#include "gdna.h" #include const char* IUPAC_2BIT ="AACCTTGGTTAAAAAACCCCGGAAAAAACCAAAAAA"; const char* IUPAC_2BITN ="001133223300000011112200000011000000"; const char* IUPAC_DEFS ="AaCcTtGgUuMmRrWwSsYyKkVvHhDdBbNnXx-*"; const char* IUPAC_COMP ="TtGgAaCcAaKkYyWwSsRrMmBbDdHhVvNnXx-*"; #define A_2BIT 0 // 00 #define C_2BIT 1 // 01 #define G_2BIT 2 // 10 #define T_2BIT 3 // 11 static byte ntCompTable[256]; static byte nt2bit[256]; //maps any character to a 2bit base value (with N = A) static char v_2bit2nt[4] = {'A','C','G','T'}; //---------------------- static bool gdna_Ready=gDnaInit(); //---------------------- byte gdna2bit(char* &nt, int n) { // Pack n bases into a byte (n can be 1..4) byte out = 0; while (n && *nt) { n--; out <<= 2; out += nt2bit[(int)*nt]; nt++; } #ifdef GDEBUG if (n) { GError("Error: attempt to read 6-mer beyond the end of the string!\n"); } #endif return out; } char ntComplement(char c) { return ntCompTable[(int)c]; } char g2bit2base(byte v2bit) { return v_2bit2nt[v2bit & 0x03 ]; } //in place reverse complement of nucleotide (sub)sequence char* reverseComplement(char* seq, int slen) { if (slen==0) slen=strlen(seq); //reverseChars(seq,len); int l=0; int r=slen-1; char c; while (l