Пример #1
0
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;
}
Пример #2
0
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);
} 
Пример #3
0
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;
} 
Пример #4
0
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;
}