1 #ifndef INCLUDEDEFINE_DEF
2 #define INCLUDEDEFINE_DEF
3 
4 //standard libs
5 #include <algorithm>
6 #include <cstring>
7 #include <string>
8 #include <iostream>
9 #include <fstream>
10 #include <sstream>
11 #include <time.h>
12 #include <ctime>
13 #include <iomanip>
14 #include <vector>
15 #include <sys/types.h>
16 #include <sys/ipc.h>
17 #include <sys/shm.h>
18 #include <sys/mman.h>
19 #include <sys/stat.h>
20 #include <fcntl.h>
21 #include <errno.h>
22 #include <limits>
23 #include <stdint.h>
24 #include <omp.h>
25 #include <math.h>
26 #include <assert.h>
27 
28 #include "VERSION"
29 
30 #define ERROR_OUT string ( __FILE__ ) +":"+ to_string ( (uint) __LINE__ ) +":"+ string ( __FUNCTION__ )
31 
32 //external libs
33 #define SAMTOOLS_BGZF_H <htslib/bgzf.h>
34 #define SAMTOOLS_SAM_H  <htslib/sam.h>
35 
36 using namespace std;
37 
38 #ifdef COMPILE_FOR_MAC
39   //some Mac's idiosyncrasies: standard SHM libraries are very old and missing some definitions
40   #define SHM_NORESERVE 0
41 #endif
42 
43 #if defined(__mips__) && !defined(SHM_NORESERVE)
44 #define SHM_NORESERVE 010000
45 #endif
46 
47 typedef int8_t int8;
48 typedef uint8_t uint8;
49 
50 #define uint unsigned long long
51 #define sint signed long long
52 #define uint64 unsigned long long
53 #define uint32 unsigned int
54 #define uint16 unsigned short int
55 #define uchar unsigned char
56 #define int64 long long
57 #define int32 int
58 
59 // this is gcc extension, may need to redefine for other compilers
60 #define uint128 __uint128_t
61 
62 #define GENOME_spacingChar 5
63 
64 #define uintWinBin unsigned short
65 #define uintWinBinMax numeric_limits<uint16>::max()
66 
67 
68 #define intSWscore int
69 #define intScore int
70 
71 #define scoreMatch 1
72 
73 //cleaned
74 //output
75 #define BAMoutput_oneAlignMaxBytes 100000
76 
77 //SAM attributes
78 #define ATTR_NH 1
79 #define ATTR_HI 2
80 #define ATTR_AS 3
81 #define ATTR_NM 4
82 #define ATTR_MD 5
83 #define ATTR_nM 6
84 #define ATTR_jM 7
85 #define ATTR_jI 8
86 #define ATTR_XS 9
87 #define ATTR_RG 10
88 #define ATTR_vG 11
89 #define ATTR_vA 12
90 #define ATTR_vW 13
91 #define ATTR_ch 14
92 #define ATTR_MC 15
93 #define ATTR_rB 16
94 #define ATTR_CR 17
95 #define ATTR_CY 18
96 #define ATTR_UR 19
97 #define ATTR_UY 20
98 #define ATTR_CB 21
99 #define ATTR_UB 22
100 #define ATTR_GX 23
101 #define ATTR_GN 24
102 #define ATTR_sM 25
103 #define ATTR_sS 26
104 #define ATTR_sQ 27
105 #define ATTR_ha 28
106 #define ATTR_cN 29
107 
108 //BAM definitions
109 #define BAM_CIGAR_MaxSize 10000
110 #define BAM_CIGAR_OperationShift 4
111 #define BAM_CIGAR_M 0
112 #define BAM_CIGAR_I 1
113 #define BAM_CIGAR_D 2
114 #define BAM_CIGAR_N 3
115 #define BAM_CIGAR_S 4
116 #define BAM_CIGAR_H 5
117 #define BAM_CIGAR_P 6
118 #define BAM_CIGAR_EQ 7
119 #define BAM_CIGAR_X 8
120 
121 
122 
123 #define BAM_ATTR_MaxSize 10000
124 
125 #if defined COMPILE_FOR_LONG_READS
126     #define MAX_N_EXONS 1000
127 #else
128     #define MAX_N_EXONS 20
129 #endif
130 
131 //input reads
132 #define MAX_N_MATES 3
133 #define DEF_readNameLengthMax 50000
134 #if defined COMPILE_FOR_LONG_READS
135     #define DEF_readSeqLengthMax 500000
136 #else
137     #define DEF_readSeqLengthMax 650
138 #endif
139 
140 #if (DEF_readNameLengthMax > DEF_readSeqLengthMax)
141         #define DEF_readNameSeqLengthMax DEF_readNameLengthMax
142 #else
143         #define DEF_readNameSeqLengthMax DEF_readSeqLengthMax
144 #endif
145 
146 #define EXIT_CODE_BUG 101
147 #define EXIT_CODE_PARAMETER 102
148 #define EXIT_CODE_RUNTIME 103
149 #define EXIT_CODE_INPUT_FILES 104
150 #define EXIT_CODE_GENOME_FILES 105
151 #define EXIT_CODE_SHM 106
152 #define EXIT_CODE_GENOME_LOADING_WAITED_TOO_LONG 107
153 #define EXIT_CODE_MEMORY_ALLOCATION 108
154 #define EXIT_CODE_FILE_OPEN 109
155 #define EXIT_CODE_FILE_WRITE 110
156 #define EXIT_CODE_INCONSISTENT_DATA 111
157 #define EXIT_CODE_FIFO 112
158 
159 //cleaned-end
160 
161 
162 //exit codes
163 #define EXIT_createExtendWindowsWithAlign_TOO_MANY_WINDOWS 101
164 
165 #define SJ_MOTIF_SIZE 7 //number of recorded SJ motifs
166 #define SJ_SAM_AnnotatedMotifShift 20
167 
168 #define EXTEND_ORDER 1 //1-first extend to the 5' of the read, then 3'; 2- first extend to the left, then to the right
169 
170 #define MAX_N_FRAG 2
171 #define MARK_FRAG_SPACER_BASE 11
172 #define MAX_N_CHIMERAS 5
173 #define MAX_N_MULTMAP 100000 //max number of multiple mappers
174 #define MAX_SJ_REPEAT_SEARCH 255 //max length of a repeat to search around a SJ
175 #define MAX_QS_VALUE 60
176 #define MAX_OUTPUT_FLAG 10
177 
178 #define PC_rStart 0
179 #define PC_Length 1
180 #define PC_Str 2
181 #define PC_Dir 3
182 #define PC_Nrep 4
183 #define PC_SAstart 5
184 #define PC_SAend 6
185 #define PC_iFrag 7
186 #define PC_SIZE 8
187 
188 #define WC_Str 0
189 #define WC_Chr 1
190 #define WC_gStart 2
191 #define WC_gEnd 3
192 #define WC_SIZE 4
193 
194 #define WA_Length 0
195 #define WA_rStart 1
196 #define WA_gStart 2
197 #define WA_Nrep 3
198 #define WA_Anchor 4
199 #define WA_iFrag 5
200 #define WA_sjA 6
201 #define WA_SIZE 7
202 
203 #define EX_R 0
204 #define EX_G 1
205 #define EX_L 2
206 #define EX_iFrag 3
207 #define EX_sjA 4
208 #define EX_SIZE 5
209 
210 //mapType
211 #define MT_PE 0 //paired end type
212 #define MT_SIZE 5
213 
214 #define MARKER_ALL_PIECES_EXCEED_seedMultimapNmax 999901 //marks the reads that map too many time, more than seedMultimapNmax
215 #define MARKER_NO_UNIQUE_PIECES 999902 //the best transcript does not contain any unique pieces
216 #define MARKER_NO_GOOD_WINDOW 999903 //did not find any good windows
217 #define MARKER_NO_GOOD_PIECES 999904
218 #define MARKER_TOO_MANY_ANCHORS_PER_WINDOW 999905
219 #define MARKER_MAX_N_MULT_EXCEEDED 999906
220 #define MARKER_FULL_LENGTH_MULTIMAPPER_EXCEEDED_alignWindowsPerReadNmax 999907
221 #define MARKER_ALL_PIECES_EXCEEDED_winAnchorMultimapNmax 999908
222 #define MARKER_TOO_MANY_CHIMERAS 999909
223 #define MARKER_READ_TOO_SHORT 999910
224 
225 #define PEMARKER_SINGLE_END 0
226 #define PEMARKER_PAIR 1
227 #define PEMARKER_ONE_END 3
228 #define PEMARKER_TOO_MANY_PAIRS 5
229 #define PEMARKER_CHIMERIC_PAIRS 7
230 #define PEMARKER_CHIMERIC_SJ_READ1 221
231 #define PEMARKER_CHIMERIC_SJ_READ2 223
232 #define PEMARKER_CHIMERIC_SJ_READ1and2 225
233 #define PEMARKER_SINGLE_END_NOTMAPPED 1001
234 
235 
236 typedef uint uiPC[PC_SIZE];
237 typedef uint uiWC[WC_SIZE];
238 typedef uint uiWA[WA_SIZE];
239 
240 // debugging
241 //#define DEBUG_Nread 1000000
242 //#define DEBUG
243 #if defined DEBUG
244     #define DEBUG_stitch
245     #define DEBUG_Nread 200000
246     #define DEBUG_NreadStart 1
247     #define DEBUG_extend
248 #endif
249 
250 // #define DEBUG_NreadStart 500000
251 
252 #endif
253