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;i<dhp->len;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'; }
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); }
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])); } }
char char_for_base(int base) { if( base < 5 ) { return char_from_base(base); } if( base == BASE_GAP ) { return '-'; } else { return ' '; } }
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"); }
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); }
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<nmer_size-1;i++) base *= 4; basepair = (int) (dnanumber / base); return char_from_base(basepair); } }
char char_complement_base(char c) { return char_from_base(complement_base(base_from_char(c))); }