Example #1
0
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;
}
Example #2
0
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);
}
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);
} 
Example #4
0
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;i<cd->baseseq->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;

}
Example #5
0
aa aminoacid_from_seq(CodonTable * ct,char * seq)
{
  return aminoacid_from_codon(ct,codon_from_seq(seq));
}
int codon_number_func(int type,void * data,char * seq)
{
  return codon_from_seq(seq-2);
}