15 typedef uint64_t HIT_INT_TYPE;
16 typedef uint64_t READ_INT_TYPE;
18 const int STRLEN = 10005 ;
19 const double EPSILON = 1e-300;
20 const double MINEEL = 1.0;
21 const double ORIVALVE = 0.1;
22 const int RANGE = 201;
23 const int OLEN = 25; // overlap length, number of bases must not be in poly(A) tails
24 const int NBITS = 32; // use unsigned int, 32 bits per variable
26 static bool verbose = true; // show detail intermediate outputs
28 inline bool isZero(double a) { return fabs(a) < 1e-8; }
29 inline bool isLongZero(double a) { return fabs(a) < 1e-30; }
31 // Assume char's range is -128..127
32 const int CHAR_RANGE = 128;
34 static std::vector<int> init_base2id() {
35 std::vector<int> vec(CHAR_RANGE, -1);
36 vec['a'] = vec['A'] = 0;
37 vec['c'] = vec['C'] = 1;
38 vec['g'] = vec['G'] = 2;
39 vec['t'] = vec['T'] = 3;
40 vec['n'] = vec['N'] = 4;
45 static const std::vector<int> base2id = init_base2id();
47 inline int get_base_id(char c) {
48 if (c < 0 || base2id[c] < 0) {
49 fprintf(stderr, "Found unknown sequence letter %c at function get_base_id!\n", c);
55 static std::vector<int> init_rbase2id() {
56 std::vector<int> vec(CHAR_RANGE, -1);
57 vec['a'] = vec['A'] = 3;
58 vec['c'] = vec['C'] = 2;
59 vec['g'] = vec['G'] = 1;
60 vec['t'] = vec['T'] = 0;
61 vec['n'] = vec['N'] = 4;
66 static const std::vector<int> rbase2id = init_rbase2id();
68 inline int get_rbase_id(char c) {
69 if (c < 0 || rbase2id[c] < 0) {
70 fprintf(stderr, "Found unknown sequence letter %c at function get_rbase_id!\n", c);
76 inline char getOpp(char c) {
78 case 'a' : return 't';
79 case 'c' : return 'g';
80 case 'g' : return 'c';
81 case 't' : return 'a';
82 case 'n' : return 'n';
83 case 'A' : return 'T';
84 case 'C' : return 'G';
85 case 'G' : return 'C';
86 case 'T' : return 'A';
87 case 'N' : return 'N';
89 fprintf(stderr, "Found unknown sequence letter %c!\n", c);
94 inline char getCharacter(int id) {
102 fprintf(stderr, "Found unknown id %d!\n", id);
107 static std::vector<unsigned int> init_mask_code() {
108 std::vector<unsigned int> vec(NBITS);
109 for (int i = 0; i < NBITS; i++) vec[i] = 1 << i;
113 static std::vector<unsigned int> mask_codes = init_mask_code();
115 inline std::string cleanStr(const std::string& str) {
116 int len = str.length();
120 while (fr < len && isspace(str[fr])) ++fr;
122 while (to >= 0 && isspace(str[to])) --to;
124 return (fr <= to ? str.substr(fr, to - fr + 1) : "");
127 inline void genReadFileNames(const char* readFN, int tagType, int read_type, int& s, char readFs[][STRLEN]){
128 const char tags[3][STRLEN] = {"un", "alignable", "max"};
131 if (read_type == 0 || read_type == 2) {
132 strcpy(suffix, "fa");
135 strcpy(suffix, "fq");
138 if (read_type == 0 || read_type == 1) {
140 sprintf(readFs[0], "%s_%s.%s", readFN, tags[tagType], suffix);
144 sprintf(readFs[0], "%s_%s_1.%s", readFN, tags[tagType], suffix);
145 sprintf(readFs[1], "%s_%s_2.%s", readFN, tags[tagType], suffix);
149 inline void printTimeUsed(const time_t& a, const time_t& b, const char* program_name) {
150 int hh = (b - a) / 3600;
151 int mm = (b - a) % 3600 / 60;
152 int ss = (b - a) % 60;
154 printf("Time Used for %s : %d h %02d m %02d s\n", program_name, hh, mm, ss);