File: codons.h

package info (click to toggle)
cufflinks 1.3.0-2
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 3,864 kB
  • sloc: cpp: 48,999; ansic: 12,297; sh: 3,381; python: 432; makefile: 209
file content (54 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef CODONS_H
#define CODONS_H
#include "GBase.h"
#include <ctype.h>

unsigned short packCodon(char n1, char n2, char n3);
//assumes n1,n2,n3 are UPPERCASE!

struct Codon {
 char nuc[3];
 Codon(char* str=NULL) {
  if (str==NULL) {
   nuc[0]='N';
   nuc[1]='N';
   nuc[2]='N';
   }
  else {
   nuc[0]=toupper(str[0]);
   nuc[1]=toupper(str[1]);
   nuc[2]=toupper(str[2]);
   }
  }

 Codon(char s1, char s2, char s3) {
   nuc[0]=toupper(s1);
   nuc[1]=toupper(s2);
   nuc[2]=toupper(s3);
   }
 
   
 char& operator[](int idx) {
   if (idx<0 || idx>2) 
      GError("Error: Codon index out of bounds!\n");
   return nuc[idx];
   }

 char operator[](int idx) const {
   if (idx<0 || idx>2) 
      GError("Error: Codon index out of bounds!\n");
   return nuc[idx];
   }
 
 char translate();
 };

//simple 1st frame forward translation of a given DNA string
//will allocated memory for the translation --  the caller is
// responsible for freeing the returned string!
char* translateDNA(const char* dnastr, int& aalen, int dnalen=0);


bool codonTableInit();
 
#endif