Debian Codegraph @

current/aligner/MicroWrapper.java

raw symbols SCIP
1 package aligner;
2
3 import java.io.File;
4 import java.io.PrintStream;
5 import java.util.ArrayList;
6 import java.util.concurrent.locks.ReadWriteLock;
7 import java.util.concurrent.locks.ReentrantReadWriteLock;
8
9 import fileIO.ByteFile;
10 import fileIO.FileFormat;
11 import fileIO.ReadWrite;
12 import jgi.BBDuk;
13 import shared.Parse;
14 import shared.Parser;
15 import shared.PreParser;
16 import shared.Shared;
17 import shared.Timer;
18 import shared.Tools;
19 import stream.ConcurrentReadInputStream;
20 import stream.ConcurrentReadOutputStream;
21 import stream.FASTQ;
22 import stream.FastaReadInputStream;
23 import stream.Read;
24 import stream.ReadStreamByteWriter;
25 import stream.SamLine;
26 import structures.ByteBuilder;
27 import structures.ListNum;
28 import template.Accumulator;
29 import template.ThreadWaiter;
30 import tracker.ReadStats;
31
32 /**
33 * This class does nothing.
34 * It is designed to be easily modified into a program
35 * that processes reads in multiple threads, by
36 * filling in the processReadPair method.
37 *
38 * @author Brian Bushnell
39 * @date November 19, 2015
40 *
41 */
42 public class MicroWrapper implements Accumulator<MicroWrapper.ProcessThread> {
43
44 /*--------------------------------------------------------------*/
45 /*---------------- Initialization ----------------*/
46 /*--------------------------------------------------------------*/
47
48 /**
49 * Code entrance from the command line.
50 * @param args Command line arguments
51 */
52 public static void main(String[] args){
53 //Start a timer immediately upon code entrance.
54 Timer t=new Timer();
55
56 //Create an instance of this class
57 MicroWrapper x=new MicroWrapper(args);
58
59 //Run the object
60 x.process(t);
61
62 //Close the print stream if it was redirected
63 Shared.closeStream(x.outstream);
64 }
65
66 /**
67 * Constructor.
68 * @param args Command line arguments
69 */
70 public MicroWrapper(String[] args){
71
72 {//Preparse block for help, config files, and outstream
73 PreParser pp=new PreParser(args, getClass(), false);
74 args=pp.args;
75 outstream=pp.outstream;
76 }
77
78 //Set shared static variables prior to parsing
79 ReadWrite.USE_PIGZ=ReadWrite.USE_UNPIGZ=true;
80 ReadWrite.setZipThreads(Shared.threads());
81
82 {//Parse the arguments
83 final Parser parser=parse(args);
84 Parser.processQuality();
85
86 maxReads=parser.maxReads;
87 overwrite=ReadStats.overwrite=parser.overwrite;
88 append=ReadStats.append=parser.append;
89 setInterleaved=parser.setInterleaved;
90
91 in1=parser.in1;
92 in2=parser.in2;
93 extin=parser.extin;
94
95 out1=parser.out1;
96 out2=parser.out2;
97 extout=parser.extout;
98 }
99
100 makeReadStats=ReadStats.collectingStats();
101
102 validateParams();
103 doPoundReplacement(); //Replace # with 1 and 2
104 adjustInterleaving(); //Make sure interleaving agrees with number of input and output files
105 fixExtensions(); //Add or remove .gz or .bz2 as needed
106 checkFileExistence(); //Ensure files can be read and written
107 checkStatics(); //Adjust file-related static fields as needed for this program
108
109 //Create output FileFormat objects
110 ffout1=FileFormat.testOutput(out1, FileFormat.SAM, extout, true, overwrite, append, ordered);
111 ffout2=FileFormat.testOutput(out2, FileFormat.SAM, extout, true, overwrite, append, ordered);
112 ffoutu1=FileFormat.testOutput(outu1, FileFormat.SAM, extout, true, overwrite, append, ordered);
113 ffoutu2=FileFormat.testOutput(outu2, FileFormat.SAM, extout, true, overwrite, append, ordered);
114
115 //Create input FileFormat objects
116 ffin1=FileFormat.testInput(in1, FileFormat.FASTQ, extin, true, true);
117 ffin2=FileFormat.testInput(in2, FileFormat.FASTQ, extin, true, true);
118
119 samOutput=(ffout1!=null && ffout1.samOrBam()) || (ffoutu1!=null && ffoutu1.samOrBam());
120 if(samOutput) {ReadStreamByteWriter.USE_ATTACHED_SAMLINE=true;}
121 fixK();
122 ref=SideChannel3.fixRefPath(ref);
123 minIdentity1=SideChannel3.fixID(minIdentity1);
124 minIdentity2=SideChannel3.fixID(minIdentity2);
125 assert(k1>0);
126
127 final Read r=MicroIndex3.loadRef(ref, samOutput);
128 index1=new MicroIndex3(k1, mm1, r);
129 index2=(k2<1 ? null : new MicroIndex3(k2, mm1, r));
130 }
131
132 void fixK() {
133 if(k1<k2) {
134 int temp=k1;
135 k1=k2;
136 k2=temp;
137 }
138 }
139
140 /*--------------------------------------------------------------*/
141 /*---------------- Initialization Helpers ----------------*/
142 /*--------------------------------------------------------------*/
143
144 /** Parse arguments from the command line */
145 private Parser parse(String[] args){
146
147 //Create a parser object
148 Parser parser=new Parser();
149
150 //Set any necessary Parser defaults here
151 //parser.foo=bar;
152
153 //Parse each argument
154 for(int i=0; i<args.length; i++){
155 String arg=args[i];
156
157 //Break arguments into their constituent parts, in the form of "a=b"
158 String[] split=arg.split("=");
159 String a=split[0].toLowerCase();
160 String b=split.length>1 ? split[1] : null;
161 if(b!=null && b.equalsIgnoreCase("null")){b=null;}
162
163 if(a.equals("verbose")){
164 verbose=Parse.parseBoolean(b);
165 }else if(a.equals("ordered")){
166 ordered=Parse.parseBoolean(b);
167 }else if(a.equals("mappedonly")){
168 mappedOnly=Parse.parseBoolean(b);
169 }
170
171 else if(a.equals("outu")){
172 outu1=b;
173 }else if(a.equals("ref")){
174 ref=b;
175 }else if(a.equals("k") || a.equals("k1") || a.equals("kbig")){
176 k1=Integer.parseInt(b);
177 }else if(a.equals("k2") || a.equals("ksmall")){
178 k2=Integer.parseInt(b);
179 }else if(a.equals("minid") || a.equals("minid1")){
180 minIdentity1=Float.parseFloat(b);
181 }else if(a.equals("minid2")){
182 minIdentity2=Float.parseFloat(b);
183 }else if(a.equals("mm")){
184 mm1=mm2=Integer.parseInt(b);
185 }else if(a.equals("mm1")){
186 mm1=Integer.parseInt(b);
187 }else if(a.equals("mm2")){
188 mm2=Integer.parseInt(b);
189 }
190
191 else if(a.equals("parse_flag_goes_here")){
192 long fake_variable=Parse.parseKMG(b);
193 //Set a variable here
194 }else if(parser.parse(arg, a, b)){//Parse standard flags in the parser
195 //do nothing
196 }else{
197 outstream.println("Unknown parameter "+args[i]);
198 assert(false) : "Unknown parameter "+args[i];
199 }
200 }
201
202 return parser;
203 }
204
205 /** Replace # with 1 and 2 in headers */
206 private void doPoundReplacement(){
207 //Do input file # replacement
208 if(in1!=null && in2==null && in1.indexOf('#')>-1 && !new File(in1).exists()){
209 in2=in1.replace("#", "2");
210 in1=in1.replace("#", "1");
211 }
212
213 //Do output file # replacement
214 if(out1!=null && out2==null && out1.indexOf('#')>-1){
215 out2=out1.replace("#", "2");
216 out1=out1.replace("#", "1");
217 }
218
219 //Do output file # replacement
220 if(outu1!=null && outu2==null && outu1.indexOf('#')>-1){
221 outu2=outu1.replace("#", "2");
222 outu1=outu1.replace("#", "1");
223 }
224
225 //Ensure there is an input file
226 if(in1==null){throw new RuntimeException("Error - at least one input file is required.");}
227
228 //Ensure out2 is not set without out1
229 if(out1==null && out2!=null){throw new RuntimeException("Error - cannot define out2 without defining out1.");}
230 }
231
232 /** Add or remove .gz or .bz2 as needed */
233 private void fixExtensions(){
234 in1=Tools.fixExtension(in1);
235 in2=Tools.fixExtension(in2);
236 }
237
238 /** Ensure files can be read and written */
239 private void checkFileExistence(){
240 //Ensure output files can be written
241 if(!Tools.testOutputFiles(overwrite, append, false, out1, out2)){
242 outstream.println((out1==null)+", "+(out2==null)+", "+out1+", "+out2);
243 throw new RuntimeException("\n\noverwrite="+overwrite+"; Can't write to output files "+out1+", "+out2+"\n");
244 }
245
246 //Ensure input files can be read
247 if(!Tools.testInputFiles(false, true, in1, in2)){
248 throw new RuntimeException("\nCan't read some input files.\n");
249 }
250
251 //Ensure that no file was specified multiple times
252 if(!Tools.testForDuplicateFiles(true, in1, in2, out1, out2)){
253 throw new RuntimeException("\nSome file names were specified multiple times.\n");
254 }
255 }
256
257 /** Make sure interleaving agrees with number of input and output files */
258 private void adjustInterleaving(){
259 //Adjust interleaved detection based on the number of input files
260 if(in2!=null){
261 if(FASTQ.FORCE_INTERLEAVED){outstream.println("Reset INTERLEAVED to false because paired input files were specified.");}
262 FASTQ.FORCE_INTERLEAVED=FASTQ.TEST_INTERLEAVED=false;
263 }
264
265 //Adjust interleaved settings based on number of output files
266 if(!setInterleaved){
267 assert(in1!=null && (out1!=null || out2==null)) : "\nin1="+in1+"\nin2="+in2+"\nout1="+out1+"\nout2="+out2+"\n";
268 if(in2!=null){ //If there are 2 input streams.
269 FASTQ.FORCE_INTERLEAVED=FASTQ.TEST_INTERLEAVED=false;
270 outstream.println("Set INTERLEAVED to "+FASTQ.FORCE_INTERLEAVED);
271 }else{ //There is one input stream.
272 if(out2!=null){
273 FASTQ.FORCE_INTERLEAVED=true;
274 FASTQ.TEST_INTERLEAVED=false;
275 outstream.println("Set INTERLEAVED to "+FASTQ.FORCE_INTERLEAVED);
276 }
277 }
278 }
279 }
280
281 /** Adjust file-related static fields as needed for this program */
282 private static void checkStatics(){
283 //Adjust the number of threads for input file reading
284 if(!ByteFile.FORCE_MODE_BF1 && !ByteFile.FORCE_MODE_BF2 && Shared.threads()>2){
285 ByteFile.FORCE_MODE_BF2=true;
286 }
287
288 assert(FastaReadInputStream.settingsOK());
289 }
290
291 /** Ensure parameter ranges are within bounds and required parameters are set */
292 private boolean validateParams(){
293 // assert(minfoo>0 && minfoo<=maxfoo) : minfoo+", "+maxfoo;
294 // assert(false) : "TODO";
295 return true;
296 }
297
298 /*--------------------------------------------------------------*/
299 /*---------------- Outer Methods ----------------*/
300 /*--------------------------------------------------------------*/
301
302 /** Create read streams and process all data */
303 void process(Timer t){
304
305 //Turn off read validation in the input threads to increase speed
306 final boolean vic=Read.VALIDATE_IN_CONSTRUCTOR;
307 Read.VALIDATE_IN_CONSTRUCTOR=Shared.threads()<4;
308
309 //Create a read input stream
310 final ConcurrentReadInputStream cris=makeCris();
311
312 //Optionally create a read output stream
313 final ConcurrentReadOutputStream ros=makeCros(ffout1, ffout2, cris.paired());
314 final ConcurrentReadOutputStream rosu=makeCros(ffoutu1, ffoutu2, cris.paired());
315
316 //Reset counters
317 readsProcessed=readsOut=0;
318 basesProcessed=basesOut=0;
319
320 //Process the reads in separate threads
321 spawnThreads(cris, ros, rosu);
322
323 if(verbose){outstream.println("Finished; closing streams.");}
324
325 //Write anything that was accumulated by ReadStats
326 errorState|=ReadStats.writeAll();
327 //Close the read streams
328 errorState|=ReadWrite.closeStreams(cris, ros, rosu);
329
330 //Reset read validation
331 Read.VALIDATE_IN_CONSTRUCTOR=vic;
332
333 //Report timing and results
334 t.stop();
335 outstream.println(Tools.timeReadsBasesProcessed(t, readsProcessed, basesProcessed, 8));
336 outstream.println(Tools.readsBasesOut(readsProcessed, basesProcessed, readsOut, basesOut, 8, false));
337 outstream.println(stats(readsProcessed, basesProcessed));
338
339 //Throw an exception of there was an error in a thread
340 if(errorState){
341 throw new RuntimeException(getClass().getName()+" terminated in an error state; the output may be corrupt.");
342 }
343 }
344
345 private ConcurrentReadInputStream makeCris(){
346 ConcurrentReadInputStream cris=ConcurrentReadInputStream.getReadInputStream(maxReads, true, ffin1, ffin2);
347 cris.start(); //Start the stream
348 if(verbose){outstream.println("Started cris");}
349 boolean paired=cris.paired();
350 if(!ffin1.samOrBam()){outstream.println("Input is being processed as "+(paired ? "paired" : "unpaired"));}
351 return cris;
352 }
353
354 private ConcurrentReadOutputStream makeCros(FileFormat ff1, FileFormat ff2, boolean pairedInput){
355 if(ff1==null){return null;}
356
357 //Select output buffer size based on whether it needs to be ordered
358 final int buff=(ordered ? Tools.mid(16, 128, (Shared.threads()*2)/3) : 8);
359
360 // //Notify user of output mode
361 // if(pairedInput && out2==null && (in1!=null && !ffin1.samOrBam() && !ff1.samOrBam())){
362 // outstream.println("Writing interleaved.");
363 // }
364
365 final ConcurrentReadOutputStream ros=
366 ConcurrentReadOutputStream.getStream(ff1, ff2, null, null, buff, null, false);
367 ros.start(); //Start the stream
368 return ros;
369 }
370
371 /*--------------------------------------------------------------*/
372 /*---------------- Thread Management ----------------*/
373 /*--------------------------------------------------------------*/
374
375 /** Spawn process threads */
376 private void spawnThreads(final ConcurrentReadInputStream cris,
377 final ConcurrentReadOutputStream ros, final ConcurrentReadOutputStream rosu){
378
379 //Do anything necessary prior to processing
380
381 //Determine how many threads may be used
382 final int threads=Shared.threads();
383
384 //Fill a list with ProcessThreads
385 ArrayList<ProcessThread> alpt=new ArrayList<ProcessThread>(threads);
386 for(int i=0; i<threads; i++){
387 alpt.add(new ProcessThread(cris, ros, rosu, i));
388 }
389
390 //Start the threads and wait for them to finish
391 boolean success=ThreadWaiter.startAndWait(alpt, this);
392 errorState&=!success;
393
394 //Do anything necessary after processing
395
396 }
397
398 @Override
399 public final void accumulate(ProcessThread pt){
400 synchronized(pt) {
401 readsProcessed+=pt.readsProcessedT;
402 basesProcessed+=pt.basesProcessedT;
403
404 readsOut+=pt.readsOutT;
405 basesOut+=pt.basesOutT;
406
407 readsMapped+=pt.readsMappedT;
408 basesMapped+=pt.basesMappedT;
409
410 identitySum+=pt.identitySumT;
411 errorState|=(!pt.success);
412 }
413 }
414
415 @Override
416 public final boolean success(){return !errorState;}
417
418 /*--------------------------------------------------------------*/
419 /*---------------- Inner Methods ----------------*/
420 /*--------------------------------------------------------------*/
421
422 public String stats(long readsIn, long basesIn) {
423 long ro=readsOut, ri=readsIn;
424 long bo=basesOut, bi=basesIn;
425 long rm=readsMapped, bm=basesMapped;
426 double idsum=identitySum;
427 ByteBuilder bb=new ByteBuilder();
428 bb.append("Aligned Reads: \t"+rm+" \t"+BBDuk.toPercent(rm, ri)).nl();
429 bb.append("Aligned Bases: \t"+bm+" \t"+BBDuk.toPercent(bm, bi)).nl();
430 bb.append("Avg Identity: \t"+Tools.format("%.4f%%", idsum*100.0/(rm)));
431 return bb.toString();
432 }
433
434 /*--------------------------------------------------------------*/
435 /*---------------- Inner Classes ----------------*/
436 /*--------------------------------------------------------------*/
437
438 /** This class is static to prevent accidental writing to shared variables.
439 * It is safe to remove the static modifier. */
440 class ProcessThread extends Thread {
441
442 //Constructor
443 ProcessThread(final ConcurrentReadInputStream cris_, final ConcurrentReadOutputStream ros_,
444 final ConcurrentReadOutputStream rosu_, final int tid_){
445 cris=cris_;
446 ros=ros_;
447 rosu=rosu_;
448 tid=tid_;
449 readstats=makeReadStats ? new ReadStats() : null;
450 mapper1=new MicroAligner3(index1, minIdentity1, false);
451 mapper2=(k2<1 ? null : new MicroAligner3(index2, minIdentity2, false));
452 }
453
454 //Called by start()
455 @Override
456 public void run(){
457 //Do anything necessary prior to processing
458
459 //Process the reads
460 processInner();
461
462 //Do anything necessary after processing
463
464 //Indicate successful exit status
465 success=true;
466 }
467
468 /** Iterate through the reads */
469 void processInner(){
470
471 //Grab the first ListNum of reads
472 ListNum<Read> ln=cris.nextList();
473
474 //Check to ensure pairing is as expected
475 if(ln!=null && !ln.isEmpty()){
476 Read r=ln.get(0);
477 // assert(ffin1.samOrBam() || (r.mate!=null)==cris.paired()); //Disabled due to non-static access
478 }
479
480 //As long as there is a nonempty read list...
481 while(ln!=null && ln.size()>0){
482 // if(verbose){outstream.println("Fetched "+reads.size()+" reads.");} //Disabled due to non-static access
483
484 processList(ln);
485
486 //Notify the input stream that the list was used
487 cris.returnList(ln);
488 // if(verbose){outstream.println("Returned a list.");} //Disabled due to non-static access
489
490 //Fetch a new list
491 ln=cris.nextList();
492 }
493
494 //Notify the input stream that the final list was used
495 if(ln!=null){
496 cris.returnList(ln.id, ln.list==null || ln.list.isEmpty());
497 }
498 }
499
500 void processList(ListNum<Read> ln){
501
502 //Grab the actual read list from the ListNum
503 final ArrayList<Read> reads=ln.list;
504 final ArrayList<Read> ulist=new ArrayList<Read>(ln.size());
505
506 //Loop through each read in the list
507 for(int idx=0; idx<reads.size(); idx++){
508 final Read r1=reads.get(idx);
509 final Read r2=r1.mate;
510
511 //Validate reads in worker threads
512 if(!r1.validated()){r1.validate(true);}
513 if(r2!=null && !r2.validated()){r2.validate(true);}
514
515 //Track the initial length for statistics
516 final int initialLength1=r1.length();
517 final int initialLength2=r1.mateLength();
518
519 //Increment counters
520 readsProcessedT+=r1.pairCount();
521 basesProcessedT+=initialLength1+initialLength2;
522
523 {
524 //Reads are processed in this block.
525 boolean mapped=processReadPair(r1, r2);
526
527
528 if(mapped || !mappedOnly){
529 readsOutT+=r1.pairCount();
530 basesOutT+=r1.pairLength();
531 }
532 if(!mapped) {
533 ulist.add(r1);
534 if(mappedOnly) {reads.set(idx, null);}
535 }
536
537 boolean output=(!mapped && rosu!=null) || (ros!=null && (mapped || !mappedOnly));
538 if(samOutput && output) {
539 r1.samline=(r1.samline!=null ? r1.samline : new SamLine(r1, 0));
540 if(r2!=null) {r2.samline=(r2.samline!=null ? r2.samline : new SamLine(r2, 1));}
541 }
542 }
543 }
544
545 //Output reads to the output stream
546 if(ros!=null){ros.add(reads, ln.id);}
547 if(rosu!=null){rosu.add(ulist, ln.id);}
548 }
549
550 /**
551 * Process a read or a read pair.
552 * @param r1 Read 1
553 * @param r2 Read 2 (may be null)
554 * @return True if the reads should be kept, false if they should be discarded.
555 */
556 boolean processReadPair(final Read r1, final Read r2){
557
558 boolean mapped=map(r1, r2);
559
560 if(readstats!=null){
561 readstats.addToHistograms(r1);
562 }
563 return mapped;
564 }
565 /*--------------------------------------------------------------*/
566
567 public boolean map(Read r1, Read r2) {
568 float id1=mapper1.map(r1);
569 float id2=mapper1.map(r2);
570 if(id1+id2<=0) {return false;}//Common case
571
572 if(r2!=null) {
573 if(mapper2!=null) {
574 if(r1.mapped() && !r2.mapped()) {id2=mapper2.map(r2);}
575 else if(r2.mapped() && !r1.mapped()) {id1=mapper2.map(r1);}
576 }
577 boolean properPair=(r1.mapped() && r2.mapped() && r1.chrom==r2.chrom &&
578 r1.strand()!=r2.strand() && Tools.absdif(r1.start, r2.start)<=1000);
579 r1.setPaired(properPair);
580 r2.setPaired(properPair);
581 }
582
583 if(r1.mapped()) {
584 readsMappedT++;
585 basesMappedT+=r1.length();
586 identitySumT+=id1;
587 }else {id1=0;}
588
589 if(r2!=null && r2.mapped()) {
590 readsMappedT++;
591 basesMappedT+=r2.length();
592 identitySumT+=id2;
593 }else {id2=0;}
594
595 return id1>0 || id2>0;
596 }
597
598 /** Number of reads processed by this thread */
599 protected long readsProcessedT=0;
600 /** Number of bases processed by this thread */
601 protected long basesProcessedT=0;
602
603 /** Number of reads retained by this thread */
604 protected long readsOutT=0;
605 /** Number of bases retained by this thread */
606 protected long basesOutT=0;
607
608 /** Number of reads mapped by this thread */
609 protected long readsMappedT=0;
610 /** Number of bases mapped by this thread */
611 protected long basesMappedT=0;
612
613 protected double identitySumT=0;
614
615 /** True only if this thread has completed successfully */
616 boolean success=false;
617
618 final ReadStats readstats;
619 final MicroAligner3 mapper1;
620 final MicroAligner3 mapper2;
621
622 /** Shared input stream */
623 private final ConcurrentReadInputStream cris;
624 /** Shared output stream */
625 private final ConcurrentReadOutputStream ros;
626 /** Shared unmapped output stream */
627 private final ConcurrentReadOutputStream rosu;
628 /** Thread ID */
629 final int tid;
630 }
631
632 /*--------------------------------------------------------------*/
633 /*---------------- Fields ----------------*/
634 /*--------------------------------------------------------------*/
635
636 /** Primary input file path */
637 private String in1=null;
638 /** Secondary input file path */
639 private String in2=null;
640
641 /** Primary output file path */
642 private String out1=null;
643 /** Secondary output file path */
644 private String out2=null;
645
646 /** Primary output file path */
647 private String outu1=null;
648 /** Secondary output file path */
649 private String outu2=null;
650
651 /** Override input file extension */
652 private String extin=null;
653 /** Override output file extension */
654 private String extout=null;
655
656 /** Whether interleaved was explicitly set. */
657 private boolean setInterleaved=false;
658
659 /*--------------------------------------------------------------*/
660
661 /** Number of reads processed */
662 protected long readsProcessed=0;
663 /** Number of bases processed */
664 protected long basesProcessed=0;
665
666 /** Number of reads retained */
667 protected long readsOut=0;
668 /** Number of bases retained */
669 protected long basesOut=0;
670
671 /** Number of reads retained */
672 protected long readsMapped=0;
673 /** Number of bases retained */
674 protected long basesMapped=0;
675
676 protected double identitySum=0;
677
678 /** Quit after processing this many input reads; -1 means no limit */
679 private long maxReads=-1;
680
681 /*--------------------------------------------------------------*/
682
683 public int k1=17;
684 public int k2=13;
685 public float minIdentity1=0.66f;
686 public float minIdentity2=0.56f;
687 public int mm1=1;
688 public int mm2=1;
689 public final MicroIndex3 index1;
690 public final MicroIndex3 index2;
691
692 public String ref;
693 boolean mappedOnly=false;
694 final boolean makeReadStats;
695 final boolean samOutput;
696
697 /*--------------------------------------------------------------*/
698 /*---------------- Statics ----------------*/
699 /*--------------------------------------------------------------*/
700
701 public static boolean TRACK_STATS=true;
702
703 /*--------------------------------------------------------------*/
704 /*---------------- Final Fields ----------------*/
705 /*--------------------------------------------------------------*/
706
707 /** Primary input file */
708 private final FileFormat ffin1;
709 /** Secondary input file */
710 private final FileFormat ffin2;
711
712 /** Primary output file */
713 private final FileFormat ffout1;
714 /** Secondary output file */
715 private final FileFormat ffout2;
716
717 /** Primary output file */
718 private final FileFormat ffoutu1;
719 /** Secondary output file */
720 private final FileFormat ffoutu2;
721
722 @Override
723 public final ReadWriteLock rwlock() {return rwlock;}
724 private final ReadWriteLock rwlock=new ReentrantReadWriteLock();
725
726 /*--------------------------------------------------------------*/
727 /*---------------- Common Fields ----------------*/
728 /*--------------------------------------------------------------*/
729
730 /** Print status messages to this output stream */
731 private PrintStream outstream=System.err;
732 /** Print verbose messages */
733 public static boolean verbose=false;
734 /** True if an error was encountered */
735 public boolean errorState=false;
736 /** Overwrite existing output files */
737 private boolean overwrite=true;
738 /** Append to existing output files */
739 private boolean append=false;
740 /** Reads are output in input order */
741 private boolean ordered=false;
742
743 }