-
Notifications
You must be signed in to change notification settings - Fork 5
/
DNAconsts.h
208 lines (152 loc) · 5.87 KB
/
DNAconsts.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* sdm: simple demultiplexer
Copyright (C) 2013 Falk Hildebrand
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DNAconsts_h
#define _DNAconsts_h
//compile with multi threading support
#define _THREADE //D
//do vector based DNA matching
#define _NEWMATCH
//sum up uc file to OTU abundance matrix in seed extension step
#define matrix_sum
//match barcodes based on maps
#define _fastBCmatch
//keep a base_map of dereplicated file
#define _MAPDEREPLICATE
//KHASH for faster / lower mem access
#define KHAS_H
//disable win warning about fopen
#define _CRT_SECURE_NO_WARNINGS
//better mem leak reports
#define _CRTDBG_MAP_ALLOC
//#define ZSTR
//DEBUG mode: more output
#define DEB//UG
#ifdef _DEBUG
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
// allocations to be of _CLIENT_BLOCK type
#else
#define DBG_NEW new
#endif
#define _isa//1gzip
#define _iz//lib
#define _CRT_SECURE_NO_DEPRECATE
//read gzip'd files using zlib.h
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <stdlib.h>
#include <crtdbg.h>
#elif !defined(_isa1gzip) && !defined(_izlib)
//#define _notgzip
#define _gzipread
#endif
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
//#include <string.h>
#include <string.h>
#include <map>
#include <stdlib.h>
#include <algorithm>
#include <assert.h>
#include <time.h>
#include <list>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <memory>
//#include <future>
#ifdef KHASH
#include "include/khash.hh"
#endif
//#include "include/robin_set.h"
#include "include/robin_hood.h"
//#include "include/ssw_cpp.h"
#ifdef _THREADED
#include <thread>
#include <mutex>
#endif
//#include <future>
#ifdef _WIN32
//#include <boost/chrono/thread_clock.hpp>
#endif // _WIN32
//2.10: added -5PR1cut and -5PR2cut flags (cut beginning X nts)
//2.11: added ".1" ".2" end of fastq header pairs; removed a few warnings
//2.13: fixed mem leak in output
//2.14: new model of preallocating space for input strings
//2.16: new threading model (no more dynamic threadpool) (reversed to old model)
//2.17: fixed PB rev seq checks..
//2.18: fastq autoversion updated (more robust)
//3.00: PacBio GoldenAxe, LotuS3
//3.02: ISA-L gzip read integration (reverted at the end)
//3.03: integrated safer deactivation of certain filters via "-1", GA round 2, streamlined findTag and detectBC functions
//3.04: GA v2
//3.05: fix for GA to report sample names and seed ext only to add samples with valid smpl name from demulti.add.fna
//3.06: -GoldenAxeMinAmpli / -GoldenAxeMaxAmpli added
static const float sdm_version = 3.06f;
static const char* sdm_status = "beta";
//2.08: add -logLvsQ flag & report
using namespace std;
static int maxSAqualP = 109;
static const double SAqualP[110] = {1.000000e+00,7.943282e-01,6.309573e-01,5.011872e-01,3.981072e-01,3.162278e-01,2.511886e-01,1.995262e-01,1.584893e-01,1.258925e-01
,1.000000e-01,7.943282e-02,6.309573e-02,5.011872e-02,3.981072e-02,3.162278e-02,2.511886e-02,1.995262e-02,1.584893e-02,1.258925e-02
,1.000000e-02,7.943282e-03,6.309573e-03,5.011872e-03,3.981072e-03,3.162278e-03,2.511886e-03,1.995262e-03,1.584893e-03,1.258925e-03
,1.000000e-03,7.943282e-04,6.309573e-04,5.011872e-04,3.981072e-04,3.162278e-04,2.511886e-04,1.995262e-04,1.584893e-04,1.258925e-04
,1.000000e-04,7.943282e-05,6.309573e-05,5.011872e-05,3.981072e-05,3.162278e-05,2.511886e-05,1.995262e-05,1.584893e-05,1.258925e-05
,1.000000e-05,7.943282e-06,6.309573e-06,5.011872e-06,3.981072e-06,3.162278e-06,2.511886e-06,1.995262e-06,1.584893e-06,1.258925e-06
,1.000000e-06,7.943282e-07,6.309573e-07,5.011872e-07,3.981072e-07,3.162278e-07,2.511886e-07,1.995262e-07,1.584893e-07,1.258925e-07
,1.000000e-07, 1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07
,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07 ,1.000000e-07
, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07
, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07, 1.000000e-07 };
static const char DNA_SPACE[15] = {'A','C','G','T','N','R','Y','M','K','W','S','B','D','H','V'};
static const int DNA_MAX_IN_MEM = 5000;
static const unsigned int MAX_FILE_STREAMS = 500;
static const int RDBUFFER = 4096;
static size_t INPUT_BUFFER_SIZE = 80000;
static size_t OUTPUT_BUFFER_SIZE = 50000;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef signed char qual_score; //used for quality scores in vectors
//seeding
static const float BestLengthRatio = 0.8f;
static const float RefLengthRatio = 0.85f;
static const qual_score MinQualDiff = 5;
bool canonicalDNA(char x);
void ini_DNAconstants();
// first base is [ACTG], second can be IUPAC
/*code description
A Adenine
C Cytosine
G Guanine
T Thymine
U Uracil
R Purine (A or G)
Y Pyrimidine (C, T, or U)
M C or A
K T, U, or G
W T, U, or A
S C or G
B C, T, U, or G (not A)
D A, T, U, or G (not C)
H A, T, U, or C (not G)
V A, C, or G (not T, not U)
N Any base (A, C, G, T, or U)
*/
#endif