| 1 |
package pacbio; |
| 2 |
|
| 3 |
import java.util.ArrayList; |
| 4 |
|
| 5 |
import align2.MultiStateAligner9PacBio; |
| 6 |
import aligner.MultiStateAligner9PacBioAdapter; |
| 7 |
import dna.AminoAcid; |
| 8 |
import dna.Data; |
| 9 |
import fileIO.FileFormat; |
| 10 |
import fileIO.ReadWrite; |
| 11 |
import shared.KillSwitch; |
| 12 |
import shared.Parse; |
| 13 |
import shared.Parser; |
| 14 |
import shared.Shared; |
| 15 |
import shared.Timer; |
| 16 |
import shared.Tools; |
| 17 |
import stream.ConcurrentReadInputStream; |
| 18 |
import stream.ConcurrentReadOutputStream; |
| 19 |
import stream.FastaReadInputStream; |
| 20 |
import stream.Read; |
| 21 |
import structures.ListNum; |
| 22 |
import tracker.ReadStats; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class RemoveAdapters3 { |
| 32 |
|
| 33 |
public static void main(String[] args){ |
| 34 |
|
| 35 |
boolean verbose=false; |
| 36 |
int ziplevel=-1; |
| 37 |
|
| 38 |
String in1=null; |
| 39 |
String in2=null; |
| 40 |
long maxReads=-1; |
| 41 |
|
| 42 |
String outname1=null; |
| 43 |
String outname2=null; |
| 44 |
|
| 45 |
String query=pacbioAdapter; |
| 46 |
|
| 47 |
boolean splitReads=false; |
| 48 |
|
| 49 |
for(int i=0; i<args.length; i++){ |
| 50 |
final String arg=args[i]; |
| 51 |
final String[] split=arg.split("="); |
| 52 |
String a=split[0].toLowerCase(); |
| 53 |
String b=split.length>1 ? split[1] : null; |
| 54 |
|
| 55 |
if(Parser.parseCommonStatic(arg, a, b)){ |
| 56 |
|
| 57 |
}else if(Parser.parseZip(arg, a, b)){ |
| 58 |
|
| 59 |
}else if(Parser.parseQuality(arg, a, b)){ |
| 60 |
|
| 61 |
}else if(Parser.parseFasta(arg, a, b)){ |
| 62 |
|
| 63 |
}else if(a.equals("path") || a.equals("root") || a.equals("tempdir")){ |
| 64 |
Data.setPath(b); |
| 65 |
}else if(a.equals("fasta") || a.equals("in") || a.equals("input") || a.equals("in1") || a.equals("input1")){ |
| 66 |
in1=b; |
| 67 |
if(b.indexOf('#')>-1){ |
| 68 |
in1=b.replace("#", "1"); |
| 69 |
in2=b.replace("#", "2"); |
| 70 |
} |
| 71 |
}else if(a.equals("in2") || a.equals("input2")){ |
| 72 |
in2=b; |
| 73 |
}else if(a.equals("query") || a.equals("adapter")){ |
| 74 |
query=b; |
| 75 |
}else if(a.equals("split")){ |
| 76 |
splitReads=Parse.parseBoolean(b); |
| 77 |
}else if(a.equals("append") || a.equals("app")){ |
| 78 |
append=ReadStats.append=Parse.parseBoolean(b); |
| 79 |
}else if(a.equals("overwrite") || a.equals("ow")){ |
| 80 |
overwrite=Parse.parseBoolean(b); |
| 81 |
System.out.println("Set overwrite to "+overwrite); |
| 82 |
}else if(a.equals("threads") || a.equals("t")){ |
| 83 |
if(b.equalsIgnoreCase("auto")){THREADS=Shared.LOGICAL_PROCESSORS;} |
| 84 |
else{THREADS=Integer.parseInt(b);} |
| 85 |
System.out.println("Set threads to "+THREADS); |
| 86 |
}else if(a.equals("reads") || a.equals("maxreads")){ |
| 87 |
maxReads=Parse.parseKMG(b); |
| 88 |
}else if(a.startsWith("outname") || a.startsWith("outfile") || a.equals("out")){ |
| 89 |
if(b==null || b.equalsIgnoreCase("null") || b.equalsIgnoreCase("none") || split.length==1){ |
| 90 |
System.out.println("No output file."); |
| 91 |
outname1=null; |
| 92 |
OUTPUT_READS=false; |
| 93 |
}else{ |
| 94 |
OUTPUT_READS=true; |
| 95 |
if(b.indexOf('#')>-1){ |
| 96 |
outname1=b.replace('#', '1'); |
| 97 |
outname2=b.replace('#', '2'); |
| 98 |
}else{ |
| 99 |
outname1=b; |
| 100 |
} |
| 101 |
} |
| 102 |
}else if(a.equals("perfectmode")){ |
| 103 |
PERFECTMODE=Parse.parseBoolean(b); |
| 104 |
if(ziplevel==-1){ziplevel=2;} |
| 105 |
}else if(a.equals("minratio")){ |
| 106 |
MINIMUM_ALIGNMENT_SCORE_RATIO=Float.parseFloat(b); |
| 107 |
System.out.println("Set MINIMUM_ALIGNMENT_SCORE_RATIO to "+MINIMUM_ALIGNMENT_SCORE_RATIO); |
| 108 |
}else if(a.startsWith("verbose")){ |
| 109 |
verbose=Parse.parseBoolean(b); |
| 110 |
}else{ |
| 111 |
throw new RuntimeException("Unknown parameter: "+args[i]); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
Parser.processQuality(); |
| 116 |
|
| 117 |
assert(FastaReadInputStream.settingsOK()); |
| 118 |
if(in1==null){throw new RuntimeException("Please specify input file.");} |
| 119 |
|
| 120 |
|
| 121 |
final ConcurrentReadInputStream cris; |
| 122 |
{ |
| 123 |
FileFormat ff1=FileFormat.testInput(in1, FileFormat.FASTQ, null, true, true); |
| 124 |
FileFormat ff2=FileFormat.testInput(in2, FileFormat.FASTQ, null, true, true); |
| 125 |
cris=ConcurrentReadInputStream.getReadInputStream(maxReads, true, ff1, ff2); |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
} |
| 130 |
boolean paired=cris.paired(); |
| 131 |
if(verbose){System.err.println("Paired: "+paired);} |
| 132 |
|
| 133 |
ConcurrentReadOutputStream ros=null; |
| 134 |
if(OUTPUT_READS){ |
| 135 |
final int buff=(!ordered ? THREADS : Tools.max(24, 2*THREADS)); |
| 136 |
|
| 137 |
FileFormat ff1=FileFormat.testOutput(outname1, FileFormat.FASTQ, null, true, overwrite, append, ordered); |
| 138 |
FileFormat ff2=FileFormat.testOutput(outname2, FileFormat.FASTQ, null, true, overwrite, append, ordered); |
| 139 |
ros=ConcurrentReadOutputStream.getStream(ff1, ff2, buff, null, true); |
| 140 |
} |
| 141 |
process(cris, ros, query, splitReads); |
| 142 |
} |
| 143 |
|
| 144 |
public static void process(ConcurrentReadInputStream cris, ConcurrentReadOutputStream ros, String query, boolean split){ |
| 145 |
|
| 146 |
Timer t=new Timer(); |
| 147 |
|
| 148 |
cris.start(); |
| 149 |
|
| 150 |
System.out.println("Started read stream."); |
| 151 |
|
| 152 |
|
| 153 |
if(ros!=null){ |
| 154 |
ros.start(); |
| 155 |
System.out.println("Started output threads."); |
| 156 |
} |
| 157 |
ProcessThread[] pts=new ProcessThread[THREADS]; |
| 158 |
for(int i=0; i<pts.length; i++){ |
| 159 |
pts[i]=new ProcessThread(cris, ros, MINIMUM_ALIGNMENT_SCORE_RATIO, query, split); |
| 160 |
pts[i].start(); |
| 161 |
} |
| 162 |
System.out.println("Started "+pts.length+" processing thread"+(pts.length==1 ? "" : "s")+"."); |
| 163 |
|
| 164 |
for(int i=0; i<pts.length; i++){ |
| 165 |
ProcessThread pt=pts[i]; |
| 166 |
synchronized(pt){ |
| 167 |
while(pt.getState()!=Thread.State.TERMINATED){ |
| 168 |
try { |
| 169 |
pt.join(); |
| 170 |
} catch (InterruptedException e) { |
| 171 |
|
| 172 |
e.printStackTrace(); |
| 173 |
} |
| 174 |
} |
| 175 |
} |
| 176 |
if(i==0){ |
| 177 |
System.out.print("Detecting finished threads: 0"); |
| 178 |
}else{ |
| 179 |
System.out.print(", "+i); |
| 180 |
} |
| 181 |
} |
| 182 |
System.out.println('\n'); |
| 183 |
ReadWrite.closeStreams(cris, ros); |
| 184 |
|
| 185 |
printStatistics(pts); |
| 186 |
|
| 187 |
t.stop(); |
| 188 |
System.out.println("Time: \t"+t); |
| 189 |
|
| 190 |
} |
| 191 |
|
| 192 |
public static void printStatistics(ProcessThread[] pts){ |
| 193 |
|
| 194 |
long plusAdaptersFound=0; |
| 195 |
long minusAdaptersFound=0; |
| 196 |
long goodReadsFound=0; |
| 197 |
long badReadsFound=0; |
| 198 |
|
| 199 |
long truepositive=0; |
| 200 |
long truenegative=0; |
| 201 |
long falsepositive=0; |
| 202 |
long falsenegative=0; |
| 203 |
long expected=0; |
| 204 |
long unexpected=0; |
| 205 |
|
| 206 |
for(ProcessThread pt : pts){ |
| 207 |
plusAdaptersFound+=pt.plusAdaptersFound; |
| 208 |
minusAdaptersFound+=pt.minusAdaptersFound; |
| 209 |
goodReadsFound+=pt.goodReadsFound; |
| 210 |
badReadsFound+=pt.badReadsFound; |
| 211 |
|
| 212 |
truepositive+=pt.truepositive; |
| 213 |
truenegative+=pt.truenegative; |
| 214 |
falsepositive+=pt.falsepositive; |
| 215 |
falsenegative+=pt.falsenegative; |
| 216 |
expected+=pt.expected; |
| 217 |
unexpected+=pt.unexpected; |
| 218 |
} |
| 219 |
|
| 220 |
long totalReads=goodReadsFound+badReadsFound; |
| 221 |
if(expected<1){expected=1;} |
| 222 |
if(unexpected<1){unexpected=1;} |
| 223 |
|
| 224 |
System.out.println("Good reads: \t"+goodReadsFound); |
| 225 |
System.out.println("Bad reads: \t"+badReadsFound); |
| 226 |
System.out.println("Plus adapters: \t"+plusAdaptersFound); |
| 227 |
System.out.println("Minus adapters: \t"+minusAdaptersFound); |
| 228 |
System.out.println(); |
| 229 |
if(truepositive>0 || truenegative>0 || falsepositive>0 || falsenegative>0){ |
| 230 |
System.out.println("Adapters Expected: \t"+expected); |
| 231 |
System.out.println("True Positive: \t"+truepositive+" \t"+Tools.format("%.3f%%", truepositive*100f/expected)); |
| 232 |
System.out.println("True Negative: \t"+truenegative+" \t"+Tools.format("%.3f%%", truenegative*100f/unexpected)); |
| 233 |
System.out.println("False Positive: \t"+falsepositive+" \t"+Tools.format("%.3f%%", falsepositive*100f/unexpected)); |
| 234 |
System.out.println("False Negative: \t"+falsenegative+" \t"+Tools.format("%.3f%%", falsenegative*100f/expected)); |
| 235 |
} |
| 236 |
|
| 237 |
} |
| 238 |
|
| 239 |
private static class ProcessThread extends Thread{ |
| 240 |
|
| 241 |
public ProcessThread(ConcurrentReadInputStream cris_, |
| 242 |
ConcurrentReadOutputStream ros_, float minRatio_, String query_, boolean split_) { |
| 243 |
cris=cris_; |
| 244 |
ros=ros_; |
| 245 |
minRatio=minRatio_; |
| 246 |
query1=query_.getBytes(); |
| 247 |
query2=AminoAcid.reverseComplementBases(query1); |
| 248 |
|
| 249 |
stride=(int)(query1.length*0.95f); |
| 250 |
window=(int)(query1.length*2.5f+10); |
| 251 |
|
| 252 |
ALIGN_ROWS=Tools.max(query1.length, rcompDistance)+1; |
| 253 |
ALIGN_COLUMNS=Tools.max(window, rcompDistance)+5; |
| 254 |
SPLIT=split_; |
| 255 |
|
| 256 |
assert(window<ALIGN_COLUMNS); |
| 257 |
|
| 258 |
msa=new MultiStateAligner9PacBioAdapter(ALIGN_ROWS, ALIGN_COLUMNS); |
| 259 |
msaR=new MultiStateAligner9PacBio(ALIGN_ROWS, ALIGN_COLUMNS); |
| 260 |
|
| 261 |
maxSwScore=msa.maxQuality(query1.length); |
| 262 |
minSwScore=(int)(maxSwScore*MINIMUM_ALIGNMENT_SCORE_RATIO); |
| 263 |
minSwScoreRcomp=(int)(msa.maxQuality(rcompDistance)*MINIMUM_ALIGNMENT_SCORE_RATIO); |
| 264 |
minSwScoreSuspect=(int)(maxSwScore*Tools.min(MINIMUM_ALIGNMENT_SCORE_RATIO*0.7f, MINIMUM_ALIGNMENT_SCORE_RATIO-0.05f)); |
| 265 |
maxImperfectSwScore=msa.maxImperfectScore(query1.length); |
| 266 |
|
| 267 |
rcomp1=new byte[rcompDistance]; |
| 268 |
rcomp2=new byte[rcompDistance]; |
| 269 |
} |
| 270 |
|
| 271 |
@Override |
| 272 |
public void run(){ |
| 273 |
ListNum<Read> ln=cris.nextList(); |
| 274 |
ArrayList<Read> readlist=ln.list; |
| 275 |
|
| 276 |
while(!readlist.isEmpty()){ |
| 277 |
|
| 278 |
|
| 279 |
for(int i=0; i<readlist.size(); i++){ |
| 280 |
Read r=readlist.get(i); |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
if(r.synthetic()){syntheticReads++;} |
| 286 |
|
| 287 |
processRead(r); |
| 288 |
if(r.mate!=null){processRead(r.mate);} |
| 289 |
|
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
if(ros!=null){ |
| 294 |
if(DONT_OUTPUT_BROKEN_READS){removeDiscarded(readlist);} |
| 295 |
for(Read r : readlist){ |
| 296 |
if(r!=null){ |
| 297 |
r.obj=null; |
| 298 |
assert(r.bases!=null); |
| 299 |
if(r.sites!=null && r.sites.isEmpty()){r.sites=null;} |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
if(SPLIT){ |
| 304 |
ros.add(split(readlist), ln.id); |
| 305 |
}else{ |
| 306 |
ros.add(readlist, ln.id); |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
cris.returnList(ln.id, readlist.isEmpty()); |
| 311 |
|
| 312 |
|
| 313 |
ln=cris.nextList(); |
| 314 |
readlist=ln.list; |
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
assert(readlist.isEmpty()); |
| 319 |
cris.returnList(ln.id, readlist.isEmpty()); |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
private static ArrayList<Read> split(ArrayList<Read> in) { |
| 327 |
ArrayList<Read> out=new ArrayList<Read>(in.size()); |
| 328 |
for(Read r : in){ |
| 329 |
if(r!=null){ |
| 330 |
assert(r.mate==null); |
| 331 |
if(!r.hasAdapter()){out.add(r);} |
| 332 |
else{out.addAll(split(r));} |
| 333 |
} |
| 334 |
} |
| 335 |
return out; |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
private static ArrayList<Read> split(Read r) { |
| 343 |
ArrayList<Read> sections=new ArrayList<Read>(); |
| 344 |
|
| 345 |
int lastX=-1; |
| 346 |
for(int i=0; i<r.length(); i++){ |
| 347 |
if(r.bases[i]=='X'){ |
| 348 |
if(i-lastX>minContig){ |
| 349 |
byte[] b=KillSwitch.copyOfRange(r.bases, lastX+1, i); |
| 350 |
byte[] q=r.quality==null ? null : KillSwitch.copyOfRange(r.quality, lastX+1, i); |
| 351 |
Read r2=new Read(b, q, r.id+"_"+(lastX+1), r.numericID); |
| 352 |
sections.add(r2); |
| 353 |
} |
| 354 |
lastX=i; |
| 355 |
} |
| 356 |
} |
| 357 |
int i=r.length(); |
| 358 |
if(i-lastX>minContig){ |
| 359 |
byte[] b=KillSwitch.copyOfRange(r.bases, lastX+1, i); |
| 360 |
byte[] q=r.quality==null ? null : KillSwitch.copyOfRange(r.quality, lastX+1, i); |
| 361 |
Read r2=new Read(b, q, r.id+"_"+(lastX+1), r.numericID); |
| 362 |
sections.add(r2); |
| 363 |
} |
| 364 |
return sections; |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
private int processRead(Read r) { |
| 371 |
|
| 372 |
int begin=0; |
| 373 |
while(begin<r.length() && r.bases[begin]=='N'){begin++;} |
| 374 |
if(begin>=r.length()){return 0;} |
| 375 |
|
| 376 |
final byte[] array=npad(r.bases, npad); |
| 377 |
|
| 378 |
int lim=array.length-npad-stride; |
| 379 |
|
| 380 |
int plusFound=0; |
| 381 |
int minusFound=0; |
| 382 |
|
| 383 |
int lastSuspect=-1; |
| 384 |
|
| 385 |
for(int i=begin; i<lim; i+=stride){ |
| 386 |
int j=Tools.min(i+window, array.length-1); |
| 387 |
if(j-i<window){ |
| 388 |
lim=0; |
| 389 |
|
| 390 |
} |
| 391 |
|
| 392 |
{ |
| 393 |
int[] rvec=msa.fillAndScoreLimited(query2, array, i, j, minSwScoreSuspect); |
| 394 |
if(rvec!=null && rvec[0]>=minSwScoreSuspect){ |
| 395 |
int score=rvec[0]; |
| 396 |
int start=rvec[1]; |
| 397 |
int stop=rvec[2]; |
| 398 |
assert(score>=minSwScoreSuspect); |
| 399 |
if((i==0 || start>i) && (j==array.length-1 || stop<j)){ |
| 400 |
boolean kill=(score>=minSwScore || (lastSuspect>0 && start>=lastSuspect && start-lastSuspect<suspectDistance)); |
| 401 |
|
| 402 |
if(!kill && array.length-stop>window){ |
| 403 |
rvec=msa.fillAndScoreLimited(query2, array, stop, stop+window, minSwScoreSuspect); |
| 404 |
if(rvec!=null && rvec[0]>=minSwScoreSuspect && rvec[1]-stop<suspectDistance){kill=true;} |
| 405 |
} |
| 406 |
|
| 407 |
if(RCOMP && !kill && start>rcompDistance && array.length-stop>rcompDistance+1){ |
| 408 |
kill=testRcomp(array, start, stop); |
| 409 |
|
| 410 |
} |
| 411 |
|
| 412 |
if(kill){ |
| 413 |
|
| 414 |
minusFound++; |
| 415 |
for(int x=Tools.max(0, start); x<=stop; x++){array[x]='X';} |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
lastSuspect=stop; |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
{ |
| 424 |
int[] rvec=msa.fillAndScoreLimited(query1, array, i, j, minSwScoreSuspect); |
| 425 |
if(rvec!=null && rvec[0]>=minSwScoreSuspect){ |
| 426 |
int score=rvec[0]; |
| 427 |
int start=rvec[1]; |
| 428 |
int stop=rvec[2]; |
| 429 |
if((i==0 || start>i) && (j==array.length-1 || stop<j)){ |
| 430 |
boolean kill=(score>=minSwScore || (lastSuspect>0 && start>=lastSuspect && start-lastSuspect<suspectDistance)); |
| 431 |
|
| 432 |
if(!kill && array.length-stop>window){ |
| 433 |
rvec=msa.fillAndScoreLimited(query1, array, stop, stop+window, minSwScoreSuspect); |
| 434 |
if(rvec!=null && rvec[0]>=minSwScoreSuspect && rvec[1]-stop<suspectDistance){kill=true;} |
| 435 |
} |
| 436 |
|
| 437 |
if(RCOMP && !kill && start>rcompDistance && array.length-stop>rcompDistance+1){ |
| 438 |
kill=testRcomp(array, start, stop); |
| 439 |
|
| 440 |
} |
| 441 |
|
| 442 |
if(kill){ |
| 443 |
|
| 444 |
plusFound++; |
| 445 |
for(int x=Tools.max(0, start); x<=stop; x++){array[x]='X';} |
| 446 |
} |
| 447 |
} |
| 448 |
|
| 449 |
lastSuspect=stop; |
| 450 |
} |
| 451 |
} |
| 452 |
} |
| 453 |
|
| 454 |
if(r.synthetic()){ |
| 455 |
if((r.numericID&3)==0){ |
| 456 |
if(plusFound>0){truepositive++;}else{falsenegative++;} |
| 457 |
if(plusFound>1){falsepositive+=(plusFound-1);} |
| 458 |
falsepositive+=minusFound; |
| 459 |
expected++; |
| 460 |
}else if((r.numericID&3)==1){ |
| 461 |
if(minusFound>0){truepositive++;}else{falsenegative++;} |
| 462 |
if(minusFound>1){falsepositive+=(minusFound-1);} |
| 463 |
falsepositive+=plusFound; |
| 464 |
expected++; |
| 465 |
}else{ |
| 466 |
falsepositive=falsepositive+plusFound+minusFound; |
| 467 |
if(plusFound+minusFound==0){truenegative++;} |
| 468 |
unexpected++; |
| 469 |
} |
| 470 |
} |
| 471 |
|
| 472 |
plusAdaptersFound+=plusFound; |
| 473 |
minusAdaptersFound+=minusFound; |
| 474 |
int found=plusFound+minusFound; |
| 475 |
if(found>0){ |
| 476 |
for(int i=npad, j=0; j<r.length(); i++, j++){r.bases[j]=array[i];} |
| 477 |
if(DONT_OUTPUT_BROKEN_READS){r.setDiscarded(true);} |
| 478 |
badReadsFound++; |
| 479 |
}else{ |
| 480 |
goodReadsFound++; |
| 481 |
} |
| 482 |
|
| 483 |
r.setHasAdapter(found>0); |
| 484 |
|
| 485 |
return found; |
| 486 |
|
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
private boolean testRcomp(byte[] array, int start, int stop) { |
| 496 |
|
| 497 |
for(int i=0, j=start-rcompDistance, k=stop+1; i<rcompDistance; i++, j++, k++){ |
| 498 |
rcomp1[i]=array[j]; |
| 499 |
if(rcomp1[i]=='X'){rcomp1[i]='N';} |
| 500 |
rcomp2[i]=array[k]; |
| 501 |
if(rcomp2[i]=='X'){rcomp2[i]='N';} |
| 502 |
} |
| 503 |
AminoAcid.reverseComplementBasesInPlace(rcomp2); |
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
int[] rvec=msaR.fillAndScoreLimited(rcomp1, rcomp2, 0, rcompDistance-1, 0, null); |
| 511 |
int score=rvec==null ? -99999 : rvec[0]; |
| 512 |
|
| 513 |
return score>=1000; |
| 514 |
|
| 515 |
} |
| 516 |
|
| 517 |
private byte[] npad(final byte[] array, final int pad){ |
| 518 |
final int len=array.length+2*pad; |
| 519 |
if(padbuffer==null || padbuffer.length!=len){padbuffer=new byte[len];} |
| 520 |
byte[] r=padbuffer; |
| 521 |
for(int i=0; i<pad; i++){r[i]='N';} |
| 522 |
for(int i=pad, j=0; j<array.length; i++, j++){r[i]=array[j];} |
| 523 |
for(int i=array.length+pad, limit=Tools.min(r.length, len+50); i<limit; i++){r[i]='N';} |
| 524 |
padbuffer=null; |
| 525 |
return r; |
| 526 |
} |
| 527 |
|
| 528 |
private byte[] padbuffer=null; |
| 529 |
private final byte[] rcomp1, rcomp2; |
| 530 |
private final byte[] query1, query2; |
| 531 |
private final ConcurrentReadInputStream cris; |
| 532 |
private final ConcurrentReadOutputStream ros; |
| 533 |
private final float minRatio; |
| 534 |
private final MultiStateAligner9PacBioAdapter msa; |
| 535 |
private final MultiStateAligner9PacBio msaR; |
| 536 |
private final int ALIGN_ROWS; |
| 537 |
private final int ALIGN_COLUMNS; |
| 538 |
private final int stride; |
| 539 |
private final int window; |
| 540 |
private final boolean SPLIT; |
| 541 |
|
| 542 |
long plusAdaptersFound=0; |
| 543 |
long minusAdaptersFound=0; |
| 544 |
long goodReadsFound=0; |
| 545 |
long badReadsFound=0; |
| 546 |
long truepositive=0; |
| 547 |
long truenegative=0; |
| 548 |
long falsepositive=0; |
| 549 |
long falsenegative=0; |
| 550 |
long expected=0; |
| 551 |
long unexpected=0; |
| 552 |
|
| 553 |
private final int maxSwScore; |
| 554 |
private final int minSwScore; |
| 555 |
private final int minSwScoreSuspect; |
| 556 |
private final int minSwScoreRcomp; |
| 557 |
private final int maxImperfectSwScore; |
| 558 |
|
| 559 |
long syntheticReads=0; |
| 560 |
|
| 561 |
} |
| 562 |
|
| 563 |
private static int removeDiscarded(ArrayList<Read> list){ |
| 564 |
int removed=0; |
| 565 |
for(int i=0; i<list.size(); i++){ |
| 566 |
Read r=list.get(i); |
| 567 |
if(r.discarded()){ |
| 568 |
if(r.mate==null || r.mate.discarded()){ |
| 569 |
list.set(i, null); |
| 570 |
removed++; |
| 571 |
} |
| 572 |
} |
| 573 |
} |
| 574 |
return removed; |
| 575 |
} |
| 576 |
|
| 577 |
public static boolean DONT_OUTPUT_BROKEN_READS; |
| 578 |
|
| 579 |
private static boolean overwrite=true; |
| 580 |
|
| 581 |
private static boolean append=false; |
| 582 |
private static int THREADS=Shared.LOGICAL_PROCESSORS; |
| 583 |
private static boolean OUTPUT_READS=false; |
| 584 |
private static boolean ordered=false; |
| 585 |
private static boolean PERFECTMODE=false; |
| 586 |
private static float MINIMUM_ALIGNMENT_SCORE_RATIO=0.31f; |
| 587 |
public static boolean RCOMP=true; |
| 588 |
private static int npad=35; |
| 589 |
public static int minContig=20; |
| 590 |
public static int suspectDistance=100; |
| 591 |
public static int rcompDistance=80; |
| 592 |
|
| 593 |
public static final String pacbioAdapter="ATCTCTCTCTTTTCCTCCTCCTCCGTTGTTGTTGTTGAGAGAGAT"; |
| 594 |
public static final String pacbioStandard_v1="TCCTCCTCCTCCGTTGTTGTTGTTGAGAGAGAGAAGGCTGGGCAGGCTATGCACCCTGGTCCAGGTCAAA" + |
| 595 |
"AGCTGCGGAACCCGCTAGCGGCCATCTTGGCCACTAGGGGTCCCGCAGATTCATATTGTCGTCTAGCATGCACAATGCTGCAAACCCAGCTTGCAATGCCCACAGCA" + |
| 596 |
"AGCGGCCAATCTTTACGCCACGTTGAATTGTTTATTACCTGTGACTGGCTATGGCTTGCAACGCCACTCGTAAAACTAGTACTTTGCGGTTAGGGGAAGTAGACAAA" + |
| 597 |
"CCCATTACTCCACTTCCCGGAAGTTCAACTCATTCCAACACGAAATAAAAGTAAACTCAACACCCCAAGCAGGCTATGTGGGGGGGTGATAGGGGTGGATTCTATTT" + |
| 598 |
"CCTATCCCATCCCCTAGGATCTCAATTAAGTTACTAGCGAGTTAAATGTCTGTAGCGATCCCGTCAGTCCTATCGCGCGCATCAAGACCTGGTTGGTTGAGCGTGCA" + |
| 599 |
"GTAGATCATCGATAAGCTGCGAGTTAGGTCATCCCAGACCGCATCTGGCGCCTAAACGTTCAGTGGTAGCTAAGGCGTCACCTTCGACTGTCTAAAGGCAATATGTC" + |
| 600 |
"GTCCTTAGCTCCAAGTCCCTAGCAAGCGTGTCGGGTCTCTCTCTTTTCCTCCTCCTCCGTTGTTGTTGTTGAGAGAGACCCGACACGCTTGCTAGGGACTTGGAGCT" + |
| 601 |
"AAGGACGACATATTGCCTTTAGACAGTCGAAGGTGACGCCTTAGCTACCACTGAACGTTTAGGCGCCAGATGCGGTCTGGGATGACCTAACTCGCAGCTTATCGATG" + |
| 602 |
"ATCTACTGCACGCTCAACCAACCAGGTCTTGATGCGCGCGATAGGACTGACGGGATCGCTACAGACATTTAACTCGCTAGTAACTTAATTGAGATCCTAGGGGATGG" + |
| 603 |
"GATAGGAAATAGAATCCACCCCTATCACCCCCCCACATAGCCTGCTTGGGGTGTTGAGTTTACTTTTATTTCGTGTTGGAATGAGTTGAACTTCCGGGAAGTGGAGT" + |
| 604 |
"AATGGGTTTGTCTACTTCCCCTAACCGCAAAGTACTAGTTTTACGAGTGGCGTTGCAAGCCATAGCCAGTCACAGGTAATAAACAATTCAACGTGGCGTAAAGATTG" + |
| 605 |
"GCCGCTTGCTGTGGGCATTGCAAGCTGGGTTTGCAGCATTGTGCATGCTAGACGACAATATGAATCTGCGGGACCCCTAGTGGCCAAGATGGCCGCTAGCGGGTTCC" + |
| 606 |
"GCAGCTTTTGACCTGGACCAGGGTGCATAGCCTGCCCAGCCTTCTCTCTCTCTTT"; |
| 607 |
|
| 608 |
|
| 609 |
} |