| 1 | #cxx . . $ `<file>/meryl/kmer-mask.C`/include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | #include "util++.H"cxx . . $ `<file>/libutil/util++.H`/ |
| 5 | #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/ |
| 6 | #include "libmeryl.H"cxx . . $ `<file>/libmeryl/libmeryl.H`/ |
| 7 | #include "existDB.H"cxx . . $ `<file>/libkmer/existDB.H`/ |
| 8 | |
| 9 | #include "seqCache.H"cxx . . $ `<file>/libseq/seqCache.H`/ |
| 10 | #include "seqStream.H"cxx . . $ `<file>/libseq/seqStream.H`/ |
| 11 | #include "merStream.H"cxx . . $ `<file>/libseq/merStream.H`/ |
| 12 | |
| 13 | #include "sweatShop.H"cxx . . $ `<file>/libutil/sweatShop.H`/ |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | class fastqRecordcxx . . $ fastqRecord# { |
| 19 | public: |
| 20 | fastqRecordcxx . . $ fastqRecord#fastqRecord(cb2f890c2fdad230).(uint32cxx . . $ uint32# ml) { |
| 21 | maxLengthcxx . . $ fastqRecord#maxLength. = ml; |
| 22 | alloccxx . . $ fastqRecord#alloc. = new char [maxLengthcxx . . $ fastqRecord#maxLength. * 8]; |
| 23 | |
| 24 | a2cxx . . $ fastqRecord#a2. = alloccxx . . $ fastqRecord#alloc. + 0 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 25 | afcxx . . $ fastqRecord#af. = alloccxx . . $ fastqRecord#alloc. + 1 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 26 | amcxx . . $ fastqRecord#am. = alloccxx . . $ fastqRecord#alloc. + 2 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 27 | a4cxx . . $ fastqRecord#a4. = alloccxx . . $ fastqRecord#alloc. + 3 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 28 | |
| 29 | a1cxx . . $ fastqRecord#a1.[0] = 0; |
| 30 | a2cxx . . $ fastqRecord#a2.[0] = 0; |
| 31 | afcxx . . $ fastqRecord#af.[0] = 0; |
| 32 | amcxx . . $ fastqRecord#am.[0] = 0; |
| 33 | a3cxx . . $ fastqRecord#a3.[0] = 0; |
| 34 | a4cxx . . $ fastqRecord#a4.[0] = 0; |
| 35 | |
| 36 | aLengthcxx . . $ fastqRecord#aLength. = 0; |
| 37 | aMaskedcxx . . $ fastqRecord#aMasked. = 0.0; |
| 38 | aLabelcxx . . $ fastqRecord#aLabel. = 0; |
| 39 | |
| 40 | b2cxx . . $ fastqRecord#b2. = alloccxx . . $ fastqRecord#alloc. + 4 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 41 | bfcxx . . $ fastqRecord#bf. = alloccxx . . $ fastqRecord#alloc. + 5 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 42 | bmcxx . . $ fastqRecord#bm. = alloccxx . . $ fastqRecord#alloc. + 6 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 43 | b4cxx . . $ fastqRecord#b4. = alloccxx . . $ fastqRecord#alloc. + 7 * maxLengthcxx . . $ fastqRecord#maxLength.; |
| 44 | |
| 45 | b1cxx . . $ fastqRecord#b1.[0] = 0; |
| 46 | b2cxx . . $ fastqRecord#b2.[0] = 0; |
| 47 | bfcxx . . $ fastqRecord#bf.[0] = 0; |
| 48 | bmcxx . . $ fastqRecord#bm.[0] = 0; |
| 49 | b3cxx . . $ fastqRecord#b3.[0] = 0; |
| 50 | b4cxx . . $ fastqRecord#b4.[0] = 0; |
| 51 | |
| 52 | bLengthcxx . . $ fastqRecord#bLength. = 0; |
| 53 | bMaskedcxx . . $ fastqRecord#bMasked. = 0.0; |
| 54 | bLabelcxx . . $ fastqRecord#bLabel. = 0; |
| 55 | }; |
| 56 | |
| 57 | ~cxx . . $ fastqRecord#`~fastqRecord`(ced63f7c635d850d).fastqRecordcxx . . $ fastqRecord#() { |
| 58 | delete [] alloccxx . . $ fastqRecord#alloc.; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | bool loadcxx . . $ fastqRecord#load(76244a888a266e11).(FILE *FASTQ1, FILE *FASTQ2) { |
| 63 | bool tooShort = false; |
| 64 | |
| 65 | a2cxx . . $ fastqRecord#a2.[maxLengthcxx . . $ fastqRecord#maxLength. - 2] = 0; |
| 66 | b2cxx . . $ fastqRecord#b2.[maxLengthcxx . . $ fastqRecord#maxLength. - 2] = 0; |
| 67 | |
| 68 | if (FASTQ1) { |
| 69 | fgets(a1cxx . . $ fastqRecord#a1., 1024, FASTQ1); chompcxx . . $ `libutil/util.h:330:9`!(a1); |
| 70 | fgets(a2cxx . . $ fastqRecord#a2., maxLengthcxx . . $ fastqRecord#maxLength., FASTQ1); chompcxx . . $ `libutil/util.h:330:9`!(a2); |
| 71 | fgets(a3cxx . . $ fastqRecord#a3., 1024, FASTQ1); chompcxx . . $ `libutil/util.h:330:9`!(a3); |
| 72 | fgets(a4cxx . . $ fastqRecord#a4., maxLengthcxx . . $ fastqRecord#maxLength., FASTQ1); chompcxx . . $ `libutil/util.h:330:9`!(a4); |
| 73 | |
| 74 | aLengthcxx . . $ fastqRecord#aLength. = strlen(a2cxx . . $ fastqRecord#a2.); |
| 75 | aMaskedcxx . . $ fastqRecord#aMasked. = 0.0; |
| 76 | aLabelcxx . . $ fastqRecord#aLabel. = 0; |
| 77 | |
| 78 | if (a2cxx . . $ fastqRecord#a2.[maxLengthcxx . . $ fastqRecord#maxLength. - 2] != 0) |
| 79 | tooShort = true; |
| 80 | } |
| 81 | |
| 82 | if (FASTQ2) { |
| 83 | fgets(b1cxx . . $ fastqRecord#b1., 1024, FASTQ2); chompcxx . . $ `libutil/util.h:330:9`!(b1); |
| 84 | fgets(b2cxx . . $ fastqRecord#b2., maxLengthcxx . . $ fastqRecord#maxLength., FASTQ2); chompcxx . . $ `libutil/util.h:330:9`!(b2); |
| 85 | fgets(b3cxx . . $ fastqRecord#b3., 1024, FASTQ2); chompcxx . . $ `libutil/util.h:330:9`!(b3); |
| 86 | fgets(b4cxx . . $ fastqRecord#b4., maxLengthcxx . . $ fastqRecord#maxLength., FASTQ2); chompcxx . . $ `libutil/util.h:330:9`!(b4); |
| 87 | |
| 88 | bLengthcxx . . $ fastqRecord#bLength. = strlen(b2cxx . . $ fastqRecord#b2.); |
| 89 | bMaskedcxx . . $ fastqRecord#bMasked. = 0.0; |
| 90 | bLabelcxx . . $ fastqRecord#bLabel. = 0; |
| 91 | |
| 92 | if (b2cxx . . $ fastqRecord#b2.[maxLengthcxx . . $ fastqRecord#maxLength. - 2] != 0) |
| 93 | tooShort = true; |
| 94 | } |
| 95 | |
| 96 | if (tooShort) { |
| 97 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: -l too small for reads:\n"); |
| 98 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " a = '%s'\n", a1cxx . . $ fastqRecord#a1.); |
| 99 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " b = '%s'\n", b1cxx . . $ fastqRecord#b1.); |
| 100 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 101 | } |
| 102 | |
| 103 | return(!feof(FASTQ1)); |
| 104 | }; |
| 105 | |
| 106 | |
| 107 | void writecxx . . $ fastqRecord#write(30d2de35654253c4).(FILE *FASTQ1, FILE *FASTQ2) { |
| 108 | |
| 109 | if (FASTQ1) |
| 110 | fprintf(FASTQ1, "%s fractionMasked=%.3f\n%s\n%s\n%s\n", a1cxx . . $ fastqRecord#a1., aMaskedcxx . . $ fastqRecord#aMasked., amcxx . . $ fastqRecord#am., a3cxx . . $ fastqRecord#a3., a4cxx . . $ fastqRecord#a4.); |
| 111 | |
| 112 | if (FASTQ2) |
| 113 | fprintf(FASTQ2, "%s fractionMasked=%.3f\n%s\n%s\n%s\n", b1cxx . . $ fastqRecord#b1., bMaskedcxx . . $ fastqRecord#bMasked., bmcxx . . $ fastqRecord#bm., b3cxx . . $ fastqRecord#b3., b4cxx . . $ fastqRecord#b4.); |
| 114 | }; |
| 115 | |
| 116 | |
| 117 | |
| 118 | public: |
| 119 | uint32cxx . . $ uint32# maxLengthcxx . . $ fastqRecord#maxLength.; |
| 120 | char *alloccxx . . $ fastqRecord#alloc.; |
| 121 | |
| 122 | char a1cxx . . $ fastqRecord#a1.[1024]; |
| 123 | char *a2cxx . . $ fastqRecord#a2.; |
| 124 | char *afcxx . . $ fastqRecord#af.; |
| 125 | char *amcxx . . $ fastqRecord#am.; |
| 126 | char a3cxx . . $ fastqRecord#a3.[1024]; |
| 127 | char *a4cxx . . $ fastqRecord#a4.; |
| 128 | |
| 129 | uint32cxx . . $ uint32# aLengthcxx . . $ fastqRecord#aLength.; |
| 130 | double aMaskedcxx . . $ fastqRecord#aMasked.; |
| 131 | uint32cxx . . $ uint32# aLabelcxx . . $ fastqRecord#aLabel.; |
| 132 | |
| 133 | char b1cxx . . $ fastqRecord#b1.[1024]; |
| 134 | char *b2cxx . . $ fastqRecord#b2.; |
| 135 | char *bfcxx . . $ fastqRecord#bf.; |
| 136 | char *bmcxx . . $ fastqRecord#bm.; |
| 137 | char b3cxx . . $ fastqRecord#b3.[1024]; |
| 138 | char *b4cxx . . $ fastqRecord#b4.; |
| 139 | |
| 140 | uint32cxx . . $ uint32# bLengthcxx . . $ fastqRecord#bLength.; |
| 141 | double bMaskedcxx . . $ fastqRecord#bMasked.; |
| 142 | uint32cxx . . $ uint32# bLabelcxx . . $ fastqRecord#bLabel.; |
| 143 | }; |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | class maskGlobalcxx . . $ maskGlobal# { |
| 149 | public: |
| 150 | maskGlobalcxx . . $ maskGlobal#maskGlobal(49f6e7a06ebc5aa8).() { |
| 151 | merNamecxx . . $ maskGlobal#merName. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 152 | |
| 153 | seq1Namecxx . . $ maskGlobal#seq1Name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 154 | seq2Namecxx . . $ maskGlobal#seq2Name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 155 | |
| 156 | outPrefixcxx . . $ maskGlobal#outPrefix. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 157 | |
| 158 | merSizecxx . . $ maskGlobal#merSize. = 0; |
| 159 | maxLengthcxx . . $ maskGlobal#maxLength. = 512; |
| 160 | |
| 161 | existNamecxx . . $ maskGlobal#existName. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 162 | minSizecxx . . $ maskGlobal#minSize. = 0; |
| 163 | extendcxx . . $ maskGlobal#extend. = 0; |
| 164 | |
| 165 | cleanercxx . . $ maskGlobal#cleaner. = false; |
| 166 | dirtiercxx . . $ maskGlobal#dirtier. = false; |
| 167 | discardcxx . . $ maskGlobal#discard. = true; |
| 168 | unlinkcxx . . $ maskGlobal#unlink. = false; |
| 169 | |
| 170 | noMaskingcxx . . $ maskGlobal#noMasking. = false; |
| 171 | |
| 172 | cleanThresholdcxx . . $ maskGlobal#cleanThreshold. = 1. / 3.; |
| 173 | matchThresholdcxx . . $ maskGlobal#matchThreshold. = 2. / 3.; |
| 174 | |
| 175 | for (uint32cxx . . $ uint32# ii=0; ii<1001; ii++) |
| 176 | scoreHistogramcxx . . $ maskGlobal#scoreHistogram.[ii] = 0; |
| 177 | |
| 178 | for (uint32cxx . . $ uint32# ii=0; ii<4; ii++) |
| 179 | for (uint32cxx . . $ uint32# jj=0; jj<4; jj++) |
| 180 | thresholdCountscxx . . $ maskGlobal#thresholdCounts.[ii][jj] = 0.0; |
| 181 | |
| 182 | outputHistogramcxx . . $ maskGlobal#outputHistogram. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 183 | |
| 184 | existcxx . . $ maskGlobal#exist. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 185 | |
| 186 | FASTQ1cxx . . $ maskGlobal#FASTQ1. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 187 | FASTQ1pipecxx . . $ maskGlobal#FASTQ1pipe. = false; |
| 188 | |
| 189 | FASTQ2cxx . . $ maskGlobal#FASTQ2. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 190 | FASTQ2pipecxx . . $ maskGlobal#FASTQ2pipe. = false; |
| 191 | |
| 192 | OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 193 | OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[1] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 194 | OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[2] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 195 | |
| 196 | OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 197 | OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[1] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 198 | OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[2] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 199 | }; |
| 200 | |
| 201 | ~cxx . . $ maskGlobal#`~maskGlobal`(ced63f7c635d850d).maskGlobalcxx . . $ maskGlobal#() { |
| 202 | }; |
| 203 | |
| 204 | |
| 205 | public: |
| 206 | char *merNamecxx . . $ maskGlobal#merName.; |
| 207 | |
| 208 | char *seq1Namecxx . . $ maskGlobal#seq1Name.; |
| 209 | char *seq2Namecxx . . $ maskGlobal#seq2Name.; |
| 210 | |
| 211 | char *outPrefixcxx . . $ maskGlobal#outPrefix.; |
| 212 | |
| 213 | uint32cxx . . $ uint32# merSizecxx . . $ maskGlobal#merSize.; |
| 214 | uint32cxx . . $ uint32# maxLengthcxx . . $ maskGlobal#maxLength.; |
| 215 | |
| 216 | char *existNamecxx . . $ maskGlobal#existName.; |
| 217 | uint32cxx . . $ uint32# minSizecxx . . $ maskGlobal#minSize.; |
| 218 | uint32cxx . . $ uint32# extendcxx . . $ maskGlobal#extend.; |
| 219 | |
| 220 | bool cleanercxx . . $ maskGlobal#cleaner.; |
| 221 | bool dirtiercxx . . $ maskGlobal#dirtier.; |
| 222 | bool discardcxx . . $ maskGlobal#discard.; |
| 223 | bool unlinkcxx . . $ maskGlobal#unlink.; |
| 224 | |
| 225 | bool noMaskingcxx . . $ maskGlobal#noMasking.; |
| 226 | |
| 227 | double cleanThresholdcxx . . $ maskGlobal#cleanThreshold.; |
| 228 | double matchThresholdcxx . . $ maskGlobal#matchThreshold.; |
| 229 | |
| 230 | uint32cxx . . $ uint32# scoreHistogramcxx . . $ maskGlobal#scoreHistogram.[1001]; |
| 231 | uint64cxx . . $ uint64# thresholdCountscxx . . $ maskGlobal#thresholdCounts.[4][4]; |
| 232 | |
| 233 | char *outputHistogramcxx . . $ maskGlobal#outputHistogram.; |
| 234 | |
| 235 | existDBcxx . . $ existDB# *existcxx . . $ maskGlobal#exist.; |
| 236 | |
| 237 | FILE *FASTQ1cxx . . $ maskGlobal#FASTQ1.; |
| 238 | bool FASTQ1pipecxx . . $ maskGlobal#FASTQ1pipe.; |
| 239 | |
| 240 | FILE *FASTQ2cxx . . $ maskGlobal#FASTQ2.; |
| 241 | bool FASTQ2pipecxx . . $ maskGlobal#FASTQ2pipe.; |
| 242 | |
| 243 | FILE *OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[4]; |
| 244 | FILE *OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[4]; |
| 245 | }; |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | // Masks mers present in the database from the input sequences. Chains together |
| 262 | // across small bits of missing mer. |
| 263 | |
| 264 | void |
| 265 | printBitscxx . . $ printBits(55de2ae18eafeecc).(char *S, uint32cxx . . $ uint32# Slen, char *found, char *display, const char *label) { |
| 266 | for (uint32cxx . . $ uint32# i=0; i<Slen; i++) |
| 267 | display[i] = (found[i]) ? '1' : '0'; |
| 268 | |
| 269 | display[Slen] = 0; |
| 270 | |
| 271 | fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s\n%s\n", label, display); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | // Scan the read for kmers that exist in the DB. Set a bit for each kmer that exists. |
| 278 | void |
| 279 | buildMaskcxx . . $ buildMask(64bcac1d815a3b18).(char *S, uint32cxx . . $ uint32# Slen, char *found, existDBcxx . . $ existDB# *exist, uint32cxx . . $ uint32# merSize) { |
| 280 | merStreamcxx . . $ merStream# MScxx . . $ merStream#merStream(c5717b5f51363f86).(new kMerBuildercxx . . $ kMerBuilder#(merSize), |
| 281 | new seqStreamcxx . . $ seqStream#(S, Slen), |
| 282 | true, true); |
| 283 | |
| 284 | for (uint32cxx . . $ uint32# i=0; i<Slen; i++) |
| 285 | found[i] = false; |
| 286 | |
| 287 | while (MS.nextMercxx . . $ merStream#nextMer(dfa6e707f7696010).()) |
| 288 | if (exist->existscxx . . $ existDB#exists(31596a199e1d8a50).(MS.theFMercxx . . $ merStream#theFMer(52e25c29fea41909).()) || exist->existscxx . . $ existDB#exists(31596a199e1d8a50).(MS.theRMercxx . . $ merStream#theRMer(52e25c29fea41909).())) |
| 289 | found[MS.thePositionInSequencecxx . . $ merStream#thePositionInSequence(f708dce9a8856c70).()] = true; |
| 290 | } |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | // Searched for isolated 'true' bits, and removes them. Isolated means fewer than minSize true |
| 296 | // bits are adjacent. |
| 297 | // |
| 298 | void |
| 299 | removeIsolatedMerscxx . . $ removeIsolatedMers(74a98b2a678c1fc8).(char *S, uint32cxx . . $ uint32# Slen, char *found, uint32cxx . . $ uint32# minSize) { |
| 300 | uint32cxx . . $ uint32# bgn = 0; |
| 301 | uint32cxx . . $ uint32# end = 0; |
| 302 | bool inRun = false; |
| 303 | |
| 304 | for (uint32cxx . . $ uint32# ii=0; ii<Slen; ii++) { |
| 305 | |
| 306 | // Start of a run of 'true'. |
| 307 | if ((found[ii] == true) && (inRun == false)) { |
| 308 | bgn = ii; |
| 309 | end = ii; |
| 310 | inRun = true; |
| 311 | } |
| 312 | |
| 313 | // End of run of 'true'. If small, destroy it. |
| 314 | if ((found[ii] == false) && (inRun == true)) { |
| 315 | end = ii; |
| 316 | |
| 317 | if (end - bgn < minSize) |
| 318 | for (uint32cxx . . $ uint32# jj=bgn; jj<end; jj++) |
| 319 | found[jj] = false; |
| 320 | |
| 321 | inRun = false; |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | |
| 327 | |
| 328 | // Convert the mer-start-based mask to a base-covering mask, allowing an extra uncovered |
| 329 | // 'extension' bases in between two blocks to join. |
| 330 | void |
| 331 | convertToBasescxx . . $ convertToBases(e07494ad5e4b565b).(char *S, uint32cxx . . $ uint32# Slen, char *found, uint32cxx . . $ uint32# merSize, uint32cxx . . $ uint32# extend) { |
| 332 | uint32cxx . . $ uint32# isMasking = 0; |
| 333 | |
| 334 | for (uint32cxx . . $ uint32# ii=0; ii<Slen; ii++) { |
| 335 | |
| 336 | if (found[ii]) |
| 337 | isMasking = merSize; |
| 338 | |
| 339 | // If the last mer we've found, see if we can extend over bases. |
| 340 | if ((isMasking == 1) && |
| 341 | (extend > 0)) { |
| 342 | for (uint32cxx . . $ uint32# jj=ii; (jj<Slen) && (jj <= ii + extend + 1); jj++) { |
| 343 | if (found[jj] == true) |
| 344 | isMasking = jj - ii + 2; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | if (isMasking > 0) { |
| 349 | found[ii] = true; |
| 350 | isMasking--; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | |
| 356 | |
| 357 | // Assumes the found[] array represents base-based masking. |
| 358 | // Returns the fraction of the sequence that is masked. |
| 359 | double |
| 360 | maskSequencecxx . . $ maskSequence(15e657618875891c).(char *S, uint32cxx . . $ uint32# Slen, char *found, bool noMasking, char *display) { |
| 361 | uint32cxx . . $ uint32# masked = 0; |
| 362 | |
| 363 | // Flip the sense of the found[ii] test to mask kmers found in the database (true) or missing (false). |
| 364 | |
| 365 | for (uint32cxx . . $ uint32# ii=0; ii<Slen; ii++) { |
| 366 | if (found[ii] == true) { |
| 367 | display[ii] = (noMasking == false) ? 'n' : S[ii]; |
| 368 | masked++; |
| 369 | } else { |
| 370 | display[ii] = S[ii]; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | display[Slen] = 0; |
| 375 | |
| 376 | return((double)masked / Slen); |
| 377 | } |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | void * |
| 387 | fastqLoadercxx . . $ fastqLoader(9f162e79bfc6c74).(void *G) { |
| 388 | maskGlobalcxx . . $ maskGlobal# *g = (maskGlobalcxx . . $ maskGlobal# *)G; |
| 389 | fastqRecordcxx . . $ fastqRecord# *s = new fastqRecordcxx . . $ fastqRecord#(g->maxLengthcxx . . $ maskGlobal#maxLength.); |
| 390 | |
| 391 | if (s->loadcxx . . $ fastqRecord#load(76244a888a266e11).(g->FASTQ1cxx . . $ maskGlobal#FASTQ1., g->FASTQ2cxx . . $ maskGlobal#FASTQ2.) == false) { |
| 392 | delete s; |
| 393 | s = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 394 | } |
| 395 | |
| 396 | return(s); |
| 397 | } |
| 398 | |
| 399 | |
| 400 | void |
| 401 | maskWorkercxx . . $ maskWorker(49f36ff46ae528d5).(void *G, void *T, void *S) { |
| 402 | maskGlobalcxx . . $ maskGlobal# *g = (maskGlobalcxx . . $ maskGlobal# *)G; |
| 403 | //maskThread *t = (maskThread *)T; |
| 404 | fastqRecordcxx . . $ fastqRecord# *s = (fastqRecordcxx . . $ fastqRecord# *)S; |
| 405 | |
| 406 | buildMaskcxx . . $ buildMask(64bcac1d815a3b18).(s->a2cxx . . $ fastqRecord#a2., s->aLengthcxx . . $ fastqRecord#aLength., s->afcxx . . $ fastqRecord#af., g->existcxx . . $ maskGlobal#exist., g->merSizecxx . . $ maskGlobal#merSize.); |
| 407 | buildMaskcxx . . $ buildMask(64bcac1d815a3b18).(s->b2cxx . . $ fastqRecord#b2., s->bLengthcxx . . $ fastqRecord#bLength., s->bfcxx . . $ fastqRecord#bf., g->existcxx . . $ maskGlobal#exist., g->merSizecxx . . $ maskGlobal#merSize.); |
| 408 | //printBits(S, found, display , "INITIAL"); |
| 409 | |
| 410 | removeIsolatedMerscxx . . $ removeIsolatedMers(74a98b2a678c1fc8).(s->a2cxx . . $ fastqRecord#a2., s->aLengthcxx . . $ fastqRecord#aLength., s->afcxx . . $ fastqRecord#af., g->minSizecxx . . $ maskGlobal#minSize.); |
| 411 | removeIsolatedMerscxx . . $ removeIsolatedMers(74a98b2a678c1fc8).(s->b2cxx . . $ fastqRecord#b2., s->bLengthcxx . . $ fastqRecord#bLength., s->bfcxx . . $ fastqRecord#bf., g->minSizecxx . . $ maskGlobal#minSize.); |
| 412 | //printBits(S, found, display, "ISOLATED REMOVAL"); |
| 413 | |
| 414 | convertToBasescxx . . $ convertToBases(e07494ad5e4b565b).(s->a2cxx . . $ fastqRecord#a2., s->aLengthcxx . . $ fastqRecord#aLength., s->afcxx . . $ fastqRecord#af., g->merSizecxx . . $ maskGlobal#merSize., g->extendcxx . . $ maskGlobal#extend.); |
| 415 | convertToBasescxx . . $ convertToBases(e07494ad5e4b565b).(s->b2cxx . . $ fastqRecord#b2., s->bLengthcxx . . $ fastqRecord#bLength., s->bfcxx . . $ fastqRecord#bf., g->merSizecxx . . $ maskGlobal#merSize., g->extendcxx . . $ maskGlobal#extend.); |
| 416 | //printBits(S, found, display, "BASE COVERAGE"); |
| 417 | |
| 418 | s->aMaskedcxx . . $ fastqRecord#aMasked. = maskSequencecxx . . $ maskSequence(15e657618875891c).(s->a2cxx . . $ fastqRecord#a2., s->aLengthcxx . . $ fastqRecord#aLength., s->afcxx . . $ fastqRecord#af., g->noMaskingcxx . . $ maskGlobal#noMasking., s->amcxx . . $ fastqRecord#am.); |
| 419 | s->bMaskedcxx . . $ fastqRecord#bMasked. = maskSequencecxx . . $ maskSequence(15e657618875891c).(s->b2cxx . . $ fastqRecord#b2., s->bLengthcxx . . $ fastqRecord#bLength., s->bfcxx . . $ fastqRecord#bf., g->noMaskingcxx . . $ maskGlobal#noMasking., s->bmcxx . . $ fastqRecord#bm.); |
| 420 | |
| 421 | s->aLabelcxx . . $ fastqRecord#aLabel. = (s->aMaskedcxx . . $ fastqRecord#aMasked. < g->cleanThresholdcxx . . $ maskGlobal#cleanThreshold.) ? 0 : ((s->aMaskedcxx . . $ fastqRecord#aMasked. < g->matchThresholdcxx . . $ maskGlobal#matchThreshold.) ? 1 : 2); |
| 422 | s->bLabelcxx . . $ fastqRecord#bLabel. = (s->bMaskedcxx . . $ fastqRecord#bMasked. < g->cleanThresholdcxx . . $ maskGlobal#cleanThreshold.) ? 0 : ((s->bMaskedcxx . . $ fastqRecord#bMasked. < g->matchThresholdcxx . . $ maskGlobal#matchThreshold.) ? 1 : 2); |
| 423 | |
| 424 | // If both reads exist, adjust labels. |
| 425 | |
| 426 | if ((s->aLengthcxx . . $ fastqRecord#aLength. > 0) && (s->bLengthcxx . . $ fastqRecord#bLength. > 0)) { |
| 427 | if ((s->aLabelcxx . . $ fastqRecord#aLabel. != s->bLabelcxx . . $ fastqRecord#bLabel.) && (g->dirtiercxx . . $ maskGlobal#dirtier.)) { |
| 428 | s->aLabelcxx . . $ fastqRecord#aLabel. = MINcxx . . $ `libutil/util.h:344:10`!(s->aLabel, s->bLabel); |
| 429 | s->bLabelcxx . . $ fastqRecord#bLabel. = MINcxx . . $ `libutil/util.h:344:10`!(s->aLabel, s->bLabel); |
| 430 | } |
| 431 | |
| 432 | if ((s->aLabelcxx . . $ fastqRecord#aLabel. != s->bLabelcxx . . $ fastqRecord#bLabel.) && (g->cleanercxx . . $ maskGlobal#cleaner.)) { |
| 433 | s->aLabelcxx . . $ fastqRecord#aLabel. = MAXcxx . . $ `libutil/util.h:348:10`!(s->aLabel, s->bLabel); |
| 434 | s->bLabelcxx . . $ fastqRecord#bLabel. = MAXcxx . . $ `libutil/util.h:348:10`!(s->aLabel, s->bLabel); |
| 435 | } |
| 436 | |
| 437 | if ((s->aLabelcxx . . $ fastqRecord#aLabel. != s->bLabelcxx . . $ fastqRecord#bLabel.) && (g->discardcxx . . $ maskGlobal#discard.)) { |
| 438 | s->aLabelcxx . . $ fastqRecord#aLabel. = 3; |
| 439 | s->bLabelcxx . . $ fastqRecord#bLabel. = 3; |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | |
| 445 | void |
| 446 | fastqWritercxx . . $ fastqWriter(6c58c5e2437d25a2).(void *G, void *S) { |
| 447 | maskGlobalcxx . . $ maskGlobal# *g = (maskGlobalcxx . . $ maskGlobal# *)G; |
| 448 | fastqRecordcxx . . $ fastqRecord# *s = (fastqRecordcxx . . $ fastqRecord# *)S; |
| 449 | |
| 450 | s->writecxx . . $ fastqRecord#write(30d2de35654253c4).(g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[s->aLabelcxx . . $ fastqRecord#aLabel.], g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[s->bLabelcxx . . $ fastqRecord#bLabel.]); |
| 451 | |
| 452 | g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[s->aLabelcxx . . $ fastqRecord#aLabel.][s->bLabelcxx . . $ fastqRecord#bLabel.]++; |
| 453 | |
| 454 | g->scoreHistogramcxx . . $ maskGlobal#scoreHistogram.[(uint32cxx . . $ uint32#)(1000 * s->aMaskedcxx . . $ fastqRecord#aMasked.)]++; |
| 455 | g->scoreHistogramcxx . . $ maskGlobal#scoreHistogram.[(uint32cxx . . $ uint32#)(1000 * s->bMaskedcxx . . $ fastqRecord#bMasked.)]++; |
| 456 | |
| 457 | delete s; |
| 458 | } |
| 459 | |
| 460 | |
| 461 | FILE * |
| 462 | openInputcxx . . $ openInput(6131e4441231c162).(char *filename, bool &P) { |
| 463 | char C[2 * FILENAME_MAXcxx . . $ `<external>/12724488666731946084/stdio_lim.h:26:9`!]; |
| 464 | FILE *F = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 465 | int32cxx . . $ int32# L = (filename == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) ? 0 : strlen(filename); |
| 466 | |
| 467 | if (filename == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 468 | return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 469 | |
| 470 | if (fileExists(filename) == false) |
| 471 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed to open Input file '%s' for reading: File not found.\n", filename), exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 472 | |
| 473 | if ((L > 3) && (strcmp(filename + L - 3, ".gz") == 0)) { |
| 474 | sprintf(C, "gzip -dc %s", filename); |
| 475 | F = popen(C, "r"); |
| 476 | P = true; |
| 477 | } |
| 478 | |
| 479 | else if ((L > 4) && (strcmp(filename + L - 4, ".bz2") == 0)) { |
| 480 | sprintf(C, "bzip2 -dc %s", filename); |
| 481 | F = popen(C, "r"); |
| 482 | P = true; |
| 483 | } |
| 484 | |
| 485 | else if ((L > 3) && (strcmp(filename + L - 3, ".xz") == 0)) { |
| 486 | sprintf(C, "xz -dc %s", filename); |
| 487 | F = popen(C, "r"); |
| 488 | P = true; |
| 489 | } |
| 490 | |
| 491 | else { |
| 492 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 493 | F = fopen(filename, "r"); |
| 494 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 495 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed to open input file '%s' for reading: %s\n", filename, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 496 | P = false; |
| 497 | } |
| 498 | |
| 499 | return(F); |
| 500 | } |
| 501 | |
| 502 | |
| 503 | void |
| 504 | closeInputcxx . . $ closeInput(496d627add48d26f).(FILE *F, char *filename, bool P) { |
| 505 | if (F == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 506 | return; |
| 507 | |
| 508 | if (P) |
| 509 | pclose(F); |
| 510 | else |
| 511 | fclose(F); |
| 512 | } |
| 513 | |
| 514 | |
| 515 | |
| 516 | FILE * |
| 517 | openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(char *prefix, const char *extension) { |
| 518 | char N[FILENAME_MAXcxx . . $ `<external>/12724488666731946084/stdio_lim.h:26:9`!]; |
| 519 | FILE *F = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 520 | |
| 521 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 522 | |
| 523 | sprintf(N, "%s.%s.fastq", prefix, extension); |
| 524 | F = fopen(N, "w"); |
| 525 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 526 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: failed to open '%s': %s\n", N, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 527 | |
| 528 | return(F); |
| 529 | } |
| 530 | |
| 531 | |
| 532 | void |
| 533 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(FILE *F, char *prefix, const char *extension) { |
| 534 | if (F) |
| 535 | fclose(F); |
| 536 | } |
| 537 | |
| 538 | |
| 539 | |
| 540 | int |
| 541 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) { |
| 542 | maskGlobalcxx . . $ maskGlobal# *g = new maskGlobalcxx . . $ maskGlobal#(); |
| 543 | |
| 544 | uint32cxx . . $ uint32# numWorkers = 1; |
| 545 | bool beVerbose = false; |
| 546 | |
| 547 | int32cxx . . $ int32# arg=1; |
| 548 | int32cxx . . $ int32# err=0; |
| 549 | while (arg < argc) { |
| 550 | if (strcmp(argv[arg], "-mdb") == 0) { |
| 551 | g->merNamecxx . . $ maskGlobal#merName. = argv[++arg]; |
| 552 | |
| 553 | } else if (strcmp(argv[arg], "-ms") == 0) { |
| 554 | g->merSizecxx . . $ maskGlobal#merSize. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 555 | |
| 556 | } else if (strcmp(argv[arg], "-l") == 0) { |
| 557 | g->maxLengthcxx . . $ maskGlobal#maxLength. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 558 | |
| 559 | } else if (strcmp(argv[arg], "-edb") == 0) { |
| 560 | g->existNamecxx . . $ maskGlobal#existName. = argv[++arg]; |
| 561 | |
| 562 | } else if (strcmp(argv[arg], "-1") == 0) { |
| 563 | g->seq1Namecxx . . $ maskGlobal#seq1Name. = argv[++arg]; |
| 564 | } else if (strcmp(argv[arg], "-2") == 0) { |
| 565 | g->seq2Namecxx . . $ maskGlobal#seq2Name. = argv[++arg]; |
| 566 | |
| 567 | } else if (strcmp(argv[arg], "-o") == 0) { |
| 568 | g->outPrefixcxx . . $ maskGlobal#outPrefix. = argv[++arg]; |
| 569 | |
| 570 | } else if (strcmp(argv[arg], "-m") == 0) { |
| 571 | g->minSizecxx . . $ maskGlobal#minSize. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 572 | |
| 573 | } else if (strcmp(argv[arg], "-e") == 0) { |
| 574 | g->extendcxx . . $ maskGlobal#extend. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 575 | |
| 576 | } else if (strcmp(argv[arg], "-t") == 0) { |
| 577 | numWorkers = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 578 | } else if (strcmp(argv[arg], "-v") == 0) { |
| 579 | beVerbose = true; |
| 580 | |
| 581 | } else if (strcmp(argv[arg], "-cleaner") == 0) { |
| 582 | g->dirtiercxx . . $ maskGlobal#dirtier. = false; |
| 583 | g->cleanercxx . . $ maskGlobal#cleaner. = true; |
| 584 | g->discardcxx . . $ maskGlobal#discard. = false; |
| 585 | g->unlinkcxx . . $ maskGlobal#unlink. = false; |
| 586 | |
| 587 | } else if (strcmp(argv[arg], "-dirtier") == 0) { |
| 588 | g->dirtiercxx . . $ maskGlobal#dirtier. = true; |
| 589 | g->cleanercxx . . $ maskGlobal#cleaner. = false; |
| 590 | g->discardcxx . . $ maskGlobal#discard. = false; |
| 591 | g->unlinkcxx . . $ maskGlobal#unlink. = false; |
| 592 | |
| 593 | } else if (strcmp(argv[arg], "-discard") == 0) { |
| 594 | g->dirtiercxx . . $ maskGlobal#dirtier. = false; |
| 595 | g->cleanercxx . . $ maskGlobal#cleaner. = false; |
| 596 | g->discardcxx . . $ maskGlobal#discard. = true; |
| 597 | g->unlinkcxx . . $ maskGlobal#unlink. = false; |
| 598 | |
| 599 | } else if (strcmp(argv[arg], "-unlink") == 0) { |
| 600 | g->dirtiercxx . . $ maskGlobal#dirtier. = false; |
| 601 | g->cleanercxx . . $ maskGlobal#cleaner. = false; |
| 602 | g->discardcxx . . $ maskGlobal#discard. = false; |
| 603 | g->unlinkcxx . . $ maskGlobal#unlink. = true; |
| 604 | |
| 605 | } else if (strcmp(argv[arg], "-nomasking") == 0) { |
| 606 | g->noMaskingcxx . . $ maskGlobal#noMasking. = true; |
| 607 | |
| 608 | } else if (strncmp(argv[arg], "-clean", 3) == 0) { |
| 609 | g->cleanThresholdcxx . . $ maskGlobal#cleanThreshold. = atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg]); |
| 610 | } else if (strncmp(argv[arg], "-match", 3) == 0) { |
| 611 | g->matchThresholdcxx . . $ maskGlobal#matchThreshold. = atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg]); |
| 612 | |
| 613 | } else if (strcmp(argv[arg], "-h") == 0) { |
| 614 | g->outputHistogramcxx . . $ maskGlobal#outputHistogram. = argv[++arg]; |
| 615 | |
| 616 | } else { |
| 617 | err++; |
| 618 | } |
| 619 | |
| 620 | arg++; |
| 621 | } |
| 622 | if ((g->outPrefixcxx . . $ maskGlobal#outPrefix. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (g->seq1Namecxx . . $ maskGlobal#seq1Name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 623 | err++; |
| 624 | if ((g->merNamecxx . . $ maskGlobal#merName. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (g->existNamecxx . . $ maskGlobal#existName. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 625 | err++; |
| 626 | if (err) { |
| 627 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s -mdb mer-database -ms mer-size ...\n", argv[0]); |
| 628 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 629 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "INPUTS:\n"); |
| 630 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 631 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -mdb mer-database load masking kmers from meryl 'mer-database'\n"); |
| 632 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -ms mer-size the mer size used to generate the meryl database\n"); |
| 633 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -edb exist-database save masking kmers to 'exist-database', and reuse on\n"); |
| 634 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " future runs (optional)\n"); |
| 635 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 636 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -1 in.1.fastq input reads - fastq, fastq.gz, fastq.bz2 or fastq.xz\n"); |
| 637 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -2 in.2.fastq - optional, for mated reads\n"); |
| 638 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 639 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -l length maximum length of input read (%u)\n", g->maxLengthcxx . . $ maskGlobal#maxLength.); |
| 640 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " If too small, program will fail.\n"); |
| 641 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " If too large, program will use excessive memory.\n"); |
| 642 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 643 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "THRESHOLDS and OPTIONS:\n"); |
| 644 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 645 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " A read with fewer than 'c' bases masked is 'clean', while a read with more than 'd' bases\n"); |
| 646 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " masked is 'match'ed. Reads in between are 'murky'. See OUTPUTS.\n"); |
| 647 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 648 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -clean c mark reads with less than this fraction masked as 'clean' (%.4f)\n", g->cleanThresholdcxx . . $ maskGlobal#cleanThreshold.); |
| 649 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -match d mark reads with more than this fraction masked as 'match' (%.4f)\n", g->matchThresholdcxx . . $ maskGlobal#matchThreshold.); |
| 650 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 651 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -m min-size ignore database hits below this many consecutive kmers (%d)\n", g->minSizecxx . . $ maskGlobal#minSize.); |
| 652 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -e extend-size extend database hits across this many missing kmers (%d)\n", g->extendcxx . . $ maskGlobal#extend.); |
| 653 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 654 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " For mate pairs, how to handle reads with different classifications:\n"); |
| 655 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 656 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -cleaner use the cleaner classification of the two reads\n"); |
| 657 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -dirtier use the dirtier classification of the two reads\n"); |
| 658 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -discard discard pairs with conflicting classifications (DEFAULT)\n"); |
| 659 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -unlink leave conflicting status alone, output reads to different files\n"); |
| 660 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " NOTE: mate pairing will be broken\n"); |
| 661 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 662 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -nomasking do not trim masked sequence; output the original read\n"); |
| 663 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 664 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "OUTPUTS:\n"); |
| 665 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 666 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -o prefix output reads:\n"); |
| 667 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " prefix.clean.[12].fastq - clean (unmasked) reads\n"); |
| 668 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " prefix.murky.[12].fastq - reads in between\n"); |
| 669 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " prefix.match.[12].fastq - matching (masked) reads\n"); |
| 670 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " prefix.mixed.[12].fastq - reads with conflicting status (for mated reads)\n"); |
| 671 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -h histogram write a histogram of the amount of sequence RETAINED\n"); |
| 672 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 673 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "COMPUTE CONFIGURATION and LOGGING\n"); |
| 674 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 675 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -t t use 't' compute threads\n"); |
| 676 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -v show progress\n"); |
| 677 | |
| 678 | if ((g->outPrefixcxx . . $ maskGlobal#outPrefix. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (g->seq1Namecxx . . $ maskGlobal#seq1Name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 679 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: an output prefix (-o) must be supplied.\n"); |
| 680 | if ((g->merNamecxx . . $ maskGlobal#merName. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (g->existNamecxx . . $ maskGlobal#existName. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 681 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: either a mer-database (-mdb) or an exist-database (-edb) must be supplied.\n"); |
| 682 | |
| 683 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 684 | } |
| 685 | |
| 686 | // Open inputs and outputs |
| 687 | |
| 688 | g->FASTQ1cxx . . $ maskGlobal#FASTQ1. = openInputcxx . . $ openInput(6131e4441231c162).(g->seq1Namecxx . . $ maskGlobal#seq1Name., g->FASTQ1pipecxx . . $ maskGlobal#FASTQ1pipe.); |
| 689 | g->FASTQ2cxx . . $ maskGlobal#FASTQ2. = openInputcxx . . $ openInput(6131e4441231c162).(g->seq2Namecxx . . $ maskGlobal#seq2Name., g->FASTQ2pipecxx . . $ maskGlobal#FASTQ2pipe.); |
| 690 | |
| 691 | if (g->FASTQ1cxx . . $ maskGlobal#FASTQ1.) { |
| 692 | g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[0] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "clean.1"); // Label == 0 |
| 693 | g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[1] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "murky.1"); // Label == 1 |
| 694 | g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[2] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "match.1"); // Label == 2 |
| 695 | g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[3] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "mixed.1"); // Label == 3 |
| 696 | } |
| 697 | |
| 698 | if (g->FASTQ2cxx . . $ maskGlobal#FASTQ2.) { |
| 699 | g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[0] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "clean.2"); |
| 700 | g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[1] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "murky.2"); |
| 701 | g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[2] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "match.2"); |
| 702 | g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[3] = openOutputcxx . . $ openOutput(3da0ca7aee9fe3b3).(g->outPrefixcxx . . $ maskGlobal#outPrefix., "mixed.2"); |
| 703 | } |
| 704 | |
| 705 | // Load data |
| 706 | |
| 707 | if ((g->existNamecxx . . $ maskGlobal#existName. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (fileExists(g->existNamecxx . . $ maskGlobal#existName.))) { |
| 708 | if (beVerbose) |
| 709 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Load existDB existName='%s'.\n", g->existNamecxx . . $ maskGlobal#existName.); |
| 710 | g->existcxx . . $ maskGlobal#exist. = new existDBcxx . . $ existDB#(g->existNamecxx . . $ maskGlobal#existName.); |
| 711 | |
| 712 | } else { |
| 713 | if (beVerbose) |
| 714 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Build existDB from merName='%s'.\n", g->merNamecxx . . $ maskGlobal#merName.); |
| 715 | g->existcxx . . $ maskGlobal#exist. = new existDBcxx . . $ existDB#(g->merNamecxx . . $ maskGlobal#merName., g->merSizecxx . . $ maskGlobal#merSize., existDBnoFlagscxx . . $ existDBnoFlags., 0, ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!); |
| 716 | |
| 717 | if (g->existNamecxx . . $ maskGlobal#existName. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 718 | if (beVerbose) |
| 719 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Save existDB into existName='%s'.\n", g->existNamecxx . . $ maskGlobal#existName.); |
| 720 | g->existcxx . . $ maskGlobal#exist.->saveStatecxx . . $ existDB#saveState(85c52e162fed56f9).(g->existNamecxx . . $ maskGlobal#existName.); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | // Process! |
| 725 | |
| 726 | if (g->FASTQ1cxx . . $ maskGlobal#FASTQ1.) { |
| 727 | sweatShopcxx . . $ sweatShop# *ss = new sweatShopcxx . . $ sweatShop#(fastqLoadercxx . . $ fastqLoader(9f162e79bfc6c74)., maskWorkercxx . . $ maskWorker(49f36ff46ae528d5)., fastqWritercxx . . $ fastqWriter(6c58c5e2437d25a2).); |
| 728 | |
| 729 | ss->setNumberOfWorkerscxx . . $ sweatShop#setNumberOfWorkers(cb2f890c2fdad230).(numWorkers); |
| 730 | |
| 731 | ss->setWorkerBatchSizecxx . . $ sweatShop#setWorkerBatchSize(cb2f890c2fdad230).(1024); |
| 732 | |
| 733 | ss->setLoaderQueueSizecxx . . $ sweatShop#setLoaderQueueSize(cb2f890c2fdad230).(numWorkers * 81920); |
| 734 | ss->setWriterQueueSizecxx . . $ sweatShop#setWriterQueueSize(cb2f890c2fdad230).(numWorkers * 81920); |
| 735 | |
| 736 | ss->runcxx . . $ sweatShop#run(b81e5e1865225ade).(g, beVerbose); |
| 737 | |
| 738 | closeInputcxx . . $ closeInput(496d627add48d26f).(g->FASTQ1cxx . . $ maskGlobal#FASTQ1., g->seq1Namecxx . . $ maskGlobal#seq1Name., g->FASTQ1pipecxx . . $ maskGlobal#FASTQ1pipe.); |
| 739 | closeInputcxx . . $ closeInput(496d627add48d26f).(g->FASTQ2cxx . . $ maskGlobal#FASTQ2., g->seq1Namecxx . . $ maskGlobal#seq1Name., g->FASTQ2pipecxx . . $ maskGlobal#FASTQ2pipe.); |
| 740 | |
| 741 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[0], g->outPrefixcxx . . $ maskGlobal#outPrefix., "clean.1"); |
| 742 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[1], g->outPrefixcxx . . $ maskGlobal#outPrefix., "murky.1"); |
| 743 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[2], g->outPrefixcxx . . $ maskGlobal#outPrefix., "match.1"); |
| 744 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT1cxx . . $ maskGlobal#OUTPUT1.[3], g->outPrefixcxx . . $ maskGlobal#outPrefix., "mixed.1"); |
| 745 | |
| 746 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[0], g->outPrefixcxx . . $ maskGlobal#outPrefix., "clean.2"); |
| 747 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[1], g->outPrefixcxx . . $ maskGlobal#outPrefix., "murky.2"); |
| 748 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[2], g->outPrefixcxx . . $ maskGlobal#outPrefix., "match.2"); |
| 749 | closeOutputcxx . . $ closeOutput(ba717dc1c248a9ca).(g->OUTPUT2cxx . . $ maskGlobal#OUTPUT2.[3], g->outPrefixcxx . . $ maskGlobal#outPrefix., "mixed.2"); |
| 750 | |
| 751 | #define FWcxx . . $ `meryl/kmer-mask.C:751:9`! uint64FMTWcxx . . $ `libutil/util.h:54:10`!(8) |
| 752 | |
| 753 | if (g->FASTQ2cxx . . $ maskGlobal#FASTQ2. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 754 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aClean "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[0][0]); |
| 755 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aMurky "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[1][0]); |
| 756 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aMatch "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[2][0]); |
| 757 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aMixed "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[3][0]); |
| 758 | } else { |
| 759 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " bClean bMurky bMatch bMixed\n"); |
| 760 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aClean "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[0][0], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[0][1], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[0][2], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[0][3]); |
| 761 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aMurky "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[1][0], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[1][1], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[1][2], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[1][3]); |
| 762 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aMatch "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[2][0], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[2][1], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[2][2], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[2][3]); |
| 763 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "aMixed "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!" "FWcxx . . $ `meryl/kmer-mask.C:751:9`!"\n", g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[3][0], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[3][1], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[3][2], g->thresholdCountscxx . . $ maskGlobal#thresholdCounts.[3][3]); |
| 764 | } |
| 765 | |
| 766 | #undef FWcxx . . $ `meryl/kmer-mask.C:751:9`! |
| 767 | |
| 768 | if (g->outputHistogramcxx . . $ maskGlobal#outputHistogram. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 769 | FILE *H = fopen(g->outputHistogramcxx . . $ maskGlobal#outputHistogram., "w"); |
| 770 | |
| 771 | fprintf(H, "# fraction-masked number-of-sequences\n"); |
| 772 | for (uint32cxx . . $ uint32# i=0; i<1001; i++) |
| 773 | if (g->scoreHistogramcxx . . $ maskGlobal#scoreHistogram.[i] > 0) |
| 774 | fprintf(H, "%.4f\t%u\n", i / 1000.0, g->scoreHistogramcxx . . $ maskGlobal#scoreHistogram.[i]); |
| 775 | |
| 776 | fclose(H); |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | delete g->existcxx . . $ maskGlobal#exist.; |
| 781 | delete g; |
| 782 | |
| 783 | exitcxx . . $ exit(44ed87f96534fad7).(0); |
| 784 | } |