93 int i, j, k, p, q,
r, nx, st;
94 static char charToBase [17] =
"-ACMGRSVTWYHKDBN";
95 static char baseToComp [17] =
"-TGKCYSBAWRDMHVN";
98 for (
i = 0;
i < 256;
i++) {
106 ch = (
unsigned char)
tolower (ch);
140 const string *sncbieaa)
const
144 int i, j, k, p, q,
r, x, y, z, st, cd;
147 static int codonIdx [9] = {0, 2, 1, 0, 3, 0, 0, 0, 0};
150 if (ncbieaa == 0 || sncbieaa == 0)
return;
153 if (ncbieaa->size () != 64 || sncbieaa->size () != 64)
return;
156 for (
i = 0;
i <= 4096;
i++) {
171 for (p = 0; p < 4 && go_on; p++) {
174 for (q = 0; q < 4 && go_on; q++) {
177 for (
r = 0;
r < 4 && go_on;
r++) {
187 cd = 16 * codonIdx [x] + 4 * codonIdx [y] + codonIdx [z];
190 ch = (*ncbieaa) [cd];
193 }
else if (aa != ch) {
195 if ((aa ==
'B' || aa ==
'D' || aa ==
'N') &&
196 (ch ==
'D' || ch ==
'N')) {
198 }
else if ((aa ==
'Z' || aa ==
'E' || aa ==
'Q') &&
199 (ch ==
'E' || ch ==
'Q')) {
201 }
else if ((aa ==
'J' || aa ==
'I' || aa ==
'L') &&
202 (ch ==
'I' || ch ==
'L')) {
210 ch = (*sncbieaa) [cd];
213 }
else if (orf != ch) {
218 if (aa ==
'X' && orf ==
'X') {
235 }
else if (orf !=
'\0') {
342 static char na[4] = {
'T',
'C',
'A',
'G' };
347 for (
int i = 0;
i < 3; ++
i ) {
361 codon.insert(codon.end(), base1);
362 codon.insert(codon.end(), base2);
363 codon.insert(codon.end(), base3);
386 if ( codon.length() != 3 )
return false;
388 for (
int i = 0;
i < 3; ++
i ) {
389 unsigned char ch = (
unsigned char)
toupper(codon[
i]);
409 for (
int i = 0;
i < 3; ++
i ) {
410 switch (
toupper((
unsigned char) codon[
i]) ) {
452 unique_ptr<CObjectIStream>
480 const string * ncbieaa = 0;
481 const string * sncbieaa = 0;
485 switch ((*gcd)->Which ()) {
487 ncbieaa = & (*gcd)->GetNcbieaa ();
490 sncbieaa = & (*gcd)->GetSncbieaa ();
498 if (ncbieaa == 0 || sncbieaa == 0) {
500 "Could not find ncbieaa and sncbieaa");
536 if ((*gcd)->IsId () && (*gcd)->GetId () ==
id) {
556 "Unable to find genetic code number " +
562 const string * ncbieaa = 0;
563 const string * sncbieaa = 0;
566 switch ((*gcd)->Which ()) {
570 int id = (*gcd)->GetId ();
575 }
else if (
id == 8) {
577 }
else if (
id == 0) {
583 ncbieaa = & (*gcd)->GetNcbieaa ();
586 sncbieaa = & (*gcd)->GetSncbieaa ();
593 if (ncbieaa != 0 && sncbieaa != 0) {
597 "GetTransTable without ID not yet supported");
601 "GetTransTable does not have sufficient information");
613 if ( (*gcl)->GetId() ==
id ) {
614 return (*gcl)->GetNcbieaa();
630 if ( (*gcl)->GetId() ==
id ) {
631 return (*gcl)->GetSncbieaa();
682 #define s_GenCodeTblMemStr CGen_code_table_imp::sm_GenCodeTblMemStr
static bool s_ValidCodon(const string &codon)
DEFINE_STATIC_FAST_MUTEX(s_ImplementationMutex)
vector< CRef< CTrans_table > > TTransTablesById
const CTrans_table & GetTransTable(int gc)
CRef< CGenetic_code_table > m_GcTable
const string & GetNcbieaa(int id) const
static const char *const sm_GenCodeTblMemStr[]
CGen_code_table_imp(void)
~CGen_code_table_imp(void)
const string & GetSncbieaa(int id) const
TTransTablesById m_TransTablesById
const CGenetic_code_table & GetCodeTable(void)
static const string & GetNcbieaa(int id)
static string IndexToCodon(int index)
static const CTrans_table & GetTransTable(int id)
static void LoadTransTable(CObjectIStream &ois)
static AutoPtr< CGen_code_table_imp > sm_Implementation
static int CodonToIndex(char base1, char base2, char base3)
static const CGenetic_code_table & GetCodeTable(void)
static CGen_code_table_imp & x_GetImplementation(void)
static void x_InitImplementation(void)
static const string & GetSncbieaa(int id)
~CGenetic_code_table(void)
const string & GetNcbieaa(void) const
const string & GetSncbieaa(void) const
static void x_InitFsaTable(void)
CTrans_table(const CGenetic_code &)
void x_InitFsaTransl(const string *ncbieaa, const string *sncbieaa) const
static int sm_NextState[4097]
static int sm_RvCmpState[4097]
static int sm_BaseToIdx[256]
static Int8 gcd(Int8 x, Int8 y)
static const char * str(char *buf, int n)
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
element_type * get(void) const
Get pointer.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
ESerialDataFormat
Data file format.
@ eSerial_AsnText
ASN.1 text.
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
uint8_t Uint1
1-byte (8-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static const string & Get(void)
Get string.
list< CRef< CGenetic_code > > Tdata
list< CRef< C_E > > Tdata
const Tdata & Get(void) const
Get the member data.
const Tdata & Get(void) const
Get the member data.
@ e_Sncbieaa
start, indexed to IUPAC extended
@ e_Ncbieaa
indexed to IUPAC extended
unsigned int
A callback function used to compare two keys in a database.
Multi-threading – mutexes; rw-locks; semaphore.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)