Debian Codegraph @

current/align2/BBMapPacBio.java

raw symbols SCIP
1 package align2;
2
3 import java.io.File;
4 import java.util.ArrayList;
5
6 import bloom.BloomFilter;
7 import dna.ChromosomeArray;
8 import dna.Data;
9 import dna.FastaToChromArrays2;
10 import fileIO.ReadWrite;
11 import jgi.CoveragePileup;
12 import shared.Shared;
13 import shared.Timer;
14 import shared.Tools;
15 import stream.FastaReadInputStream;
16 import stream.ReadStreamWriter;
17 import stream.SamLine;
18
19 /**
20 * Based on TestIndex11f
21 *
22 * @author Brian Bushnell
23 * @date Jul 10, 2012
24 *
25 */
26 public final class BBMapPacBio extends AbstractMapper {
27
28
29 public static void main(String[] args){
30 Timer t=new Timer();
31 BBMapPacBio mapper=new BBMapPacBio(args);
32 args=Tools.condenseStrict(args);
33 if(!INDEX_LOADED){mapper.loadIndex();}
34 if(Data.scaffoldPrefixes){mapper.processAmbig2();}
35 mapper.testSpeed(args);
36 ReadWrite.waitForWritingToFinish();
37 t.stop();
38 outstream.println("\nTotal time: \t"+t);
39 clearStatics();
40 }
41
42 public BBMapPacBio(String[] args){
43 super(args);
44 }
45
46 @Override
47 public void setDefaults(){
48 ReadWrite.USE_PIGZ=ReadWrite.USE_UNPIGZ=false;
49 ReadWrite.USE_BGZIP=ReadWrite.USE_UNBGZIP=true;
50 ReadWrite.PREFER_BGZIP=true;
51 FastaToChromArrays2.MID_PADDING=2000;
52 ReadWrite.ZIPLEVEL=2;
53 MAKE_MATCH_STRING=true;
54 keylen=12;
55
56 MINIMUM_ALIGNMENT_SCORE_RATIO=0.46f;
57
58 keyDensity=3.5f;//2.3f;
59 maxKeyDensity=4.5f;//4f;
60 minKeyDensity*=2.5f;//1.8f;
61 maxDesiredKeys=63;
62
63 SLOW_ALIGN_PADDING=8;
64 SLOW_RESCUE_PADDING=8+SLOW_ALIGN_PADDING;
65 TIP_SEARCH_DIST=15;
66
67 MSA_TYPE="MultiStateAligner9PacBio";
68 MAX_SITESCORES_TO_PRINT=100;
69 PRINT_SECONDARY_ALIGNMENTS=false;
70 AbstractIndex.MIN_APPROX_HITS_TO_KEEP=1;
71 Shared.capBufferLen(20);
72 }
73
74 @Override
75 public String[] preparse(String[] args){
76 if(fast){
77 ArrayList<String> list=new ArrayList<String>();
78 list.add("tipsearch="+TIP_SEARCH_DIST/5);
79 // list.add("maxindel=100");
80 // list.add("minhits=2");
81 list.add("bwr=0.16");
82 // list.add("minratio=0.5");
83 // list.add("k=13");
84 list.add("quickmatch=t");
85 list.add("rescuemismatches=15");
86 list.add("rescuedist=800");
87 list.add("maxsites=5");
88 list.add("maxsites2=400");
89
90 BBIndexPacBio.setFractionToExclude(BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE*1.25f);
91
92 for(String s : args){if(s!=null){list.add(s);}}
93 args=list.toArray(new String[list.size()]);
94
95 keyDensity*=0.9f;
96 maxKeyDensity*=0.9f;
97 minKeyDensity*=0.9f;
98 }else if(vslow){
99 ArrayList<String> list=new ArrayList<String>();
100 list.add("tipsearch="+(TIP_SEARCH_DIST*3)/2);
101 list.add("minhits=1");
102 list.add("minratio=0.22");
103 list.add("usequality=f");
104 list.add("rescuemismatches=50");
105 list.add("rescuedist=2500");
106
107 BBIndexPacBio.setFractionToExclude(0);
108
109 for(String s : args){if(s!=null){list.add(s);}}
110 args=list.toArray(new String[list.size()]);
111
112 SLOW_ALIGN_PADDING=SLOW_ALIGN_PADDING*2+8;
113 SLOW_RESCUE_PADDING=SLOW_RESCUE_PADDING*2+2;
114
115 AbstractIndex.SLOW=true;
116 AbstractIndex.VSLOW=true;
117 keyDensity*=2.5f;
118 maxKeyDensity*=2.5f;
119 minKeyDensity*=2.5f;
120 }else if(slow){
121 //TODO: Unfinished
122 ArrayList<String> list=new ArrayList<String>();
123
124 BBIndexPacBio.setFractionToExclude(BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE*0.4f);
125
126 for(String s : args){if(s!=null){list.add(s);}}
127 args=list.toArray(new String[list.size()]);
128
129 AbstractIndex.SLOW=true;
130 keyDensity*=1.2f;
131 maxKeyDensity*=1.2f;
132 minKeyDensity*=1.2f;
133 }
134
135 if(excludeFraction>=0){
136 BBIndexPacBio.setFractionToExclude(excludeFraction);
137 }
138
139 return args;
140 }
141
142 @Override
143 void postparse(String[] args){
144
145 if(MSA.bandwidthRatio>0 && MSA.bandwidthRatio<.2){
146 SLOW_ALIGN_PADDING=Tools.min(SLOW_ALIGN_PADDING, 5);
147 SLOW_RESCUE_PADDING=Tools.min(SLOW_RESCUE_PADDING, 10);
148 }
149
150 if(maxIndel1>-1){
151 TIP_SEARCH_DIST=Tools.min(TIP_SEARCH_DIST, maxIndel1);
152 BBIndexPacBio.MAX_INDEL=maxIndel1;
153 }
154 if(maxIndel2>-1){
155 BBIndexPacBio.MAX_INDEL2=maxIndel2;
156 }
157
158 if(minApproxHits>-1){
159 BBIndexPacBio.MIN_APPROX_HITS_TO_KEEP=minApproxHits;
160 }
161
162 if(expectedSites>-1){
163 BBMapThreadPacBio.setExpectedSites(expectedSites);
164 outstream.println("Set EXPECTED_SITES to "+expectedSites);
165 }
166
167 if(fractionGenomeToExclude>=0){
168 BBIndexPacBio.setFractionToExclude(fractionGenomeToExclude);
169 }
170
171 {
172 final String a=(args.length>0 ? args[0] : null);
173 final String b=(args.length>1 ? args[1] : null);
174 if(in1==null && a!=null && a.indexOf('=')<0 && (a.startsWith("stdin") || new File(a).exists())){in1=a;}
175 if(in2==null && b!=null && b.indexOf('=')<0 && new File(b).exists()){in2=b;}
176 if(ERROR_ON_NO_OUTPUT && !OUTPUT_READS && in1!=null){throw new RuntimeException("Error: no output file, and ERROR_ON_NO_OUTPUT="+ERROR_ON_NO_OUTPUT);}
177 }
178
179 assert(synthReadlen<BBMapThreadPacBio.ALIGN_ROWS);
180
181 if(MSA.bandwidth>0){
182 int halfwidth=MSA.bandwidth/2;
183 TIP_SEARCH_DIST=Tools.min(TIP_SEARCH_DIST, halfwidth/2);
184 BBIndexPacBio.MAX_INDEL=Tools.min(BBIndexPacBio.MAX_INDEL, halfwidth/2);
185 BBIndexPacBio.MAX_INDEL2=Tools.min(BBIndexPacBio.MAX_INDEL2, halfwidth);
186 SLOW_ALIGN_PADDING=Tools.min(SLOW_ALIGN_PADDING, halfwidth/4);
187 SLOW_RESCUE_PADDING=Tools.min(SLOW_RESCUE_PADDING, halfwidth/4);
188 }
189
190 if(PRINT_SECONDARY_ALIGNMENTS){
191 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
192 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
193 }
194
195 if(in1!=null){
196 if(ambigMode==AMBIG_BEST){
197 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
198 if(!PRINT_SECONDARY_ALIGNMENTS){BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=true;}
199 outstream.println("Retaining first best site only for ambiguous mappings.");
200 }else if(ambigMode==AMBIG_ALL){
201 PRINT_SECONDARY_ALIGNMENTS=ReadStreamWriter.OUTPUT_SAM_SECONDARY_ALIGNMENTS=true;
202 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
203 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
204 SamLine.MAKE_NH_TAG=true;
205 ambiguousAll=true;
206 outstream.println("Retaining all best sites for ambiguous mappings.");
207 }else if(ambigMode==AMBIG_RANDOM){
208 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
209 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
210 ambiguousRandom=true;
211 outstream.println("Choosing a site randomly for ambiguous mappings.");
212 }else if(ambigMode==AMBIG_TOSS){
213 REMOVE_DUPLICATE_BEST_ALIGNMENTS=true;
214 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=true;
215 outstream.println("Ambiguously mapped reads will be considered unmapped.");
216 }else{
217 throw new RuntimeException("Unknown ambiguous mapping mode: "+ambigMode);
218 }
219 }
220
221 }
222
223 @Override
224 public void setup(){
225
226 assert(!useRandomReads || maxReads>0 || (in1!=null && in1.equals("sequential"))) : "Please specify number of reads to use.";
227
228 if(minid!=-1){
229 MINIMUM_ALIGNMENT_SCORE_RATIO=MSA.minIdToMinRatio(minid, MSA_TYPE);
230 outstream.println("Set MINIMUM_ALIGNMENT_SCORE_RATIO to "+Tools.format("%.3f",MINIMUM_ALIGNMENT_SCORE_RATIO));
231 }
232
233 if(!setxs){SamLine.MAKE_XS_TAG=(SamLine.INTRON_LIMIT<1000000000);}
234 if(setxs && !setintron){SamLine.INTRON_LIMIT=10;}
235
236 if(outFile==null && outFile2==null && outFileM==null && outFileM2==null && outFileU==null && outFileU2==null
237 && outFileB==null && outFileB2==null && splitterOutputs==null && BBSplitter.streamTable==null){
238 outstream.println("No output file.");
239 OUTPUT_READS=false;
240 }else{
241 OUTPUT_READS=true;
242 if(bamscript!=null){
243 BBSplitter.makeBamScript(bamscript, splitterOutputs, outFile, outFile2, outFileM, outFileM2, outFileU, outFileU2, outFileB, outFileB2);
244 }
245 }
246
247 FastaReadInputStream.MIN_READ_LEN=Tools.max(keylen+2, FastaReadInputStream.MIN_READ_LEN);
248 assert(FastaReadInputStream.settingsOK());
249
250 if(build<0){throw new RuntimeException("Must specify a build number, e.g. build=1");}
251 else{Data.GENOME_BUILD=build;}
252
253 if(blacklist!=null && blacklist.size()>0){
254 Timer t=new Timer();
255 t.start();
256 for(String s : blacklist){
257 Blacklist.addToBlacklist(s);
258 }
259 t.stop();
260 outstream.println("Created blacklist:\t"+t);
261 t.start();
262 }
263
264 if(ziplevel!=-1){ReadWrite.ZIPLEVEL=ziplevel;}
265 if(reference!=null){RefToIndex.makeIndex(reference, build, outstream, keylen);}
266 }
267
268
269 @Override
270 void processAmbig2(){
271 assert(Data.scaffoldPrefixes) : "Only process this block if there are multiple references.";
272 if(BBSplitter.AMBIGUOUS2_MODE==BBSplitter.AMBIGUOUS2_SPLIT){
273 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
274 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
275 outstream.println("Reads that map to multiple references will be written to special output streams.");
276 }else if(BBSplitter.AMBIGUOUS2_MODE==BBSplitter.AMBIGUOUS2_FIRST){
277 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
278 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
279 outstream.println("Reads that map to multiple references will be written to the first reference's stream only.");
280 }else if(BBSplitter.AMBIGUOUS2_MODE==BBSplitter.AMBIGUOUS2_TOSS){
281 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=true;
282 outstream.println("Reads that map to multiple references will be considered unmapped.");
283 }else if(BBSplitter.AMBIGUOUS2_MODE==BBSplitter.AMBIGUOUS2_RANDOM){
284 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
285 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
286 outstream.println("Reads that map to multiple references will be written to a random stream.");
287 }else if(BBSplitter.AMBIGUOUS2_MODE==BBSplitter.AMBIGUOUS2_ALL){
288 REMOVE_DUPLICATE_BEST_ALIGNMENTS=false;
289 BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;
290 outstream.println("Reads that map to multiple references will be written to all relevant output streams.");
291 }else{
292 BBSplitter.AMBIGUOUS2_MODE=BBSplitter.AMBIGUOUS2_FIRST;
293 }
294 }
295
296 @Override
297 void loadIndex(){
298 Timer t=new Timer();
299
300 if(build>-1){
301 Data.setGenome(build);
302 AbstractIndex.MINCHROM=1;
303 AbstractIndex.MAXCHROM=Data.numChroms;
304 if(minChrom<0){minChrom=1;}
305 if(maxChrom<0 || maxChrom>Data.numChroms){maxChrom=Data.numChroms;}
306 outstream.println("Set genome to "+Data.GENOME_BUILD);
307
308 if(RefToIndex.AUTO_CHROMBITS){
309 int maxLength=Tools.max(Data.chromLengths);
310 RefToIndex.chrombits=Integer.numberOfLeadingZeros(maxLength)-1;
311 RefToIndex.chrombits=Tools.min(RefToIndex.chrombits, 16);
312 }
313 if(RefToIndex.chrombits!=-1){
314 BBIndexPacBio.setChromBits(RefToIndex.chrombits);
315 if(verbose_stats>0){outstream.println("Set CHROMBITS to "+RefToIndex.chrombits);}
316 }
317 }
318
319 assert(minChrom>=AbstractIndex.MINCHROM && maxChrom<=AbstractIndex.MAXCHROM) :
320 minChrom+", "+maxChrom+", "+AbstractIndex.MINCHROM+", "+AbstractIndex.MAXCHROM;
321 AbstractIndex.MINCHROM=minChrom;
322 AbstractIndex.MAXCHROM=maxChrom;
323
324 if(targetGenomeSize>0){
325 long bases=Data.numDefinedBases;
326 long x=Tools.max(1, Math.round(0.25f+bases*1d/targetGenomeSize));
327 BBMapThreadPacBio.setExpectedSites((int)x);
328 outstream.println("Set EXPECTED_SITES to "+x);
329 }
330
331 assert(!(PERFECTMODE && SEMIPERFECTMODE));
332 if(PERFECTMODE){setPerfectMode();}
333 if(SEMIPERFECTMODE){setSemiperfectMode();}
334
335 //Optional section for discrete timing of chrom array loading
336 if(SLOW_ALIGN || AbstractIndex.USE_EXTENDED_SCORE || useRandomReads || MAKE_MATCH_STRING){
337 outstream.println();
338 if(RefToIndex.chromlist==null){
339 Data.loadChromosomes(minChrom, maxChrom);
340 }else{
341 assert(RefToIndex.chromlist.size()==maxChrom-minChrom+1) : RefToIndex.chromlist.size();
342 for(ChromosomeArray cha : RefToIndex.chromlist){
343 Data.chromosomePlusMatrix[cha.chromosome]=cha;
344 }
345 }
346 if(Shared.TRIM_RNAME){Data.trimScaffoldNames();}
347 t.stop();
348 outstream.println("Loaded Reference:\t"+t);
349 t.start();
350 }
351 RefToIndex.chromlist=null;
352
353 t.start();
354 BBIndexPacBio.loadIndex(minChrom, maxChrom, keylen, !RefToIndex.NODISK, RefToIndex.NODISK);
355
356 {
357 long len=Data.numDefinedBases;
358 if(len<300000000){
359 BBIndexPacBio.MAX_HITS_REDUCTION2+=1;
360 BBIndexPacBio.MAXIMUM_MAX_HITS_REDUCTION+=1;
361 if(len<30000000){
362 BBIndexPacBio.setFractionToExclude(BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE*0.5f);
363 BBIndexPacBio.MAXIMUM_MAX_HITS_REDUCTION+=1;
364 BBIndexPacBio.HIT_REDUCTION_DIV=Tools.max(BBIndexPacBio.HIT_REDUCTION_DIV-1, 3);
365 }else if(len<100000000){
366 BBIndexPacBio.setFractionToExclude(BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE*0.6f);
367 }else{
368 BBIndexPacBio.setFractionToExclude(BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE*0.75f);
369 }
370 }
371 }
372
373 t.stop();
374 outstream.println("Generated Index:\t"+t);
375 t.start();
376
377 if(!SLOW_ALIGN && !AbstractIndex.USE_EXTENDED_SCORE && !useRandomReads && !MAKE_MATCH_STRING){
378 for(int chrom=minChrom; chrom<=maxChrom; chrom++){
379 Data.unload(chrom, true);
380 }
381 }
382
383 if(ReadWrite.countActiveThreads()>0){
384 ReadWrite.waitForWritingToFinish();
385 t.stop();
386 outstream.println("Finished Writing:\t"+t);
387 t.start();
388 }
389
390 if(coverageBinned!=null || coverageBase!=null || rangeCov!=null || coverageHist!=null || coverageStats!=null || coverageRPKM!=null || normcov!=null || normcovOverall!=null || calcCov){
391 String[] cvargs=("covhist="+coverageHist+"\tcovstats="+coverageStats+"\tbasecov="+coverageBase+"\trangecov="+rangeCov+"\tbincov="+coverageBinned+"\tphyscov="+coveragePhysical+
392 "\t32bit="+cov32bit+"\tnzo="+covNzo+"\ttwocolumn="+covTwocolumn+"\tsecondary="+PRINT_SECONDARY_ALIGNMENTS+"\tcovminscaf="+coverageMinScaf+
393 "\tksb="+covKsb+"\tbinsize="+covBinSize+"\tk="+covK+"\tstartcov="+covStartOnly+"\tstopcov="+covStopOnly+"\tstrandedcov="+covStranded+"\trpkm="+coverageRPKM+
394 "\tnormcov="+normcov+"\tnormcovo="+normcovOverall+(in1==null ? "" : "\tin1="+in1)+(in2==null ? "" : "\tin2="+in2)+
395 (covSetbs ? ("\tbitset="+covBitset+"\tarrays="+covArrays) : "")).split("\t");
396 pileup=new CoveragePileup(cvargs);
397 pileup.createDataStructures();
398 pileup.loadScaffoldsFromIndex(minChrom, maxChrom);
399 }
400
401 if(!forceanalyze && (in1==null || maxReads==0)){return;}
402
403 BBIndexPacBio.analyzeIndex(minChrom, maxChrom, BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE, keylen);
404
405 t.stop();
406 outstream.println("Analyzed Index: \t"+t);
407 t.start();
408
409 if(makeBloomFilter){
410 String serialPath=RefToIndex.bloomLoc(build);
411 File serialFile=new File(serialPath);
412 if(bloomSerial && !RefToIndex.NODISK && serialFile.exists()){
413 bloomFilter=ReadWrite.read(BloomFilter.class, RefToIndex.bloomLoc(build), true);
414 t.stop("Loaded Bloom Filter: ");
415 }else{
416 if(bloomSerial){System.out.println("Could not read "+serialPath+", generating filter from reference.");}
417 bloomFilter=new BloomFilter(true, bloomFilterK, bloomFilterK, 1, bloomFilterHashes, bloomFilterMinHits, true);
418 t.stop("Made Bloom Filter: ");
419 if(bloomSerial && !RefToIndex.NODISK && !RefToIndex.FORCE_READ_ONLY){
420 // && serialFile.canWrite()
421 try {
422 ReadWrite.writeObjectInThread(bloomFilter, serialPath, true);
423 outstream.println("Writing Bloom Filter.");
424 } catch (Throwable e) {
425 e.printStackTrace();
426 outstream.println("Can't Write Bloom Filter.");
427 }
428 }
429 }
430 outstream.println(bloomFilter.filter.toShortString());
431 t.start();
432 }
433 }
434
435 @Override
436 public void testSpeed(String[] args){
437
438 if(in1==null || maxReads==0){
439 outstream.println("No reads to process; quitting.");
440 return;
441 }
442
443 Timer t=new Timer();
444
445 final boolean paired=openStreams(t, args);
446 if(paired){BBIndexPacBio.QUIT_AFTER_TWO_PERFECTS=false;}
447
448 t.start();
449
450 adjustThreadsforMemory(680);
451
452 AbstractMapThread.CALC_STATISTICS=CALC_STATISTICS;
453 AbstractMapThread[] mtts=new AbstractMapThread[Shared.threads()];
454 for(int i=0; i<mtts.length; i++){
455 try {
456 mtts[i]=new BBMapThreadPacBio(cris, keylen,
457 pileup, SLOW_ALIGN, CORRECT_THRESH, minChrom,
458 maxChrom, keyDensity, maxKeyDensity, minKeyDensity, maxDesiredKeys, REMOVE_DUPLICATE_BEST_ALIGNMENTS,
459 SAVE_AMBIGUOUS_XY, MINIMUM_ALIGNMENT_SCORE_RATIO, TRIM_LIST, MAKE_MATCH_STRING, QUICK_MATCH_STRINGS, rosA, rosM, rosU, rosB,
460 SLOW_ALIGN_PADDING, SLOW_RESCUE_PADDING, OUTPUT_MAPPED_ONLY, DONT_OUTPUT_BLACKLISTED_READS, MAX_SITESCORES_TO_PRINT, PRINT_SECONDARY_ALIGNMENTS,
461 REQUIRE_CORRECT_STRANDS_PAIRS, SAME_STRAND_PAIRS, KILL_BAD_PAIRS, rcompMate,
462 PERFECTMODE, SEMIPERFECTMODE, FORBID_SELF_MAPPING, TIP_SEARCH_DIST,
463 ambiguousRandom, ambiguousAll, KFILTER, MIN_IDFILTER, qtrimLeft, qtrimRight, untrim, TRIM_QUALITY, minTrimLength,
464 LOCAL_ALIGN, RESCUE, STRICT_MAX_INDEL, MSA_TYPE, bloomFilter);
465 } catch (Exception e) {
466 e.printStackTrace();
467 abort(mtts, "Aborting due to prior error.");
468 }
469 mtts[i].idmodulo=idmodulo;
470 if(verbose){
471 mtts[i].verbose=verbose;
472 mtts[i].index().verbose=verbose;
473 }
474 }
475
476 cris.start(); //4567
477 outstream.println("Processing reads in "+(paired ? "paired" : "single")+"-ended mode.");
478 outstream.println("Started read stream.");
479
480 /* The threads are started after initialization to prevent resource competition between initialization and mapping */
481 for(int i=0; i<mtts.length; i++){mtts[i].start();}
482 outstream.println("Started "+mtts.length+" mapping thread"+(mtts.length==1 ? "" : "s")+".");
483
484 final int broken=shutDownThreads(mtts, false);
485
486 if(printStats){outstream.println("\n\n ------------------ Results ------------------ ");}
487 closeStreams(cris, rosA, rosM, rosU, rosB);
488 outstream.println();
489 if(printSettings){printSettings(keylen);}
490
491 printOutput(mtts, t, keylen, paired, false, pileup, scafNzo, sortStats, statsOutputFile);
492 if(broken>0 || errorState){throw new RuntimeException("BBMap terminated in an error state; the output may be corrupt.");}
493 }
494
495 @Override
496 void setSemiperfectMode() {
497 assert(SEMIPERFECTMODE);
498 if(SEMIPERFECTMODE){
499 TRIM_LIST=false;
500 keyDensity/=2;
501 maxKeyDensity/=2;
502 minKeyDensity=1.1f;
503 maxDesiredKeys/=2;
504 MINIMUM_ALIGNMENT_SCORE_RATIO=0.45f;
505 BBIndexPacBio.setSemiperfectMode();
506 }
507 }
508
509 @Override
510 void setPerfectMode() {
511 assert(PERFECTMODE);
512 if(PERFECTMODE){
513 TRIM_LIST=false;
514 keyDensity/=2;
515 maxKeyDensity/=2;
516 minKeyDensity=1.1f;
517 maxDesiredKeys/=2;
518 MINIMUM_ALIGNMENT_SCORE_RATIO=1.0f;
519 BBIndexPacBio.setPerfectMode();
520 }
521 }
522
523
524 @Override
525 void printSettings(int k){
526
527 printSettings0(k, BBIndexPacBio.MAX_INDEL, MINIMUM_ALIGNMENT_SCORE_RATIO);
528
529 if(verbose_stats>=2){
530 outstream.println("Key Density: \t"+keyDensity+" ("+minKeyDensity+" ~ "+maxKeyDensity+")");
531 outstream.println("Max keys: \t"+maxDesiredKeys);
532
533 outstream.println("Block Subsections: \t"+BBIndexPacBio.CHROMS_PER_BLOCK);
534 outstream.println("Fraction To Remove: \t"+Tools.format("%.4f", (BBIndexPacBio.REMOVE_FREQUENT_GENOME_FRACTION ? BBIndexPacBio.FRACTION_GENOME_TO_EXCLUDE : 0)));
535 // sysout.println("ADD_SCORE_Z: \t"+IndexPacBio.ADD_SCORE_Z);
536 outstream.println("Hits To Keep: \t"+BBIndexPacBio.MIN_APPROX_HITS_TO_KEEP);
537 }
538
539 if(verbose_stats>=3){
540 outstream.println("Remove Clumpy: \t"+BBIndexPacBio.REMOVE_CLUMPY);
541 if(BBIndexPacBio.REMOVE_CLUMPY){
542 outstream.println("CLUMPY_MAX_DIST: \t"+BBIndexPacBio.CLUMPY_MAX_DIST);
543 outstream.println("CLUMPY_MIN_LENGTH: \t"+BBIndexPacBio.CLUMPY_MIN_LENGTH_INDEX);
544 outstream.println("CLUMPY_FRACTION: \t"+BBIndexPacBio.CLUMPY_FRACTION);
545 }
546 outstream.println("Remove Long Lists: \t"+BBIndexPacBio.TRIM_LONG_HIT_LISTS);
547 if(BBIndexPacBio.TRIM_LONG_HIT_LISTS){
548 outstream.println("HIT_FRACTION_TO_RETAIN:\t"+BBIndexPacBio.HIT_FRACTION_TO_RETAIN);
549 }
550 outstream.println("Trim By Greedy: \t"+BBIndexPacBio.TRIM_BY_GREEDY);
551 outstream.println("Trim By Total Sites: \t"+BBIndexPacBio.TRIM_BY_TOTAL_SITE_COUNT);
552 if(BBIndexPacBio.TRIM_BY_TOTAL_SITE_COUNT){
553 outstream.println("MAX_AVG_SITES: \t"+BBIndexPacBio.MAX_AVERAGE_LIST_TO_SEARCH);
554 outstream.println("MAX_AVG_SITES_2: \t"+BBIndexPacBio.MAX_AVERAGE_LIST_TO_SEARCH2);
555 outstream.println("MAX_SHORTEST_SITE: \t"+BBIndexPacBio.MAX_SHORTEST_LIST_TO_SEARCH);
556 }
557 outstream.println("Index Min Score: \t"+BBIndexPacBio.MIN_SCORE_MULT);
558
559 outstream.println("Dynamic Trim: \t"+BBIndexPacBio.DYNAMICALLY_TRIM_LOW_SCORES);
560 if(BBIndexPacBio.DYNAMICALLY_TRIM_LOW_SCORES){
561 outstream.println("DYNAMIC_SCORE_THRESH: \t"+BBIndexPacBio.DYNAMIC_SCORE_THRESH);
562 }
563 }
564
565 }
566
567 }