| 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 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public class MicroWrapper implements Accumulator<MicroWrapper.ProcessThread> { |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public static void main(String[] args){ |
| 53 |
|
| 54 |
Timer t=new Timer(); |
| 55 |
|
| 56 |
|
| 57 |
MicroWrapper x=new MicroWrapper(args); |
| 58 |
|
| 59 |
|
| 60 |
x.process(t); |
| 61 |
|
| 62 |
|
| 63 |
Shared.closeStream(x.outstream); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public MicroWrapper(String[] args){ |
| 71 |
|
| 72 |
{ |
| 73 |
PreParser pp=new PreParser(args, getClass(), false); |
| 74 |
args=pp.args; |
| 75 |
outstream=pp.outstream; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
ReadWrite.USE_PIGZ=ReadWrite.USE_UNPIGZ=true; |
| 80 |
ReadWrite.setZipThreads(Shared.threads()); |
| 81 |
|
| 82 |
{ |
| 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(); |
| 104 |
adjustInterleaving(); |
| 105 |
fixExtensions(); |
| 106 |
checkFileExistence(); |
| 107 |
checkStatics(); |
| 108 |
|
| 109 |
|
| 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 |
|
| 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 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
private Parser parse(String[] args){ |
| 146 |
|
| 147 |
|
| 148 |
Parser parser=new Parser(); |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
for(int i=0; i<args.length; i++){ |
| 155 |
String arg=args[i]; |
| 156 |
|
| 157 |
|
| 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 |
|
| 194 |
}else if(parser.parse(arg, a, b)){ |
| 195 |
|
| 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 |
|
| 206 |
private void doPoundReplacement(){ |
| 207 |
|
| 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 |
|
| 214 |
if(out1!=null && out2==null && out1.indexOf('#')>-1){ |
| 215 |
out2=out1.replace("#", "2"); |
| 216 |
out1=out1.replace("#", "1"); |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
if(outu1!=null && outu2==null && outu1.indexOf('#')>-1){ |
| 221 |
outu2=outu1.replace("#", "2"); |
| 222 |
outu1=outu1.replace("#", "1"); |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
if(in1==null){throw new RuntimeException("Error - at least one input file is required.");} |
| 227 |
|
| 228 |
|
| 229 |
if(out1==null && out2!=null){throw new RuntimeException("Error - cannot define out2 without defining out1.");} |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
private void fixExtensions(){ |
| 234 |
in1=Tools.fixExtension(in1); |
| 235 |
in2=Tools.fixExtension(in2); |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
private void checkFileExistence(){ |
| 240 |
|
| 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 |
|
| 247 |
if(!Tools.testInputFiles(false, true, in1, in2)){ |
| 248 |
throw new RuntimeException("\nCan't read some input files.\n"); |
| 249 |
} |
| 250 |
|
| 251 |
|
| 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 |
|
| 258 |
private void adjustInterleaving(){ |
| 259 |
|
| 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 |
|
| 266 |
if(!setInterleaved){ |
| 267 |
assert(in1!=null && (out1!=null || out2==null)) : "\nin1="+in1+"\nin2="+in2+"\nout1="+out1+"\nout2="+out2+"\n"; |
| 268 |
if(in2!=null){ |
| 269 |
FASTQ.FORCE_INTERLEAVED=FASTQ.TEST_INTERLEAVED=false; |
| 270 |
outstream.println("Set INTERLEAVED to "+FASTQ.FORCE_INTERLEAVED); |
| 271 |
}else{ |
| 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 |
|
| 282 |
private static void checkStatics(){ |
| 283 |
|
| 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 |
|
| 292 |
private boolean validateParams(){ |
| 293 |
|
| 294 |
|
| 295 |
return true; |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
void process(Timer t){ |
| 304 |
|
| 305 |
|
| 306 |
final boolean vic=Read.VALIDATE_IN_CONSTRUCTOR; |
| 307 |
Read.VALIDATE_IN_CONSTRUCTOR=Shared.threads()<4; |
| 308 |
|
| 309 |
|
| 310 |
final ConcurrentReadInputStream cris=makeCris(); |
| 311 |
|
| 312 |
|
| 313 |
final ConcurrentReadOutputStream ros=makeCros(ffout1, ffout2, cris.paired()); |
| 314 |
final ConcurrentReadOutputStream rosu=makeCros(ffoutu1, ffoutu2, cris.paired()); |
| 315 |
|
| 316 |
|
| 317 |
readsProcessed=readsOut=0; |
| 318 |
basesProcessed=basesOut=0; |
| 319 |
|
| 320 |
|
| 321 |
spawnThreads(cris, ros, rosu); |
| 322 |
|
| 323 |
if(verbose){outstream.println("Finished; closing streams.");} |
| 324 |
|
| 325 |
|
| 326 |
errorState|=ReadStats.writeAll(); |
| 327 |
|
| 328 |
errorState|=ReadWrite.closeStreams(cris, ros, rosu); |
| 329 |
|
| 330 |
|
| 331 |
Read.VALIDATE_IN_CONSTRUCTOR=vic; |
| 332 |
|
| 333 |
|
| 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 |
|
| 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(); |
| 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 |
|
| 358 |
final int buff=(ordered ? Tools.mid(16, 128, (Shared.threads()*2)/3) : 8); |
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
final ConcurrentReadOutputStream ros= |
| 366 |
ConcurrentReadOutputStream.getStream(ff1, ff2, null, null, buff, null, false); |
| 367 |
ros.start(); |
| 368 |
return ros; |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
private void spawnThreads(final ConcurrentReadInputStream cris, |
| 377 |
final ConcurrentReadOutputStream ros, final ConcurrentReadOutputStream rosu){ |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
final int threads=Shared.threads(); |
| 383 |
|
| 384 |
|
| 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 |
|
| 391 |
boolean success=ThreadWaiter.startAndWait(alpt, this); |
| 392 |
errorState&=!success; |
| 393 |
|
| 394 |
|
| 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 |
|
| 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 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
class ProcessThread extends Thread { |
| 441 |
|
| 442 |
|
| 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 |
|
| 455 |
@Override |
| 456 |
public void run(){ |
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
processInner(); |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
success=true; |
| 466 |
} |
| 467 |
|
| 468 |
|
| 469 |
void processInner(){ |
| 470 |
|
| 471 |
|
| 472 |
ListNum<Read> ln=cris.nextList(); |
| 473 |
|
| 474 |
|
| 475 |
if(ln!=null && !ln.isEmpty()){ |
| 476 |
Read r=ln.get(0); |
| 477 |
|
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
while(ln!=null && ln.size()>0){ |
| 482 |
|
| 483 |
|
| 484 |
processList(ln); |
| 485 |
|
| 486 |
|
| 487 |
cris.returnList(ln); |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
ln=cris.nextList(); |
| 492 |
} |
| 493 |
|
| 494 |
|
| 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 |
|
| 503 |
final ArrayList<Read> reads=ln.list; |
| 504 |
final ArrayList<Read> ulist=new ArrayList<Read>(ln.size()); |
| 505 |
|
| 506 |
|
| 507 |
for(int idx=0; idx<reads.size(); idx++){ |
| 508 |
final Read r1=reads.get(idx); |
| 509 |
final Read r2=r1.mate; |
| 510 |
|
| 511 |
|
| 512 |
if(!r1.validated()){r1.validate(true);} |
| 513 |
if(r2!=null && !r2.validated()){r2.validate(true);} |
| 514 |
|
| 515 |
|
| 516 |
final int initialLength1=r1.length(); |
| 517 |
final int initialLength2=r1.mateLength(); |
| 518 |
|
| 519 |
|
| 520 |
readsProcessedT+=r1.pairCount(); |
| 521 |
basesProcessedT+=initialLength1+initialLength2; |
| 522 |
|
| 523 |
{ |
| 524 |
|
| 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 |
|
| 546 |
if(ros!=null){ros.add(reads, ln.id);} |
| 547 |
if(rosu!=null){rosu.add(ulist, ln.id);} |
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 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;} |
| 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 |
|
| 599 |
protected long readsProcessedT=0; |
| 600 |
|
| 601 |
protected long basesProcessedT=0; |
| 602 |
|
| 603 |
|
| 604 |
protected long readsOutT=0; |
| 605 |
|
| 606 |
protected long basesOutT=0; |
| 607 |
|
| 608 |
|
| 609 |
protected long readsMappedT=0; |
| 610 |
|
| 611 |
protected long basesMappedT=0; |
| 612 |
|
| 613 |
protected double identitySumT=0; |
| 614 |
|
| 615 |
|
| 616 |
boolean success=false; |
| 617 |
|
| 618 |
final ReadStats readstats; |
| 619 |
final MicroAligner3 mapper1; |
| 620 |
final MicroAligner3 mapper2; |
| 621 |
|
| 622 |
|
| 623 |
private final ConcurrentReadInputStream cris; |
| 624 |
|
| 625 |
private final ConcurrentReadOutputStream ros; |
| 626 |
|
| 627 |
private final ConcurrentReadOutputStream rosu; |
| 628 |
|
| 629 |
final int tid; |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
private String in1=null; |
| 638 |
|
| 639 |
private String in2=null; |
| 640 |
|
| 641 |
|
| 642 |
private String out1=null; |
| 643 |
|
| 644 |
private String out2=null; |
| 645 |
|
| 646 |
|
| 647 |
private String outu1=null; |
| 648 |
|
| 649 |
private String outu2=null; |
| 650 |
|
| 651 |
|
| 652 |
private String extin=null; |
| 653 |
|
| 654 |
private String extout=null; |
| 655 |
|
| 656 |
|
| 657 |
private boolean setInterleaved=false; |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
protected long readsProcessed=0; |
| 663 |
|
| 664 |
protected long basesProcessed=0; |
| 665 |
|
| 666 |
|
| 667 |
protected long readsOut=0; |
| 668 |
|
| 669 |
protected long basesOut=0; |
| 670 |
|
| 671 |
|
| 672 |
protected long readsMapped=0; |
| 673 |
|
| 674 |
protected long basesMapped=0; |
| 675 |
|
| 676 |
protected double identitySum=0; |
| 677 |
|
| 678 |
|
| 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 |
|
| 699 |
|
| 700 |
|
| 701 |
public static boolean TRACK_STATS=true; |
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
private final FileFormat ffin1; |
| 709 |
|
| 710 |
private final FileFormat ffin2; |
| 711 |
|
| 712 |
|
| 713 |
private final FileFormat ffout1; |
| 714 |
|
| 715 |
private final FileFormat ffout2; |
| 716 |
|
| 717 |
|
| 718 |
private final FileFormat ffoutu1; |
| 719 |
|
| 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 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
private PrintStream outstream=System.err; |
| 732 |
|
| 733 |
public static boolean verbose=false; |
| 734 |
|
| 735 |
public boolean errorState=false; |
| 736 |
|
| 737 |
private boolean overwrite=true; |
| 738 |
|
| 739 |
private boolean append=false; |
| 740 |
|
| 741 |
private boolean ordered=false; |
| 742 |
|
| 743 |
} |