| 1 |
package jgi; |
| 2 |
|
| 3 |
import java.io.File; |
| 4 |
import java.io.PrintStream; |
| 5 |
import java.text.SimpleDateFormat; |
| 6 |
import java.util.ArrayList; |
| 7 |
import java.util.Date; |
| 8 |
import java.util.LinkedHashSet; |
| 9 |
import java.util.TimeZone; |
| 10 |
|
| 11 |
import align2.BBMap; |
| 12 |
import align2.BBSplitter; |
| 13 |
import align2.RefToIndex; |
| 14 |
import bloom.PolyFilter; |
| 15 |
import cardinality.CardinalityTracker; |
| 16 |
import clump.Clumpify; |
| 17 |
import clump.KmerSort; |
| 18 |
import dna.AminoAcid; |
| 19 |
import dna.Data; |
| 20 |
import fileIO.ByteFile1; |
| 21 |
import fileIO.FileFormat; |
| 22 |
import fileIO.ReadWrite; |
| 23 |
import fileIO.TextFile; |
| 24 |
import fileIO.TextStreamWriter; |
| 25 |
import hiseq.AnalyzeFlowCell; |
| 26 |
import server.ServerTools; |
| 27 |
import shared.Parse; |
| 28 |
import shared.Parser; |
| 29 |
import shared.PreParser; |
| 30 |
import shared.Shared; |
| 31 |
import shared.Timer; |
| 32 |
import shared.Tools; |
| 33 |
import shared.TrimRead; |
| 34 |
import sketch.SendSketch; |
| 35 |
import sketch.SketchObject; |
| 36 |
import stream.FASTQ; |
| 37 |
import stream.Read; |
| 38 |
import stream.ReadInputStream; |
| 39 |
import tax.FilterByTaxa; |
| 40 |
import tax.GiToTaxid; |
| 41 |
import tax.TaxFilter; |
| 42 |
import tax.TaxNode; |
| 43 |
import tax.TaxTree; |
| 44 |
import tracker.ReadStats; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public class RQCFilter2 { |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public static void main(String[] args){ |
| 66 |
|
| 67 |
Timer t=new Timer(); |
| 68 |
|
| 69 |
|
| 70 |
RQCFilter2 x=new RQCFilter2(args); |
| 71 |
|
| 72 |
|
| 73 |
x.process(); |
| 74 |
|
| 75 |
|
| 76 |
t.stop(); |
| 77 |
outstream.println("\nOverall Time: \t"+t); |
| 78 |
|
| 79 |
|
| 80 |
Shared.closeStream(outstream); |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
RQCFilter2(String[] args){ |
| 88 |
|
| 89 |
{ |
| 90 |
PreParser pp=new PreParser(args, getClass(), true); |
| 91 |
args=pp.args; |
| 92 |
outstream=pp.outstream; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
Parser parser=new Parser(); |
| 97 |
|
| 98 |
|
| 99 |
String symbols_=null; |
| 100 |
|
| 101 |
boolean doNextera_=false; |
| 102 |
FASTQ.DETECT_QUALITY_OUT=false; |
| 103 |
FASTQ.ASCII_OFFSET_OUT=33; |
| 104 |
ReadWrite.USE_PIGZ=ReadWrite.USE_UNPIGZ=true; |
| 105 |
ReadWrite.USE_BGZIP=ReadWrite.USE_UNBGZIP=ReadWrite.PREFER_BGZIP=true; |
| 106 |
ReadWrite.setZipThreads(Tools.max(Shared.threads()>1 ? 2 : 1, Shared.threads()>20 ? Shared.threads()/2 : Shared.threads())); |
| 107 |
TaxFilter.REQUIRE_PRESENT=false; |
| 108 |
SendSketch.suppressErrors=ServerTools.suppressErrors=true; |
| 109 |
ReadStats.GC_BINS_AUTO=true; |
| 110 |
|
| 111 |
boolean doMerge_=true; |
| 112 |
|
| 113 |
|
| 114 |
for(int i=0; i<args.length; i++){ |
| 115 |
String arg=args[i]; |
| 116 |
String[] split=arg.split("="); |
| 117 |
String a=split[0].toLowerCase(); |
| 118 |
String b=split.length>1 ? split[1] : null; |
| 119 |
|
| 120 |
if(Parser.parseCommonStatic(arg, a, b)){ |
| 121 |
if(a.equalsIgnoreCase("taxpath")) { |
| 122 |
if(b==null) { |
| 123 |
taxTreeFile=null; |
| 124 |
}else { |
| 125 |
if(TaxTree.TAX_PATH==null) {taxTreeFile="";} |
| 126 |
else {taxTreeFile=TaxTree.TAX_PATH;} |
| 127 |
int lastchar=Tools.lastChar(taxTreeFile); |
| 128 |
if(taxTreeFile.length()>0 && lastchar!='/' && lastchar!='\\') { |
| 129 |
taxTreeFile+="/"; |
| 130 |
} |
| 131 |
taxTreeFile+="tree.taxtree.gz"; |
| 132 |
} |
| 133 |
} |
| 134 |
}else if(Parser.parseZip(arg, a, b)){ |
| 135 |
if(a.equals("pigz")){ |
| 136 |
pigz=b; |
| 137 |
}else if(a.equals("unpigz")){ |
| 138 |
unpigz=b; |
| 139 |
}else if(a.equals("zl") || a.equals("ziplevel")){ |
| 140 |
zl=b; |
| 141 |
} |
| 142 |
}else if(parser.parseInterleaved(arg, a, b)){ |
| 143 |
|
| 144 |
}else if(a.equals("verbose")){ |
| 145 |
verbose=Parse.parseBoolean(b); |
| 146 |
ByteFile1.verbose=verbose; |
| 147 |
stream.FastaReadInputStream.verbose=verbose; |
| 148 |
primaryArgList.add(arg); |
| 149 |
}else if(a.equals("in") || a.equals("input") || a.equals("in1") || a.equals("input1")){ |
| 150 |
in1=b; |
| 151 |
}else if(a.equals("in2") || a.equals("input2")){ |
| 152 |
in2=b; |
| 153 |
}else if(a.equals("out") || a.equals("output") || a.equals("out1") || a.equals("output1")){ |
| 154 |
out1=b; |
| 155 |
}else if(a.equals("out2") || a.equals("output2")){ |
| 156 |
out2=b; |
| 157 |
}else if(a.equals("ref")){ |
| 158 |
if(b!=null){ |
| 159 |
if(!b.contains(",") || new File(b).exists()){ |
| 160 |
bbdukFilterRefs.add(b); |
| 161 |
}else{ |
| 162 |
String[] split2=b.split(","); |
| 163 |
for(String s2 : split2){ |
| 164 |
bbdukFilterRefs.add(s2); |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
}else if(a.equals("spikeinref")){ |
| 169 |
if(b!=null){ |
| 170 |
if(!b.contains(",") || new File(b).exists()){ |
| 171 |
spikeinRefs.add(b); |
| 172 |
}else{ |
| 173 |
String[] split2=b.split(","); |
| 174 |
for(String s2 : split2){ |
| 175 |
spikeinRefs.add(s2); |
| 176 |
} |
| 177 |
} |
| 178 |
} |
| 179 |
}else if(a.equals("artifactdb")){ |
| 180 |
mainArtifactFile=b; |
| 181 |
}else if(a.equals("ribodb")){ |
| 182 |
riboKmers=b; |
| 183 |
}else if(a.equals("phixref")){ |
| 184 |
phixRef=b; |
| 185 |
}else if(a.equals("fragadapter")){ |
| 186 |
fragAdapter=b; |
| 187 |
}else if(a.equals("rnaadapter")){ |
| 188 |
rnaAdapter=b; |
| 189 |
}else if(a.equals("lfpelinker")){ |
| 190 |
lfpeLinker=b; |
| 191 |
}else if(a.equals("cliplinker") || a.equals("jointseq")){ |
| 192 |
clipLinker=b; |
| 193 |
}else if(a.equals("clrslinker")){ |
| 194 |
clrsLinker=b; |
| 195 |
}else if(a.equals("bisulfite") || a.equals("bisulfate")){ |
| 196 |
bisulfite=Parse.parseBoolean(b); |
| 197 |
}else if(a.equals("trimfragadapter") || a.equals("trimfragadapters")){ |
| 198 |
fragAdapterFlag=Parse.parseBoolean(b); |
| 199 |
}else if(a.equals("swift") || a.equals("trimswift")){ |
| 200 |
swiftFlag=Parse.parseBoolean(b); |
| 201 |
}else if(a.equals("trimrnaadapter") || a.equals("trimrnaadapters")){ |
| 202 |
rnaAdapterFlag=Parse.parseBoolean(b); |
| 203 |
}else if(a.equals("removehuman") || a.equals("human")){ |
| 204 |
humanFlag=Parse.parseBoolean(b); |
| 205 |
}else if(a.equals("removedog") || a.equals("dog")){ |
| 206 |
dogFlag=Parse.parseBoolean(b); |
| 207 |
}else if(a.equals("removecat") || a.equals("cat")){ |
| 208 |
catFlag=Parse.parseBoolean(b); |
| 209 |
}else if(a.equals("removemouse") || a.equals("mouse")){ |
| 210 |
mouseFlag=Parse.parseBoolean(b); |
| 211 |
}else if(a.equals("catdoghumanmouse") || a.equals("mousecatdoghuman") || a.equals("")){ |
| 212 |
mouseCatDogHumanFlag=Parse.parseBoolean(b); |
| 213 |
}else if(a.equals("keephumanreads") || a.equals("keephuman")){ |
| 214 |
keepHumanReads=Parse.parseBoolean(b); |
| 215 |
}else if(a.equals("pairedtosingle")){ |
| 216 |
pairedToSingle=Parse.parseBoolean(b); |
| 217 |
}else if(a.equals("aggressive")){ |
| 218 |
aggressiveHumanFlag=aggressiveMicrobeFlag=Parse.parseBoolean(b); |
| 219 |
}else if(a.equals("aggressivehuman")){ |
| 220 |
aggressiveHumanFlag=Parse.parseBoolean(b); |
| 221 |
}else if(a.equals("aggressivemicrobe")){ |
| 222 |
aggressiveMicrobeFlag=Parse.parseBoolean(b); |
| 223 |
}else if(a.equals("removemicrobes") || a.equals("removecommonmicrobes") || a.equals("microbes")){ |
| 224 |
removeCommonMicrobeFlag=Parse.parseBoolean(b); |
| 225 |
}else if(a.equals("trimuntrim")){ |
| 226 |
trimUntrim=Parse.parseBoolean(b); |
| 227 |
}else if(a.equals("ribomap")){ |
| 228 |
riboMapFlag=Parse.parseBoolean(b); |
| 229 |
}else if(a.equals("removechloroplast") || a.equals("chloroplast") || a.equals("chloro") || a.equals("chloromap")){ |
| 230 |
chloroMapFlag=Parse.parseBoolean(b); |
| 231 |
}else if(a.equals("removemito") || a.equals("mito") || a.equals("mitomap")){ |
| 232 |
mitoMapFlag=Parse.parseBoolean(b); |
| 233 |
}else if(a.equals("detectmicrobes") || a.equals("detectcommonmicrobes")){ |
| 234 |
detectMicrobeFlag=Parse.parseBoolean(b); |
| 235 |
}else if(a.equals("detectmicrobes2") || a.equals("detectothermicrobes")){ |
| 236 |
otherMicrobeFlag=Parse.parseBoolean(b); |
| 237 |
}else if(a.equals("removeribo") || a.equals("ribo")){ |
| 238 |
riboKmerFlag=Parse.parseBoolean(b); |
| 239 |
}else if(a.equals("riboout") || a.equals("outribo")){ |
| 240 |
riboOutFile=b; |
| 241 |
}else if(a.equals("fbtout") || a.equals("outfbt")){ |
| 242 |
fbtOutFile=b; |
| 243 |
}else if(a.equals("overwrite") || a.equals("ow")){ |
| 244 |
overwrite=Parse.parseBoolean(b); |
| 245 |
}else if(a.equals("ml") || a.equals("minlen") || a.equals("minlength")){ |
| 246 |
minLen=Integer.parseInt(b); |
| 247 |
}else if(a.equals("mlf") || a.equals("minlenfrac") || a.equals("minlenfraction") || a.equals("minlengthfraction")){ |
| 248 |
minLenFraction=Float.parseFloat(b); |
| 249 |
}else if(a.equals("libtype") || a.equals("library")){ |
| 250 |
libType=toLibType(b); |
| 251 |
}else if(a.equals("path") || a.equals("outdir")){ |
| 252 |
outDir=b; |
| 253 |
}else if(a.equals("symbols")){ |
| 254 |
symbols_=b; |
| 255 |
}else if(a.equals("overallstats") || a.equals("stats")){ |
| 256 |
rqcStatsName=b; |
| 257 |
}else if(a.equals("stats2")){ |
| 258 |
rqcStatsName2=b; |
| 259 |
}else if(a.equals("scafstats")){ |
| 260 |
scaffoldStatsName1=b; |
| 261 |
}else if(a.equals("scafstatskt") || a.equals("scafstatstrim")){ |
| 262 |
scaffoldStatsName_kt=b; |
| 263 |
}else if(a.equals("refstats")){ |
| 264 |
refStatsName=b; |
| 265 |
}else if(a.equals("kmerstats")){ |
| 266 |
kmerStatsName1=b; |
| 267 |
}else if(a.equals("log")){ |
| 268 |
logName=b; |
| 269 |
}else if(a.equals("donefile")){ |
| 270 |
doneFile=b; |
| 271 |
}else if(a.equals("ihist")){ |
| 272 |
ihistName=b; |
| 273 |
}else if(a.equals("merge") || a.equals("domerge")){ |
| 274 |
doMerge_=Parse.parseBoolean(b); |
| 275 |
}else if(a.equals("khist") || a.equals("dokhist")){ |
| 276 |
doKhist=Parse.parseBoolean(b); |
| 277 |
}else if(a.equals("filelist")){ |
| 278 |
fileListName=b; |
| 279 |
}else if(a.equals("compress")){ |
| 280 |
compress=Parse.parseBoolean(b); |
| 281 |
}else if(a.equalsIgnoreCase("polya") || a.equalsIgnoreCase("removepolya") || a.equalsIgnoreCase("filterpolya")){ |
| 282 |
filterPolyA=Parse.parseBoolean(b); |
| 283 |
}else if(a.equalsIgnoreCase("trimpolya")){ |
| 284 |
trimPolyA=Parse.parseBoolean(b); |
| 285 |
}else if(a.equals("trimpolyg")){ |
| 286 |
trimPolyGLeft=trimPolyGRight=Parser.parsePoly(b); |
| 287 |
}else if(a.equals("trimpolygleft")){ |
| 288 |
trimPolyGLeft=Parser.parsePoly(b); |
| 289 |
}else if(a.equals("trimpolygright")){ |
| 290 |
trimPolyGRight=Parser.parsePoly(b); |
| 291 |
}else if(a.equals("filterpolyg")){ |
| 292 |
filterPolyG=Parser.parsePoly(b); |
| 293 |
}else if(a.equals("phix") || a.equals("removephix")){ |
| 294 |
phixFlag=Parse.parseBoolean(b); |
| 295 |
}else if(a.equals("lambda") || a.equals("removelambda")){ |
| 296 |
lambdaFlag=Parse.parseBoolean(b); |
| 297 |
}else if(a.equals("pjet")){ |
| 298 |
pjetFlag=Parse.parseBoolean(b); |
| 299 |
}else if(a.equalsIgnoreCase("sip")){ |
| 300 |
sipFlag=Parse.parseBoolean(b); |
| 301 |
}else if(a.equals("mtst")){ |
| 302 |
mtstFlag=Parse.parseBoolean(b); |
| 303 |
}else if(a.equals("kapa")){ |
| 304 |
kapaFlag=Parse.parseBoolean(b); |
| 305 |
}else if(a.equals("jointseq")){ |
| 306 |
jointSeq=b; |
| 307 |
}else if(a.equals("nextera") || a.equals("nexteralmp")){ |
| 308 |
doNextera_=Parse.parseBoolean(b); |
| 309 |
}else if(a.equals("copyundefined") || a.equals("cu")){ |
| 310 |
copyUndefined=Parse.parseBoolean(b); |
| 311 |
}else if(a.equals("ktrim")){ |
| 312 |
ktrim=b; |
| 313 |
}else if(a.equals("ftl") || a.equals("forcetrimleft")){ |
| 314 |
ftl=Integer.parseInt(b); |
| 315 |
}else if(a.equals("ftr") || a.equals("forcetrimright")){ |
| 316 |
ftr=Integer.parseInt(b); |
| 317 |
}else if(a.equals("ftr2") || a.equals("forcetrimright2")){ |
| 318 |
ftr2=Integer.parseInt(b); |
| 319 |
}else if(a.equals("mink")){ |
| 320 |
mink=Integer.parseInt(b); |
| 321 |
}else if(a.equals("k")){ |
| 322 |
assert(false) : "To specify kmer length, use filterk, trimk, mapk, or normalizek instead of just 'k'"; |
| 323 |
filter_k=Integer.parseInt(b); |
| 324 |
}else if(a.equals("filterk")){ |
| 325 |
filter_k=Integer.parseInt(b); |
| 326 |
}else if(a.equals("trimk")){ |
| 327 |
trim_k=Integer.parseInt(b); |
| 328 |
}else if(a.equals("mapk")){ |
| 329 |
map_k=Integer.parseInt(b); |
| 330 |
}else if(a.equals("normalizek") || a.equals("normk") || a.equals("ecck")){ |
| 331 |
normalize_k=Integer.parseInt(b); |
| 332 |
}else if(a.equals("filterhdist")){ |
| 333 |
hdist_filter=Integer.parseInt(b); |
| 334 |
}else if(a.equals("spikeink")){ |
| 335 |
spikein_k=Integer.parseInt(b); |
| 336 |
}else if(a.equals("spikeinhdist")){ |
| 337 |
hdist_spikein=Integer.parseInt(b); |
| 338 |
}else if(a.equals("filterqhdist")){ |
| 339 |
qhdist_filter=Integer.parseInt(b); |
| 340 |
}else if(a.equals("trimhdist")){ |
| 341 |
hdist_trim=Integer.parseInt(b); |
| 342 |
}else if(a.equals("trimhdist2")){ |
| 343 |
hdist2_trim=Integer.parseInt(b); |
| 344 |
}else if(a.equals("ribohdist")){ |
| 345 |
hdist_ribo=Integer.parseInt(b); |
| 346 |
}else if(a.equals("riboedist") || a.equals("riboedits")){ |
| 347 |
edist_ribo=Integer.parseInt(b); |
| 348 |
}else if(a.equals("maq")){ |
| 349 |
assert(b!=null) : "Bad parameter: "+arg; |
| 350 |
if(b.indexOf(',')>-1){ |
| 351 |
String[] x=b.split(","); |
| 352 |
assert(x.length==2) : "maq should be length 1 or 2 (at most 1 comma).\nFormat: maq=quality,bases; e.g. maq=10 or maq=10,20"; |
| 353 |
minAvgQuality=Byte.parseByte(x[0]); |
| 354 |
minAvgQualityBases=Integer.parseInt(x[1]); |
| 355 |
}else{ |
| 356 |
minAvgQuality=Byte.parseByte(b); |
| 357 |
} |
| 358 |
}else if(a.equals("forcetrimmod") || a.equals("forcemrimmodulo") || a.equals("ftm")){ |
| 359 |
forceTrimModulo=Integer.parseInt(b); |
| 360 |
}else if(a.equals("trimq")){ |
| 361 |
trimq=Byte.parseByte(b); |
| 362 |
}else if(a.equals("qtrim")){ |
| 363 |
if(b==null){qtrim="r";} |
| 364 |
else if(b.equalsIgnoreCase("left") || b.equalsIgnoreCase("l")){qtrim="l";qtrimFlag=true;} |
| 365 |
else if(b.equalsIgnoreCase("right") || b.equalsIgnoreCase("r")){qtrim="r";qtrimFlag=true;} |
| 366 |
else if(b.equalsIgnoreCase("both") || b.equalsIgnoreCase("rl") || b.equalsIgnoreCase("lr")){qtrim="lr";qtrimFlag=true;} |
| 367 |
else if(Tools.isDigit(b.charAt(0))){ |
| 368 |
trimq=Byte.parseByte(b); |
| 369 |
qtrimFlag=(trimq>=0); |
| 370 |
qtrim=(qtrimFlag ? "lr" : "f"); |
| 371 |
}else{ |
| 372 |
qtrimFlag=Parse.parseBoolean(b); |
| 373 |
qtrim=""+qtrimFlag; |
| 374 |
} |
| 375 |
}else if(a.equals("optitrim") || a.equals("otf") || a.equals("otm")){ |
| 376 |
if(b!=null && (b.charAt(0)=='.' || Tools.isDigit(b.charAt(0)))){ |
| 377 |
TrimRead.optimalMode=true; |
| 378 |
TrimRead.optimalBias=Float.parseFloat(b); |
| 379 |
assert(TrimRead.optimalBias>=0 && TrimRead.optimalBias<1); |
| 380 |
}else{ |
| 381 |
TrimRead.optimalMode=Parse.parseBoolean(b); |
| 382 |
} |
| 383 |
}else if(a.equals("maxns")){ |
| 384 |
maxNs=Integer.parseInt(b); |
| 385 |
}else if(a.equals("usetmpdir")){ |
| 386 |
writeTempToTmpdir=Parse.parseBoolean(b); |
| 387 |
}else if(a.equals("tmpdir")){ |
| 388 |
tmpDir=b; |
| 389 |
writeTempToTmpdir=(b!=null); |
| 390 |
}else if(a.equals("delete") || a.equals("deletetemp")){ |
| 391 |
deleteTemp=Parse.parseBoolean(b); |
| 392 |
}else if(a.equals("humanpath")){ |
| 393 |
humanPath=b; |
| 394 |
}else if(a.equals("catpath")){ |
| 395 |
catPath=b; |
| 396 |
}else if(a.equals("dogpath")){ |
| 397 |
dogPath=b; |
| 398 |
}else if(a.equals("mousepath")){ |
| 399 |
dogPath=b; |
| 400 |
}else if(a.equalsIgnoreCase("mouseCatDogHumanPath")){ |
| 401 |
mouseCatDogHumanPath=b; |
| 402 |
}else if(a.equals("mapref") || a.equals("maprefs")){ |
| 403 |
if(b==null){mappingRefs.clear();} |
| 404 |
else{ |
| 405 |
for(String s : b.split(",")){ |
| 406 |
mappingRefs.add(s); |
| 407 |
} |
| 408 |
} |
| 409 |
}else if(a.equals("chastityfilter") || a.equals("cf") || a.equals("chastity")){ |
| 410 |
chastityfilter=b; |
| 411 |
}else if(a.equals("failnobarcode")){ |
| 412 |
failnobarcode=b; |
| 413 |
}else if(a.equals("badbarcodes") || a.equals("barcodefilter")){ |
| 414 |
barcodefilter=b; |
| 415 |
}else if(a.equals("barcodes") || a.equals("barcode")){ |
| 416 |
barcodes=b; |
| 417 |
}else if(a.equals("extend")){ |
| 418 |
extendFlag=Parse.parseBoolean(b); |
| 419 |
extendFlagAuto=false; |
| 420 |
}else if(a.equals("extendauto")){ |
| 421 |
extendFlagAuto=Parse.parseBoolean(b); |
| 422 |
}else if(a.equals("taxlist") || a.equals("tax") || a.equals("taxa") || a.equals("taxid")){ |
| 423 |
taxList=b; |
| 424 |
}else if(a.equals("taxtree") || a.equals("tree")){ |
| 425 |
taxTreeFile=b; |
| 426 |
}else if(a.equals("loadgitable")){ |
| 427 |
loadGiTable=Parse.parseBoolean(b); |
| 428 |
}else if(a.equals("gitable")){ |
| 429 |
giTable=b; |
| 430 |
loadGiTable=(b!=null); |
| 431 |
}else if(a.equals("taxlevel") || a.equals("tl") || a.equals("level") || a.equals("lv")){ |
| 432 |
taxLevel=b; |
| 433 |
}else if(a.equals("microberef")){ |
| 434 |
commonMicrobesRef=b; |
| 435 |
}else if(a.equals("microbepath")){ |
| 436 |
commonMicrobesPath=b; |
| 437 |
}else if(a.equals("microbebuild")){ |
| 438 |
commonMicrobesBuild=Integer.parseInt(b); |
| 439 |
}else if(a.equals("ordered")){ |
| 440 |
ordered=Parse.parseBoolean(b); |
| 441 |
} |
| 442 |
|
| 443 |
else if(a.equals("sketch")){ |
| 444 |
sketchFlag=Parse.parseBoolean(b); |
| 445 |
}else if(a.equals("silvalocal") || a.equals("localsilva")){ |
| 446 |
SILVA_LOCAL=Parse.parseBoolean(b); |
| 447 |
}else if(a.equals("sketchdb") || a.equals("sketchserver")){ |
| 448 |
sketchDB=b; |
| 449 |
}else if(a.equals("sketchreads")){ |
| 450 |
sketchReads=Integer.parseInt(b); |
| 451 |
}else if(a.equals("sketchsamplerate")){ |
| 452 |
sketchSamplerate=b; |
| 453 |
assert(b!=null); |
| 454 |
}else if(a.equals("sketchminprob")){ |
| 455 |
sketchMinProb=b; |
| 456 |
assert(b!=null); |
| 457 |
} |
| 458 |
|
| 459 |
else if(a.equals("clump") || a.equals("clumpify")){ |
| 460 |
doClump=Parse.parseBoolean(b); |
| 461 |
}else if(a.equals("recal") || a.equals("recalibrate")){ |
| 462 |
recalibrate=Parse.parseBoolean(b); |
| 463 |
}else if(a.equals("quantize")){ |
| 464 |
quantize=b; |
| 465 |
}else if(a.equals("phixsam")){ |
| 466 |
phixSam=b; |
| 467 |
}else if(a.equals("tiledump")){ |
| 468 |
tiledump=b; |
| 469 |
}else if(a.equals("polyfilter")){ |
| 470 |
polyfilter=b; |
| 471 |
}else if(a.equals("fbt") || a.equals("filterbytile")){ |
| 472 |
doFilterByTile=Parse.parseBoolean(b); |
| 473 |
}else if(a.equals("dedupe")){ |
| 474 |
removeDuplicates=Parse.parseBoolean(b); |
| 475 |
}else if(a.equals("alldupes")){ |
| 476 |
removeAllDuplicates=Parse.parseBoolean(b); |
| 477 |
}else if(a.equals("opticaldupes") || a.equals("optical")){ |
| 478 |
removeOpticalDuplicates=Parse.parseBoolean(b); |
| 479 |
}else if(a.equals("edgedupes")){ |
| 480 |
removeEdgeDuplicates=Parse.parseBoolean(b); |
| 481 |
}else if(a.equals("dpasses")){ |
| 482 |
duplicatePasses=Integer.parseInt(b); |
| 483 |
}else if(a.equals("dsubs")){ |
| 484 |
duplicateSubs=Integer.parseInt(b); |
| 485 |
}else if(a.equals("ddist")){ |
| 486 |
duplicateDist=Integer.parseInt(b); |
| 487 |
}else if(a.equals("lowcomplexity")){ |
| 488 |
lowComplexity=Parse.parseBoolean(b); |
| 489 |
}else if(a.equals("clumpifygroups") || a.equals("groups")){ |
| 490 |
clumpifyGroups=Integer.parseInt(b); |
| 491 |
}else if(a.equals("clumpifytmpdir")){ |
| 492 |
clumpifyTmpdir=Parse.parseBoolean(b); |
| 493 |
} |
| 494 |
|
| 495 |
else if(a.equals("entropy") || a.equals("efilter") || a.equals("minentropy") || a.equals("entropyfilter")){ |
| 496 |
if(b==null){entropyFilter=true;} |
| 497 |
else if(Tools.isLetter(b.charAt(0))){ |
| 498 |
entropyFilter=Parse.parseBoolean(b); |
| 499 |
}else{ |
| 500 |
minEntropy=Double.parseDouble(b); |
| 501 |
entropyFilter=minEntropy>0; |
| 502 |
} |
| 503 |
}else if(a.equals("entropyk")){ |
| 504 |
entropyk=Integer.parseInt(b); |
| 505 |
}else if(a.equals("entropywindow")){ |
| 506 |
entropywindow=Integer.parseInt(b); |
| 507 |
} |
| 508 |
|
| 509 |
else if(a.equalsIgnoreCase("RQCFilterData") || a.equalsIgnoreCase("RQCFilterPath") || a.equalsIgnoreCase("data") || a.equalsIgnoreCase("datapath")){ |
| 510 |
RQCFilterData=b; |
| 511 |
} |
| 512 |
|
| 513 |
else if(a.equals("discoveradapters") || a.equals("findadapters") || a.equals("detectadapters")){ |
| 514 |
discoverAdaptersFlag=Parse.parseBoolean(b); |
| 515 |
} |
| 516 |
|
| 517 |
else if(a.equals("bloomfilter") || a.equals("bloom")){ |
| 518 |
bloomFilter=Parse.parseBoolean(b); |
| 519 |
}else if(a.equals("bloomk") || a.equals("bloomfilterk")){ |
| 520 |
bloomFilterK=Integer.parseInt(b); |
| 521 |
}else if(a.equals("bloomhashes") || a.equals("bloomfilterhashes")){ |
| 522 |
bloomFilterHashes=Integer.parseInt(b); |
| 523 |
}else if(a.equals("bloomminhits") || a.equals("bloomfilterminhits")){ |
| 524 |
bloomFilterMinHits=Integer.parseInt(b); |
| 525 |
}else if(a.equals("bloomfilterminreads") || a.equals("bloomminreads")){ |
| 526 |
minReadsToBloomFilter=Parse.parseKMG(b); |
| 527 |
}else if(a.equals("bloomserial") || a.equals("serialbloom")){ |
| 528 |
bloomSerial=Parse.parseBoolean(b); |
| 529 |
} |
| 530 |
|
| 531 |
else if(a.equals("dryrun")){ |
| 532 |
dryrun=Parse.parseBoolean(b); |
| 533 |
} |
| 534 |
|
| 535 |
else if(a.equals("skipfilter")){ |
| 536 |
skipFilter=Parse.parseBoolean(b); |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
else if(a.equals("dna")){ |
| 541 |
dnaArtifactFlag=Parse.parseBoolean(b); |
| 542 |
}else if(a.equals("rna")){ |
| 543 |
rnaArtifactFlag=Parse.parseBoolean(b); |
| 544 |
dnaArtifactFlag=!rnaArtifactFlag; |
| 545 |
} |
| 546 |
|
| 547 |
else{ |
| 548 |
|
| 549 |
primaryArgList.add(arg); |
| 550 |
} |
| 551 |
} |
| 552 |
|
| 553 |
{ |
| 554 |
if(RQCFilterData==null){RQCFilterData=".";} |
| 555 |
File f=new File(RQCFilterData); |
| 556 |
assert(f.exists() && f.isDirectory()) : "RQCFilterData path is not set correctly."; |
| 557 |
|
| 558 |
fixReferencePaths(); |
| 559 |
} |
| 560 |
|
| 561 |
if("auto".equalsIgnoreCase(taxTreeFile)){taxTreeFile=TaxTree.defaultTreeFile();} |
| 562 |
|
| 563 |
|
| 564 |
if(doClump){ordered=true;} |
| 565 |
|
| 566 |
doNexteraLMP=doNextera_; |
| 567 |
|
| 568 |
if(removeCommonMicrobeFlag && detectMicrobeFlag){detectMicrobeFlag=false;} |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
if(writeTempToTmpdir){ |
| 573 |
if(tmpDir==null){tmpDir=Shared.tmpdir();} |
| 574 |
if(tmpDir!=null){ |
| 575 |
tmpDir=tmpDir.replace('\\', '/'); |
| 576 |
if(tmpDir.length()>0 && !tmpDir.endsWith("/")){tmpDir+="/";} |
| 577 |
} |
| 578 |
}else{tmpDir=null;} |
| 579 |
|
| 580 |
if(hdist2_trim<0){hdist2_trim=hdist_trim;} |
| 581 |
|
| 582 |
|
| 583 |
primaryArgList.add("ow="+overwrite); |
| 584 |
|
| 585 |
if(outDir!=null){ |
| 586 |
outDir=outDir.trim().replace('\\', '/'); |
| 587 |
if(outDir.length()>0 && !outDir.endsWith("/")){outDir=outDir+"/";} |
| 588 |
}else{outDir="";} |
| 589 |
|
| 590 |
|
| 591 |
{ |
| 592 |
logName=appendOutDir(logName); |
| 593 |
reproduceName=appendOutDir(reproduceName); |
| 594 |
fileListName=appendOutDir(fileListName); |
| 595 |
ihistName=appendOutDir(ihistName); |
| 596 |
khistName=appendOutDir(khistName); |
| 597 |
peaksName=appendOutDir(peaksName); |
| 598 |
riboOutFile=appendOutDir(riboOutFile); |
| 599 |
fbtOutFile=appendOutDir(fbtOutFile); |
| 600 |
chloroOutFile=appendOutDir(chloroOutFile); |
| 601 |
humanOutFile=appendOutDir(humanOutFile); |
| 602 |
spikeinOutFile=appendOutDir(spikeinOutFile); |
| 603 |
synthOutFile1=appendOutDir(synthOutFile1); |
| 604 |
synthOutFile2=appendOutDir(synthOutFile2); |
| 605 |
microbeOutFile=appendOutDir(microbeOutFile); |
| 606 |
microbeStatsFile=appendOutDir(microbeStatsFile); |
| 607 |
microbesUsed=appendOutDir(microbesUsed); |
| 608 |
chloroStatsFile=appendOutDir(chloroStatsFile); |
| 609 |
sipStatsFile=appendOutDir(sipStatsFile); |
| 610 |
sipScafStats=appendOutDir(sipScafStats); |
| 611 |
|
| 612 |
cardinalityName=appendOutDir(cardinalityName); |
| 613 |
adaptersOutFile=appendOutDir(adaptersOutFile); |
| 614 |
|
| 615 |
|
| 616 |
phistName=appendOutDir(phistName); |
| 617 |
qhistName=appendOutDir(qhistName); |
| 618 |
bhistName=appendOutDir(bhistName); |
| 619 |
gchistName=appendOutDir(gchistName); |
| 620 |
doneFile=appendOutDir(doneFile); |
| 621 |
} |
| 622 |
|
| 623 |
{ |
| 624 |
if(rqcStatsName2!=null){ |
| 625 |
rqcStatsName2=appendOutDir(rqcStatsName2); |
| 626 |
} |
| 627 |
if(rqcStatsName!=null){ |
| 628 |
rqcStatsName_kt=appendOutDir("ktrim_"+rqcStatsName); |
| 629 |
rqcStatsName=appendOutDir(rqcStatsName); |
| 630 |
} |
| 631 |
if(kmerStatsName1!=null){ |
| 632 |
kmerStatsName_kt=appendOutDir("ktrim_"+kmerStatsName1); |
| 633 |
kmerStatsName1=appendOutDir(kmerStatsName1); |
| 634 |
} |
| 635 |
if(kmerStatsName2!=null){ |
| 636 |
kmerStatsName2=appendOutDir(kmerStatsName2); |
| 637 |
} |
| 638 |
if(scaffoldStatsNameSpikein!=null){ |
| 639 |
scaffoldStatsNameSpikein=appendOutDir(scaffoldStatsNameSpikein); |
| 640 |
} |
| 641 |
if(scaffoldStatsName1!=null){ |
| 642 |
scaffoldStatsName_kt=appendOutDir("ktrim_"+scaffoldStatsName1); |
| 643 |
scaffoldStatsName1=appendOutDir(scaffoldStatsName1); |
| 644 |
} |
| 645 |
if(scaffoldStatsName2!=null){ |
| 646 |
scaffoldStatsName2=appendOutDir(scaffoldStatsName2); |
| 647 |
} |
| 648 |
if(refStatsName!=null){ |
| 649 |
refStatsName=appendOutDir(refStatsName); |
| 650 |
} |
| 651 |
} |
| 652 |
|
| 653 |
doSpikein=(mtstFlag || kapaFlag || !spikeinRefs.isEmpty()); |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
if(libType==FRAG || ((libType==LFPE && lfpeLinker==null) || (libType==CLIP && clipLinker==null) || (libType==CLRS && clrsLinker==null))){ |
| 658 |
doAdapterTrim=(fragAdapterFlag || rnaAdapterFlag); |
| 659 |
doFilter=!skipFilter; |
| 660 |
}else if(libType==LFPE){ |
| 661 |
doAdapterTrim=true; |
| 662 |
doFilter=!skipFilter; |
| 663 |
}else if(libType==CLIP){ |
| 664 |
doAdapterTrim=true; |
| 665 |
doFilter=!skipFilter; |
| 666 |
}else if(libType==CLRS){ |
| 667 |
doAdapterTrim=true; |
| 668 |
doFilter=!skipFilter; |
| 669 |
}else{ |
| 670 |
throw new RuntimeException("Unknown library type."); |
| 671 |
} |
| 672 |
|
| 673 |
if(phixSam==null) {recalibrate=false;} |
| 674 |
|
| 675 |
|
| 676 |
if(catFlag && dogFlag && humanFlag && mouseFlag){ |
| 677 |
mouseCatDogHumanFlag=true; |
| 678 |
} |
| 679 |
|
| 680 |
|
| 681 |
if(mouseCatDogHumanFlag){ |
| 682 |
mouseFlag=false; |
| 683 |
catFlag=false; |
| 684 |
dogFlag=false; |
| 685 |
humanFlag=false; |
| 686 |
} |
| 687 |
|
| 688 |
if(dogFlag){mappingRefs.add("path="+dogPath);} |
| 689 |
if(catFlag){mappingRefs.add("path="+catPath);} |
| 690 |
if(mouseFlag){mappingRefs.add("path="+mousePath);} |
| 691 |
if(!doMerge_){ihistName=null;} |
| 692 |
doMerge=(ihistName!=null); |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
symbols=(symbols_==null ? abbreviation() : symbols_); |
| 697 |
|
| 698 |
assert(in1!=null) : "No input file specified."; |
| 699 |
|
| 700 |
in1=Tools.fixExtension(in1); |
| 701 |
in2=Tools.fixExtension(in2); |
| 702 |
|
| 703 |
|
| 704 |
if(out1==null){ |
| 705 |
|
| 706 |
File f=new File(in1); |
| 707 |
String name=f.getName(); |
| 708 |
rawName=ReadWrite.rawName(name); |
| 709 |
int dot=rawName.lastIndexOf('.'); |
| 710 |
if(dot>-1){ |
| 711 |
out1=rawName.substring(0, dot)+"."+symbols+rawName.substring(dot)+(compress ? ".gz" : ""); |
| 712 |
}else{ |
| 713 |
out1=rawName+"."+symbols+".fastq"+(compress ? ".gz" : ""); |
| 714 |
} |
| 715 |
}else{ |
| 716 |
File f=new File(out1); |
| 717 |
String name=f.getName(); |
| 718 |
rawName=ReadWrite.rawName(name); |
| 719 |
} |
| 720 |
|
| 721 |
|
| 722 |
tempSalt=KmerNormalize.getSalt(out1, 1); |
| 723 |
clumpPrefix="TEMP_CLUMP_"+tempSalt+"_"; |
| 724 |
recalPrefix="TEMP_RECAL_"+tempSalt+"_"; |
| 725 |
fbtPrefix="TEMP_FBT_"+tempSalt+"_"; |
| 726 |
trimPrefix="TEMP_TRIM_"+tempSalt+"_"; |
| 727 |
polyPrefix="TEMP_POLY_"+tempSalt+"_"; |
| 728 |
humanPrefix="TEMP_HUMAN_"+tempSalt+"_"; |
| 729 |
spikeinPrefix="TEMP_SPIKEIN_"+tempSalt+"_"; |
| 730 |
filterPrefix1="TEMP_FILTER1_"+tempSalt+"_"; |
| 731 |
filterPrefix2="TEMP_FILTER2_"+tempSalt+"_"; |
| 732 |
sipPrefix="TEMP_SIP_"+tempSalt+"_"; |
| 733 |
taxaPrefix="TEMP_TAXA_"+tempSalt+"_"; |
| 734 |
microbePrefix="TEMP_MICROBE_"+tempSalt+"_"; |
| 735 |
riboPrefix="TEMP_RIBO_"+tempSalt+"_"; |
| 736 |
chloroPrefix="TEMP_CHLORO_"+tempSalt+"_"; |
| 737 |
|
| 738 |
if(mappingRefs.size()>0){ |
| 739 |
mappingPrefix=new String[mappingRefs.size()]; |
| 740 |
for(int i=0; i<mappingRefs.size(); i++){ |
| 741 |
mappingPrefix[i]="TEMP_MAP_"+tempSalt+"_"+i+"_"; |
| 742 |
} |
| 743 |
}else{ |
| 744 |
mappingPrefix=null; |
| 745 |
} |
| 746 |
|
| 747 |
if(reproduceName!=null){ |
| 748 |
writeReproduceHeader(reproduceName, args, overwrite); |
| 749 |
} |
| 750 |
} |
| 751 |
|
| 752 |
private String appendOutDir(String s){ |
| 753 |
if(s==null){return null;} |
| 754 |
if(s.startsWith(outDir)){return s;} |
| 755 |
return outDir+s; |
| 756 |
} |
| 757 |
|
| 758 |
private String removeOutDir(String s){ |
| 759 |
if(s==null){return null;} |
| 760 |
if(outDir==null || outDir.length()==0){return s;} |
| 761 |
if(s.startsWith(outDir)){return s.substring(outDir.length());} |
| 762 |
return s; |
| 763 |
} |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
public void process(){ |
| 774 |
|
| 775 |
if(doneFile!=null){ |
| 776 |
try { |
| 777 |
File f=new File(doneFile); |
| 778 |
if(f.exists()){ |
| 779 |
f.delete(); |
| 780 |
} |
| 781 |
} catch (Exception e) { |
| 782 |
e.printStackTrace(); |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
if(outDir!=null && outDir.length()>0){ |
| 788 |
File f=new File(outDir); |
| 789 |
if(!f.exists()){ |
| 790 |
f.mkdirs(); |
| 791 |
} |
| 792 |
} |
| 793 |
|
| 794 |
|
| 795 |
if(logName!=null){ |
| 796 |
boolean b=Tools.canWrite(logName, overwrite); |
| 797 |
assert(b) : "Can't write to "+logName; |
| 798 |
log("bbtools filter start", false); |
| 799 |
} |
| 800 |
|
| 801 |
|
| 802 |
if(fileListName!=null){ |
| 803 |
boolean b=Tools.canWrite(fileListName, overwrite); |
| 804 |
assert(b) : "Can't write to "+fileListName; |
| 805 |
|
| 806 |
StringBuilder sb=new StringBuilder(); |
| 807 |
if(!doNexteraLMP){ |
| 808 |
if(out1!=null){sb.append("filtered_fastq="+out1).append('\n');} |
| 809 |
if(out2!=null){sb.append("filtered_fastq_2="+out2).append('\n');} |
| 810 |
} |
| 811 |
|
| 812 |
String x=(outDir==null ? "" : outDir); |
| 813 |
int xlen=x.length(); |
| 814 |
|
| 815 |
|
| 816 |
if(ihistName!=null){ |
| 817 |
sb.append("ihist="+removeOutDir(ihistName)).append('\n'); |
| 818 |
} |
| 819 |
if(doKhist){ |
| 820 |
if(khistName!=null){ |
| 821 |
sb.append("khist="+removeOutDir(khistName)).append('\n'); |
| 822 |
} |
| 823 |
if(peaksName!=null){ |
| 824 |
sb.append("peaks="+removeOutDir(peaksName)).append('\n'); |
| 825 |
} |
| 826 |
} |
| 827 |
if(scaffoldStatsNameSpikein!=null && doSpikein){ |
| 828 |
sb.append("spikeinstats="+removeOutDir(scaffoldStatsNameSpikein)).append('\n'); |
| 829 |
} |
| 830 |
if(scaffoldStatsName1!=null){ |
| 831 |
sb.append("scafstats1="+removeOutDir(scaffoldStatsName1)).append('\n'); |
| 832 |
} |
| 833 |
if(scaffoldStatsName2!=null){ |
| 834 |
sb.append("scafstats2="+removeOutDir(scaffoldStatsName2)).append('\n'); |
| 835 |
} |
| 836 |
if(refStatsName!=null){ |
| 837 |
sb.append("refstats="+removeOutDir(refStatsName)).append('\n'); |
| 838 |
} |
| 839 |
if(riboKmerFlag && riboOutFile!=null){ |
| 840 |
sb.append("ribo="+removeOutDir(riboOutFile)).append('\n'); |
| 841 |
} |
| 842 |
if(doFilterByTile && fbtOutFile!=null){ |
| 843 |
sb.append("filteredByTile="+removeOutDir(fbtOutFile)).append('\n'); |
| 844 |
} |
| 845 |
|
| 846 |
if(sipFlag){ |
| 847 |
if(sipStatsFile!=null){ |
| 848 |
sb.append("sipSpikeinStats="+removeOutDir(sipStatsFile)).append('\n'); |
| 849 |
} |
| 850 |
if(sipScafStats!=null){ |
| 851 |
sb.append("sipScafStats="+removeOutDir(sipScafStats)).append('\n'); |
| 852 |
} |
| 853 |
} |
| 854 |
|
| 855 |
if((chloroMapFlag || mitoMapFlag || riboMapFlag) && chloroOutFile!=null){ |
| 856 |
sb.append("chloroMitoRiboReads="+removeOutDir(chloroOutFile)).append('\n'); |
| 857 |
} |
| 858 |
if((chloroMapFlag || mitoMapFlag || riboMapFlag) && chloroStatsFile!=null){ |
| 859 |
sb.append("chloroMitoRiboStats="+removeOutDir(chloroStatsFile)).append('\n'); |
| 860 |
} |
| 861 |
|
| 862 |
if(removeCommonMicrobeFlag && microbeOutFile!=null){ |
| 863 |
sb.append("chaffMicrobeReads="+removeOutDir(microbeOutFile)).append('\n'); |
| 864 |
sb.append("microbeStats="+removeOutDir(microbeStatsFile)).append('\n'); |
| 865 |
}else if(detectMicrobeFlag && microbeStatsFile!=null){ |
| 866 |
sb.append("microbeStats="+removeOutDir(microbeStatsFile)).append('\n'); |
| 867 |
} |
| 868 |
if(removeCommonMicrobeFlag && microbesUsed!=null){ |
| 869 |
sb.append("microbesUsed="+removeOutDir(microbesUsed)).append('\n'); |
| 870 |
} |
| 871 |
|
| 872 |
if(otherMicrobeFlag && microbeStats2File!=null){ |
| 873 |
sb.append("microbeStats2="+removeOutDir(microbeStats2File)).append('\n'); |
| 874 |
} |
| 875 |
|
| 876 |
if(discoverAdaptersFlag && adaptersOutFile!=null){ |
| 877 |
sb.append("adaptersDetected="+removeOutDir(adaptersOutFile)).append('\n'); |
| 878 |
} |
| 879 |
|
| 880 |
if(doFilter && synthOutFile1!=null){ |
| 881 |
sb.append("chaffSynthReads1="+removeOutDir(synthOutFile1)).append('\n'); |
| 882 |
} |
| 883 |
if(doFilter && synthOutFile2!=null){ |
| 884 |
sb.append("chaffSynthReads2="+removeOutDir(synthOutFile2)).append('\n'); |
| 885 |
} |
| 886 |
if((humanFlag || mouseCatDogHumanFlag) && humanOutFile!=null){ |
| 887 |
sb.append("chaffHumanReads="+removeOutDir(humanOutFile)).append('\n'); |
| 888 |
} |
| 889 |
|
| 890 |
if(sketchFlag && sketchName!=null){ |
| 891 |
sb.append("sketchResult="+removeOutDir(sketchName)).append('\n'); |
| 892 |
} |
| 893 |
|
| 894 |
if(doAdapterTrim){ |
| 895 |
if(phistName!=null){ |
| 896 |
sb.append("polymerHist="+removeOutDir(phistName)).append('\n'); |
| 897 |
} |
| 898 |
if(qhistName!=null){ |
| 899 |
sb.append("qualityHist="+removeOutDir(qhistName)).append('\n'); |
| 900 |
} |
| 901 |
if(bhistName!=null){ |
| 902 |
sb.append("baseFrequencyHist="+removeOutDir(bhistName)).append('\n'); |
| 903 |
} |
| 904 |
if(gchistName!=null){ |
| 905 |
sb.append("GCHist="+removeOutDir(gchistName)).append('\n'); |
| 906 |
} |
| 907 |
} |
| 908 |
|
| 909 |
if(sb.length()>0){ |
| 910 |
ReadWrite.writeString(sb, fileListName, false); |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
Shared.GC_BEFORE_PRINT_MEMORY=true; |
| 915 |
Shared.printMemory(); |
| 916 |
|
| 917 |
long lastReadsObserved=-1; |
| 918 |
{ |
| 919 |
|
| 920 |
|
| 921 |
if(sketchFlag){ |
| 922 |
boolean success=runSketch(in1, sketchName, null); |
| 923 |
Shared.printMemory(); |
| 924 |
} |
| 925 |
|
| 926 |
|
| 927 |
int step=0; |
| 928 |
final int numSteps=(doClump ? 1 : 0)+(doFilterByTile ? 1 : 0)+(doSpikein ? 1 : 0)+(doFilter ? 2 : 0)+(doAdapterTrim ? 1 : 0)+(doNexteraLMP ? 1 : 0)+(riboKmerFlag ? 1 : 0)+ |
| 929 |
((chloroMapFlag || mitoMapFlag || riboMapFlag) ? 1 : 0)+(sipFlag ? 1 : 0)+(recalibrate ? 1 : 0)+(polyfilter==null ? 0 : 1)+ |
| 930 |
(removeCommonMicrobeFlag ? 1 : 0)+((humanFlag || mouseCatDogHumanFlag) ? 1 : 0)+mappingRefs.size(); |
| 931 |
String inPrefix=null, outPrefix=null; |
| 932 |
|
| 933 |
if(discoverAdaptersFlag){ |
| 934 |
discoverAdapters(in1, in2, adaptersOutFile); |
| 935 |
Data.unloadAll(); |
| 936 |
Shared.printMemory(); |
| 937 |
} |
| 938 |
|
| 939 |
|
| 940 |
if(doClump){ |
| 941 |
step++; |
| 942 |
inPrefix=outPrefix; |
| 943 |
outPrefix=(step<numSteps ? clumpPrefix : null); |
| 944 |
|
| 945 |
|
| 946 |
final String in1z, in2z, out1z, out2z; |
| 947 |
if(step==1){ |
| 948 |
in1z=in1; in2z=in2; |
| 949 |
}else{ |
| 950 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 951 |
} |
| 952 |
if(step>=numSteps){ |
| 953 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 954 |
out1z=out1; out2z=out2; |
| 955 |
}else{ |
| 956 |
ReadWrite.ZIPLEVEL=Tools.min(ReadWrite.ZIPLEVEL, 4); |
| 957 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 958 |
} |
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
clumpify(in1z, in2z, out1z, out2z, inPrefix, outPrefix, step); |
| 965 |
lastReadsObserved=KmerSort.lastReadsOut; |
| 966 |
|
| 967 |
if(in2!=null && out2==null){ |
| 968 |
FASTQ.FORCE_INTERLEAVED=true; |
| 969 |
FASTQ.TEST_INTERLEAVED=false; |
| 970 |
} |
| 971 |
|
| 972 |
if(inPrefix!=null){ |
| 973 |
delete(inPrefix, out1z, out2z); |
| 974 |
} |
| 975 |
|
| 976 |
FASTQ.ASCII_OFFSET=33; |
| 977 |
FASTQ.DETECT_QUALITY=false; |
| 978 |
Data.unloadAll(); |
| 979 |
Shared.printMemory(); |
| 980 |
} |
| 981 |
|
| 982 |
if(recalibrate) { |
| 983 |
step++; |
| 984 |
inPrefix=outPrefix; |
| 985 |
outPrefix=(step<numSteps ? recalPrefix : null); |
| 986 |
|
| 987 |
|
| 988 |
final String in1z, in2z, out1z, out2z; |
| 989 |
if(step==1){ |
| 990 |
in1z=in1; in2z=in2; |
| 991 |
}else{ |
| 992 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 993 |
} |
| 994 |
if(step>=numSteps){ |
| 995 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 996 |
out1z=out1; out2z=out2; |
| 997 |
}else{ |
| 998 |
ReadWrite.ZIPLEVEL=Tools.min(ReadWrite.ZIPLEVEL, 4); |
| 999 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1000 |
} |
| 1001 |
|
| 1002 |
calcTrueQuality(phixSam); |
| 1003 |
recalibrate(in1z, in2z, out1z, out2z, inPrefix, outPrefix, step); |
| 1004 |
lastReadsObserved=BBDuk.lastReadsOut; |
| 1005 |
|
| 1006 |
|
| 1007 |
if(in2!=null && out2==null){ |
| 1008 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1009 |
FASTQ.TEST_INTERLEAVED=false; |
| 1010 |
} |
| 1011 |
|
| 1012 |
if(inPrefix!=null){ |
| 1013 |
delete(inPrefix, out1z, out2z); |
| 1014 |
} |
| 1015 |
|
| 1016 |
FASTQ.ASCII_OFFSET=33; |
| 1017 |
FASTQ.DETECT_QUALITY=false; |
| 1018 |
ReadStats.clear(); |
| 1019 |
Data.unloadAll(); |
| 1020 |
Shared.printMemory(); |
| 1021 |
} |
| 1022 |
|
| 1023 |
|
| 1024 |
if(doFilterByTile){ |
| 1025 |
step++; |
| 1026 |
if(dryrun || lastReadsObserved<0 || lastReadsObserved>=400000 || tiledump!=null){ |
| 1027 |
inPrefix=outPrefix; |
| 1028 |
outPrefix=(step<numSteps ? fbtPrefix : null); |
| 1029 |
|
| 1030 |
final String in1z, in2z, out1z, out2z; |
| 1031 |
if(step==1){ |
| 1032 |
in1z=in1; in2z=in2; |
| 1033 |
}else{ |
| 1034 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1035 |
} |
| 1036 |
if(step>=numSteps){ |
| 1037 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1038 |
out1z=out1; out2z=out2; |
| 1039 |
}else{ |
| 1040 |
ReadWrite.ZIPLEVEL=Tools.min(ReadWrite.ZIPLEVEL, 4); |
| 1041 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1042 |
} |
| 1043 |
|
| 1044 |
filterByTile(in1z, in2z, out1z, out2z, fbtOutFile, tiledump, inPrefix, outPrefix, step); |
| 1045 |
lastReadsObserved=AnalyzeFlowCell.lastReadsOut; |
| 1046 |
|
| 1047 |
if(in2!=null && out2==null){ |
| 1048 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1049 |
FASTQ.TEST_INTERLEAVED=false; |
| 1050 |
} |
| 1051 |
|
| 1052 |
if(inPrefix!=null){ |
| 1053 |
delete(inPrefix, out1z, out2z); |
| 1054 |
} |
| 1055 |
|
| 1056 |
FASTQ.ASCII_OFFSET=33; |
| 1057 |
FASTQ.DETECT_QUALITY=false; |
| 1058 |
} |
| 1059 |
Data.unloadAll(); |
| 1060 |
Shared.printMemory(); |
| 1061 |
} |
| 1062 |
|
| 1063 |
|
| 1064 |
if(doAdapterTrim){ |
| 1065 |
step++; |
| 1066 |
inPrefix=outPrefix; |
| 1067 |
outPrefix=(step<numSteps ? trimPrefix : null); |
| 1068 |
|
| 1069 |
|
| 1070 |
final String in1z, in2z, out1z, out2z; |
| 1071 |
if(step==1){ |
| 1072 |
in1z=in1; in2z=in2; |
| 1073 |
}else{ |
| 1074 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1075 |
} |
| 1076 |
if(step>=numSteps){ |
| 1077 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1078 |
out1z=out1; out2z=out2; |
| 1079 |
}else{ |
| 1080 |
ReadWrite.ZIPLEVEL=Tools.min(ReadWrite.ZIPLEVEL, 4); |
| 1081 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1082 |
} |
| 1083 |
|
| 1084 |
ktrim(in1z, in2z, out1z, out2z, inPrefix, outPrefix, step); |
| 1085 |
lastReadsObserved=BBDuk.lastReadsOut; |
| 1086 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 6); |
| 1087 |
|
| 1088 |
|
| 1089 |
if(in2!=null && out2==null){ |
| 1090 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1091 |
FASTQ.TEST_INTERLEAVED=false; |
| 1092 |
} |
| 1093 |
|
| 1094 |
if(inPrefix!=null){ |
| 1095 |
delete(inPrefix, out1z, out2z); |
| 1096 |
} |
| 1097 |
|
| 1098 |
FASTQ.ASCII_OFFSET=33; |
| 1099 |
FASTQ.DETECT_QUALITY=false; |
| 1100 |
ReadStats.clear(); |
| 1101 |
Data.unloadAll(); |
| 1102 |
Shared.printMemory(); |
| 1103 |
} |
| 1104 |
|
| 1105 |
|
| 1106 |
if(polyfilter!=null){ |
| 1107 |
step++; |
| 1108 |
inPrefix=outPrefix; |
| 1109 |
outPrefix=(step<numSteps ? polyPrefix : null); |
| 1110 |
|
| 1111 |
|
| 1112 |
final String in1z, in2z, out1z, out2z; |
| 1113 |
if(step==1){ |
| 1114 |
in1z=in1; in2z=in2; |
| 1115 |
}else{ |
| 1116 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1117 |
} |
| 1118 |
if(step>=numSteps){ |
| 1119 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1120 |
out1z=out1; out2z=out2; |
| 1121 |
}else{ |
| 1122 |
ReadWrite.ZIPLEVEL=Tools.min(ReadWrite.ZIPLEVEL, 4); |
| 1123 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1124 |
} |
| 1125 |
|
| 1126 |
polyfilter(in1z, in2z, out1z, out2z, inPrefix, outPrefix, polyfilter, step); |
| 1127 |
lastReadsObserved=PolyFilter.lastReadsOut; |
| 1128 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 6); |
| 1129 |
|
| 1130 |
|
| 1131 |
if(in2!=null && out2==null){ |
| 1132 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1133 |
FASTQ.TEST_INTERLEAVED=false; |
| 1134 |
} |
| 1135 |
|
| 1136 |
if(inPrefix!=null){ |
| 1137 |
delete(inPrefix, out1z, out2z); |
| 1138 |
} |
| 1139 |
|
| 1140 |
FASTQ.ASCII_OFFSET=33; |
| 1141 |
FASTQ.DETECT_QUALITY=false; |
| 1142 |
Data.unloadAll(); |
| 1143 |
Shared.printMemory(); |
| 1144 |
} |
| 1145 |
|
| 1146 |
|
| 1147 |
if(doSpikein){ |
| 1148 |
step++; |
| 1149 |
inPrefix=outPrefix; |
| 1150 |
outPrefix=(step<numSteps ? spikeinPrefix : null); |
| 1151 |
|
| 1152 |
|
| 1153 |
final String in1z, in2z, out1z, out2z; |
| 1154 |
if(step==1){ |
| 1155 |
in1z=in1; in2z=in2; |
| 1156 |
}else{ |
| 1157 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1158 |
} |
| 1159 |
if(step>=numSteps){ |
| 1160 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1161 |
out1z=out1; out2z=out2; |
| 1162 |
}else{ |
| 1163 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1164 |
} |
| 1165 |
|
| 1166 |
filterSpikein(in1z, in2z, out1z, out2z, spikeinOutFile, inPrefix, outPrefix, step); |
| 1167 |
lastReadsObserved=Seal.lastReadsOut; |
| 1168 |
|
| 1169 |
if(in2!=null && out2==null){ |
| 1170 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1171 |
FASTQ.TEST_INTERLEAVED=false; |
| 1172 |
} |
| 1173 |
|
| 1174 |
if(step>1){ |
| 1175 |
delete(inPrefix, out1z, out2z); |
| 1176 |
} |
| 1177 |
Data.unloadAll(); |
| 1178 |
Shared.printMemory(); |
| 1179 |
} |
| 1180 |
|
| 1181 |
|
| 1182 |
if(doFilter){ |
| 1183 |
step++; |
| 1184 |
inPrefix=outPrefix; |
| 1185 |
outPrefix=(step<numSteps ? filterPrefix1 : null); |
| 1186 |
|
| 1187 |
|
| 1188 |
final String in1z, in2z, out1z, out2z; |
| 1189 |
if(step==1){ |
| 1190 |
in1z=in1; in2z=in2; |
| 1191 |
}else{ |
| 1192 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1193 |
} |
| 1194 |
if(step>=numSteps){ |
| 1195 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1196 |
out1z=out1; out2z=out2; |
| 1197 |
}else{ |
| 1198 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1199 |
} |
| 1200 |
|
| 1201 |
filter1(in1z, in2z, out1z, out2z, synthOutFile1, inPrefix, outPrefix, step); |
| 1202 |
lastReadsObserved=BBDuk.lastReadsOut; |
| 1203 |
|
| 1204 |
if(in2!=null && out2==null){ |
| 1205 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1206 |
FASTQ.TEST_INTERLEAVED=false; |
| 1207 |
} |
| 1208 |
|
| 1209 |
if(step>1){ |
| 1210 |
delete(inPrefix, out1z, out2z); |
| 1211 |
} |
| 1212 |
Data.unloadAll(); |
| 1213 |
Shared.printMemory(); |
| 1214 |
} |
| 1215 |
|
| 1216 |
|
| 1217 |
if(doFilter){ |
| 1218 |
step++; |
| 1219 |
inPrefix=outPrefix; |
| 1220 |
outPrefix=(step<numSteps ? filterPrefix2 : null); |
| 1221 |
|
| 1222 |
|
| 1223 |
final String in1z, in2z, out1z, out2z; |
| 1224 |
if(step==1){ |
| 1225 |
in1z=in1; in2z=in2; |
| 1226 |
}else{ |
| 1227 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1228 |
} |
| 1229 |
if(step>=numSteps){ |
| 1230 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1231 |
out1z=out1; out2z=out2; |
| 1232 |
}else{ |
| 1233 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1234 |
} |
| 1235 |
|
| 1236 |
filter2(in1z, in2z, out1z, out2z, synthOutFile2, inPrefix, outPrefix, step); |
| 1237 |
lastReadsObserved=BBDuk.lastReadsOut; |
| 1238 |
|
| 1239 |
if(in2!=null && out2==null){ |
| 1240 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1241 |
FASTQ.TEST_INTERLEAVED=false; |
| 1242 |
} |
| 1243 |
|
| 1244 |
if(step>1){ |
| 1245 |
delete(inPrefix, out1z, out2z); |
| 1246 |
} |
| 1247 |
Data.unloadAll(); |
| 1248 |
Shared.printMemory(); |
| 1249 |
} |
| 1250 |
|
| 1251 |
if(sipFlag){ |
| 1252 |
step++; |
| 1253 |
inPrefix=outPrefix; |
| 1254 |
outPrefix=(step<numSteps ? sipPrefix : null); |
| 1255 |
|
| 1256 |
|
| 1257 |
final String in1z, in2z, out1z, out2z; |
| 1258 |
if(step==1){ |
| 1259 |
in1z=in1; in2z=in2; |
| 1260 |
}else{ |
| 1261 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1262 |
} |
| 1263 |
if(step>=numSteps){ |
| 1264 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1265 |
out1z=out1; out2z=out2; |
| 1266 |
}else{ |
| 1267 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1268 |
} |
| 1269 |
|
| 1270 |
|
| 1271 |
final String ref=Data.findPath("?SIP_spikeins.fa.gz"); |
| 1272 |
|
| 1273 |
{ |
| 1274 |
ArrayList<String> args=new ArrayList<String>(); |
| 1275 |
args.add("covstats="+sipStatsFile); |
| 1276 |
final boolean addToOtherStats=(sipStatsFile==null); |
| 1277 |
decontamByMapping(in1z, in2z, out1z, out2z, null, sipScafStats, inPrefix, outPrefix, ref, step, addToOtherStats, args); |
| 1278 |
if(!addToOtherStats){ |
| 1279 |
filterstats.parseSip(sipScafStats); |
| 1280 |
assert(filterstats.toString()!=null); |
| 1281 |
} |
| 1282 |
} |
| 1283 |
|
| 1284 |
if(in2!=null && out2==null){ |
| 1285 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1286 |
FASTQ.TEST_INTERLEAVED=false; |
| 1287 |
} |
| 1288 |
|
| 1289 |
if(step>1){ |
| 1290 |
delete(inPrefix, out1z, out2z); |
| 1291 |
} |
| 1292 |
Data.unloadAll(); |
| 1293 |
Shared.printMemory(); |
| 1294 |
} |
| 1295 |
|
| 1296 |
|
| 1297 |
if(riboKmerFlag){ |
| 1298 |
step++; |
| 1299 |
inPrefix=outPrefix; |
| 1300 |
outPrefix=(step<numSteps ? riboPrefix : null); |
| 1301 |
|
| 1302 |
|
| 1303 |
final String in1z, in2z, out1z, out2z; |
| 1304 |
if(step==1){ |
| 1305 |
in1z=in1; in2z=in2; |
| 1306 |
}else{ |
| 1307 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1308 |
} |
| 1309 |
if(step>=numSteps){ |
| 1310 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1311 |
out1z=out1; out2z=out2; |
| 1312 |
}else{ |
| 1313 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1314 |
} |
| 1315 |
|
| 1316 |
filterRibo(in1z, in2z, out1z, out2z, riboOutFile, inPrefix, outPrefix, step); |
| 1317 |
lastReadsObserved=BBDuk.lastReadsOut; |
| 1318 |
|
| 1319 |
if(in2!=null && out2==null){ |
| 1320 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1321 |
FASTQ.TEST_INTERLEAVED=false; |
| 1322 |
} |
| 1323 |
|
| 1324 |
if(step>1){ |
| 1325 |
delete(inPrefix, out1z, out2z); |
| 1326 |
} |
| 1327 |
Data.unloadAll(); |
| 1328 |
Shared.printMemory(); |
| 1329 |
} |
| 1330 |
|
| 1331 |
if(detectMicrobeFlag){ |
| 1332 |
|
| 1333 |
inPrefix=outPrefix; |
| 1334 |
final String in1z, in2z; |
| 1335 |
if(step==1){ |
| 1336 |
in1z=in1; in2z=in2; |
| 1337 |
}else if(step<numSteps){ |
| 1338 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1339 |
}else{ |
| 1340 |
inPrefix=null; |
| 1341 |
in1z=outDir+stripDirs(out1); |
| 1342 |
in2z=(out2==null ? null : outDir+stripDirs(out2)); |
| 1343 |
} |
| 1344 |
|
| 1345 |
String ref=commonMicrobesRef; |
| 1346 |
|
| 1347 |
detectCommonMicrobes(in1z, in2z, microbeStatsFile, inPrefix, ref, aggressiveMicrobeFlag, commonMicrobesBuild, commonMicrobesRef, commonMicrobesPath); |
| 1348 |
Data.unloadAll(); |
| 1349 |
Shared.printMemory(); |
| 1350 |
} |
| 1351 |
|
| 1352 |
|
| 1353 |
if(removeCommonMicrobeFlag){ |
| 1354 |
step++; |
| 1355 |
inPrefix=outPrefix; |
| 1356 |
outPrefix=(step<numSteps ? microbePrefix : null); |
| 1357 |
|
| 1358 |
|
| 1359 |
final String in1z, in2z, out1z, out2z; |
| 1360 |
if(step==1){ |
| 1361 |
in1z=in1; in2z=in2; |
| 1362 |
}else{ |
| 1363 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1364 |
} |
| 1365 |
if(step>=numSteps){ |
| 1366 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1367 |
out1z=out1; out2z=out2; |
| 1368 |
}else{ |
| 1369 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1370 |
} |
| 1371 |
|
| 1372 |
String ref=taxFilter(commonMicrobesRef, "taxa.fa.gz", microbesUsed, taxLevel, false, false, true, overwrite, false); |
| 1373 |
|
| 1374 |
|
| 1375 |
{ |
| 1376 |
int oldMapK=map_k; |
| 1377 |
map_k=13; |
| 1378 |
removeCommonMicrobes(in1z, in2z, out1z, out2z, microbeOutFile, microbeStatsFile, inPrefix, outPrefix, ref, step, aggressiveMicrobeFlag); |
| 1379 |
map_k=oldMapK; |
| 1380 |
} |
| 1381 |
|
| 1382 |
if(in2!=null && out2==null){ |
| 1383 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1384 |
FASTQ.TEST_INTERLEAVED=false; |
| 1385 |
} |
| 1386 |
|
| 1387 |
if(step>1){ |
| 1388 |
delete(inPrefix, out1z, out2z); |
| 1389 |
} |
| 1390 |
Data.unloadAll(); |
| 1391 |
Shared.printMemory(); |
| 1392 |
} |
| 1393 |
|
| 1394 |
if(otherMicrobeFlag){ |
| 1395 |
|
| 1396 |
inPrefix=outPrefix; |
| 1397 |
final String in1z, in2z; |
| 1398 |
if(step==1){ |
| 1399 |
in1z=in1; in2z=in2; |
| 1400 |
}else if(step<numSteps){ |
| 1401 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1402 |
}else{ |
| 1403 |
inPrefix=null; |
| 1404 |
in1z=outDir+stripDirs(out1); |
| 1405 |
in2z=(out2==null ? null : outDir+stripDirs(out2)); |
| 1406 |
} |
| 1407 |
|
| 1408 |
String ref=otherMicrobesRef; |
| 1409 |
|
| 1410 |
detectCommonMicrobes(in1z, in2z, microbeStats2File, inPrefix, ref, aggressiveMicrobeFlag, otherMicrobesBuild, otherMicrobesRef, otherMicrobesPath); |
| 1411 |
Data.unloadAll(); |
| 1412 |
Shared.printMemory(); |
| 1413 |
} |
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
if(chloroMapFlag || mitoMapFlag || riboMapFlag){ |
| 1418 |
step++; |
| 1419 |
inPrefix=outPrefix; |
| 1420 |
outPrefix=(step<numSteps ? chloroPrefix : null); |
| 1421 |
|
| 1422 |
|
| 1423 |
final String in1z, in2z, out1z, out2z; |
| 1424 |
if(step==1){ |
| 1425 |
in1z=in1; in2z=in2; |
| 1426 |
}else{ |
| 1427 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1428 |
} |
| 1429 |
if(step>=numSteps){ |
| 1430 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1431 |
out1z=out1; out2z=out2; |
| 1432 |
}else{ |
| 1433 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1434 |
} |
| 1435 |
|
| 1436 |
|
| 1437 |
if(chloroMapFlag && taxList!=null){ |
| 1438 |
boolean foundPlant=false; |
| 1439 |
TaxTree tree=TaxTree.loadTaxTree(taxTreeFile, outstream, true, false); |
| 1440 |
TaxNode plant=tree.getNodeByName("Viridiplantae"); |
| 1441 |
for(String s : taxList.split(",")){ |
| 1442 |
TaxNode tn=tree.parseNodeFromHeader(s, true); |
| 1443 |
if(tn!=null && (tree.commonAncestor(plant, tn)==plant || tree.commonAncestor(plant, tn)==tn)){ |
| 1444 |
foundPlant=true; |
| 1445 |
break; |
| 1446 |
} |
| 1447 |
} |
| 1448 |
if(!foundPlant){ |
| 1449 |
outstream.println("Disabled chloroMapFlag because organism is not a plant."); |
| 1450 |
chloroMapFlag=false; |
| 1451 |
} |
| 1452 |
} |
| 1453 |
|
| 1454 |
|
| 1455 |
final String ref0; |
| 1456 |
if(chloroMapFlag){ |
| 1457 |
if(mitoMapFlag && riboMapFlag){ref0=chloroMitoRiboRef;} |
| 1458 |
else if(mitoMapFlag){ref0=chloroMitoRef;} |
| 1459 |
else if(riboMapFlag){ref0=chloroRiboRef;} |
| 1460 |
else{ref0=chloroplastRef;} |
| 1461 |
}else if(mitoMapFlag){ |
| 1462 |
if(riboMapFlag){ref0=mitoRiboRef;} |
| 1463 |
else{ref0=mitoRef;} |
| 1464 |
}else{ |
| 1465 |
ref0=riboRef; |
| 1466 |
} |
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
String ref; |
| 1471 |
{ |
| 1472 |
ArrayList<String> refList=new ArrayList<String>(3); |
| 1473 |
if(chloroMapFlag){refList.add(chloroplastRef);} |
| 1474 |
if(mitoMapFlag){refList.add(mitoRef);} |
| 1475 |
if(riboMapFlag){refList.add(riboRef);} |
| 1476 |
ref=taxFilterList(refList, "chloroMitoRiboRef.fa.gz", true, true, "species"); |
| 1477 |
if(ref!=null){ |
| 1478 |
File f=new File(ref); |
| 1479 |
if(!f.exists() || f.length()<200){ |
| 1480 |
outstream.println("Can't find chloroplast/mito/ribo for taxa; using full dataset."); |
| 1481 |
ref=ref0; |
| 1482 |
} |
| 1483 |
}else{ref=ref0;} |
| 1484 |
} |
| 1485 |
|
| 1486 |
{ |
| 1487 |
final boolean addToOtherStats=(chloroStatsFile==null); |
| 1488 |
decontamByMapping(in1z, in2z, out1z, out2z, chloroOutFile, chloroStatsFile, inPrefix, outPrefix, ref, step, addToOtherStats, null); |
| 1489 |
if(!addToOtherStats){ |
| 1490 |
filterstats.parseChloro(chloroStatsFile); |
| 1491 |
assert(filterstats.toString()!=null); |
| 1492 |
} |
| 1493 |
} |
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
if(!ref0.equals(ref)){ |
| 1498 |
delete(null, ref); |
| 1499 |
} |
| 1500 |
Data.unloadAll(); |
| 1501 |
Shared.printMemory(); |
| 1502 |
|
| 1503 |
if(in2!=null && out2==null){ |
| 1504 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1505 |
FASTQ.TEST_INTERLEAVED=false; |
| 1506 |
} |
| 1507 |
|
| 1508 |
if(step>1){ |
| 1509 |
delete(inPrefix, out1z, out2z); |
| 1510 |
} |
| 1511 |
} |
| 1512 |
|
| 1513 |
|
| 1514 |
if(humanFlag || mouseCatDogHumanFlag){ |
| 1515 |
step++; |
| 1516 |
inPrefix=outPrefix; |
| 1517 |
outPrefix=(step<numSteps ? humanPrefix : null); |
| 1518 |
|
| 1519 |
|
| 1520 |
final String in1z, in2z, out1z, out2z; |
| 1521 |
if(step==1){ |
| 1522 |
in1z=in1; in2z=in2; |
| 1523 |
}else{ |
| 1524 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1525 |
} |
| 1526 |
if(step>=numSteps){ |
| 1527 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1528 |
out1z=out1; out2z=out2; |
| 1529 |
}else{ |
| 1530 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1531 |
} |
| 1532 |
|
| 1533 |
dehumanize(in1z, in2z, out1z, out2z, humanOutFile, inPrefix, outPrefix, step, mouseCatDogHumanFlag, aggressiveHumanFlag, lastReadsObserved); |
| 1534 |
|
| 1535 |
if(in2!=null && out2==null){ |
| 1536 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1537 |
FASTQ.TEST_INTERLEAVED=false; |
| 1538 |
} |
| 1539 |
|
| 1540 |
Data.unloadAll(); |
| 1541 |
Shared.printMemory(); |
| 1542 |
if(step>1){ |
| 1543 |
delete(inPrefix, out1z, out2z); |
| 1544 |
} |
| 1545 |
} |
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
if(mappingRefs.size()>0){ |
| 1550 |
for(int i=0; i<mappingRefs.size(); i++){ |
| 1551 |
step++; |
| 1552 |
inPrefix=outPrefix; |
| 1553 |
outPrefix=(step<numSteps ? mappingPrefix[i] : null); |
| 1554 |
|
| 1555 |
|
| 1556 |
final String in1z, in2z, out1z, out2z; |
| 1557 |
if(step==1){ |
| 1558 |
in1z=in1; in2z=in2; |
| 1559 |
}else{ |
| 1560 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1561 |
} |
| 1562 |
if(step>=numSteps){ |
| 1563 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1564 |
out1z=out1; out2z=out2; |
| 1565 |
}else{ |
| 1566 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1567 |
} |
| 1568 |
|
| 1569 |
decontamByMapping(in1z, in2z, out1z, out2z, null, null, inPrefix, outPrefix, mappingRefs.get(i), step, true, null); |
| 1570 |
|
| 1571 |
if(in2!=null && out2==null){ |
| 1572 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1573 |
FASTQ.TEST_INTERLEAVED=false; |
| 1574 |
} |
| 1575 |
|
| 1576 |
Data.unloadAll(); |
| 1577 |
Shared.printMemory(); |
| 1578 |
if(step>1){ |
| 1579 |
delete(inPrefix, out1z, out2z); |
| 1580 |
} |
| 1581 |
} |
| 1582 |
} |
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
if(doNexteraLMP){ |
| 1587 |
step++; |
| 1588 |
inPrefix=outPrefix; |
| 1589 |
outPrefix=null; |
| 1590 |
|
| 1591 |
|
| 1592 |
final String in1z, in2z, out1z, out2z; |
| 1593 |
if(step==1){ |
| 1594 |
in1z=in1; in2z=in2; |
| 1595 |
}else{ |
| 1596 |
in1z=stripDirs(out1); in2z=stripDirs(out2); |
| 1597 |
} |
| 1598 |
|
| 1599 |
if(step>=numSteps){ |
| 1600 |
ReadWrite.ZIPLEVEL=Tools.max(ReadWrite.ZIPLEVEL, 9); |
| 1601 |
out1z=out1; out2z=out2; |
| 1602 |
}else{ |
| 1603 |
out1z=stripDirs(out1); out2z=stripDirs(out2); |
| 1604 |
} |
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
if(doMerge){merge(in1z, in2z, inPrefix);} |
| 1609 |
|
| 1610 |
splitNextera(in1z, in2z, inPrefix, outPrefix, step); |
| 1611 |
|
| 1612 |
if(in2!=null && out2==null){ |
| 1613 |
FASTQ.FORCE_INTERLEAVED=true; |
| 1614 |
FASTQ.TEST_INTERLEAVED=false; |
| 1615 |
} |
| 1616 |
|
| 1617 |
Data.unloadAll(); |
| 1618 |
Shared.printMemory(); |
| 1619 |
if(step>1){ |
| 1620 |
delete(inPrefix, out1z, out2z); |
| 1621 |
} |
| 1622 |
}else{ |
| 1623 |
if(doMerge){ |
| 1624 |
if(step==0){ |
| 1625 |
merge(in1, in2, null); |
| 1626 |
}else{ |
| 1627 |
merge(out1, out2, null); |
| 1628 |
} |
| 1629 |
} |
| 1630 |
if(doKhist){ |
| 1631 |
if(step==0){ |
| 1632 |
khist(in1, in2, null); |
| 1633 |
}else{ |
| 1634 |
khist(out1, out2, null); |
| 1635 |
} |
| 1636 |
} |
| 1637 |
} |
| 1638 |
} |
| 1639 |
|
| 1640 |
if(doMerge){ |
| 1641 |
BBDuk.putRqc("outputReads", BBMerge.readsProcessedTotal*2, true, false); |
| 1642 |
BBDuk.putRqc("outputBases", BBMerge.basesProcessedTotal, true, false); |
| 1643 |
} |
| 1644 |
|
| 1645 |
|
| 1646 |
if(rqcStatsName!=null){ |
| 1647 |
final TextStreamWriter tsw=new TextStreamWriter(rqcStatsName, overwrite, false, false); |
| 1648 |
tsw.start(); |
| 1649 |
tsw.println(BBDuk.rqcString()); |
| 1650 |
tsw.println("gcPolymerRatio="+Tools.format("%.6f", filterstats.gcPolymerRatio)); |
| 1651 |
tsw.poisonAndWait(); |
| 1652 |
} |
| 1653 |
|
| 1654 |
|
| 1655 |
if(rqcStatsName2!=null){ |
| 1656 |
String s=filterstats.toString(); |
| 1657 |
ReadWrite.writeString(s, rqcStatsName2, false); |
| 1658 |
} |
| 1659 |
|
| 1660 |
|
| 1661 |
if(logName!=null){ |
| 1662 |
log("RQCFilter complete", true); |
| 1663 |
if(logName.endsWith(".tmp")){ |
| 1664 |
String old=logName; |
| 1665 |
logName=logName.substring(0, logName.length()-4); |
| 1666 |
new File(old).renameTo(new File(logName)); |
| 1667 |
} |
| 1668 |
} |
| 1669 |
|
| 1670 |
if(doneFile!=null){ |
| 1671 |
Date d=new Date(); |
| 1672 |
ReadWrite.writeString(in1+"\n"+d+"\n"+d.getTime(), doneFile); |
| 1673 |
} |
| 1674 |
} |
| 1675 |
|
| 1676 |
private boolean discoverAdapters(String in1, String in2, String outa){ |
| 1677 |
log("findAdapters start", true); |
| 1678 |
|
| 1679 |
ArrayList<String> argList=new ArrayList<String>(); |
| 1680 |
|
| 1681 |
{ |
| 1682 |
argList.add("overwrite="+overwrite); |
| 1683 |
|
| 1684 |
|
| 1685 |
if(in1!=null){argList.add("in1="+in1);} |
| 1686 |
if(in2!=null){argList.add("in2="+in2);} |
| 1687 |
if(outa!=null){argList.add("outa="+outa);} |
| 1688 |
argList.add("reads=1m"); |
| 1689 |
} |
| 1690 |
|
| 1691 |
String[] mergeargs=argList.toArray(new String[0]); |
| 1692 |
|
| 1693 |
if(reproduceName!=null){ |
| 1694 |
writeReproduceFile(reproduceName, "bbmerge.sh", mergeargs); |
| 1695 |
} |
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
boolean success=false; |
| 1700 |
if(!dryrun){ |
| 1701 |
final boolean OLD_FORCE_INT=FASTQ.FORCE_INTERLEAVED, OLD_TEST_INT=FASTQ.TEST_INTERLEAVED; |
| 1702 |
BBMerge merger=new BBMerge(mergeargs); |
| 1703 |
|
| 1704 |
|
| 1705 |
try { |
| 1706 |
merger.process(); |
| 1707 |
FASTQ.FORCE_INTERLEAVED=OLD_FORCE_INT; |
| 1708 |
FASTQ.TEST_INTERLEAVED=OLD_TEST_INT; |
| 1709 |
|
| 1710 |
long merged=merger.correctCountTotal+merger.incorrectCountTotal; |
| 1711 |
if(outa!=null && merged>=5000){ |
| 1712 |
ArrayList<Read> list=ReadInputStream.toReads(outa, FileFormat.FA, -1); |
| 1713 |
if(list!=null && list.size()>=2){ |
| 1714 |
success=true; |
| 1715 |
for(int rnum=0; rnum<2 && success; rnum++){ |
| 1716 |
Read r=list.get(rnum); |
| 1717 |
if(r.length()<trim_k){ |
| 1718 |
|
| 1719 |
success=false; break; |
| 1720 |
} |
| 1721 |
for(int i=0; i<trim_k && success; i++){ |
| 1722 |
if(!AminoAcid.isFullyDefined(r.bases[i])){ |
| 1723 |
|
| 1724 |
success=false; break; |
| 1725 |
} |
| 1726 |
} |
| 1727 |
} |
| 1728 |
}else{ |
| 1729 |
|
| 1730 |
} |
| 1731 |
}else{ |
| 1732 |
|
| 1733 |
} |
| 1734 |
} catch (Exception e) { |
| 1735 |
e.printStackTrace(); |
| 1736 |
log("failed", true); |
| 1737 |
System.exit(1); |
| 1738 |
} |
| 1739 |
FASTQ.FORCE_INTERLEAVED=OLD_FORCE_INT; |
| 1740 |
FASTQ.TEST_INTERLEAVED=OLD_TEST_INT; |
| 1741 |
} |
| 1742 |
|
| 1743 |
discoveredAdaptersValid=success; |
| 1744 |
|
| 1745 |
log("findAdapters finish", true); |
| 1746 |
return success; |
| 1747 |
} |
| 1748 |
|
| 1749 |
|
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
private void clumpify(String in1, String in2, String out1, String out2, String inPrefix, String outPrefix, int stepNum){ |
| 1761 |
|
| 1762 |
log("clumpify start", true); |
| 1763 |
|
| 1764 |
ArrayList<String> argList=new ArrayList<String>(); |
| 1765 |
|
| 1766 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 1767 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 1768 |
|
| 1769 |
{ |
| 1770 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 1771 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 1772 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 1773 |
argList.add("reorder"); |
| 1774 |
|
| 1775 |
|
| 1776 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 1777 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 1778 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 1779 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 1780 |
|
| 1781 |
|
| 1782 |
if(removeDuplicates){argList.add("dedupe");} |
| 1783 |
if(removeAllDuplicates){argList.add("allduplicates");} |
| 1784 |
if(removeOpticalDuplicates || removeEdgeDuplicates){argList.add("optical");} |
| 1785 |
if(removeEdgeDuplicates){argList.add("spany"); argList.add("adjacent");} |
| 1786 |
if(duplicateSubs>=0){argList.add("dsubs="+duplicateSubs);} |
| 1787 |
if(duplicateDist>=0){argList.add("ddist="+duplicateDist);} |
| 1788 |
if(duplicatePasses>0){argList.add("passes="+duplicatePasses);} |
| 1789 |
if(lowComplexity){argList.add("lowcomplexity="+lowComplexity);} |
| 1790 |
if(clumpifyGroups>0){argList.add("groups="+clumpifyGroups);} |
| 1791 |
if(clumpifyTmpdir){argList.add("usetmpdir="+clumpifyTmpdir);} |
| 1792 |
} |
| 1793 |
|
| 1794 |
String[] args=argList.toArray(new String[0]); |
| 1795 |
|
| 1796 |
if(reproduceName!=null){ |
| 1797 |
writeReproduceFile(reproduceName, "clumpify.sh", args); |
| 1798 |
} |
| 1799 |
|
| 1800 |
if(!dryrun){ |
| 1801 |
Clumpify c=new Clumpify(args); |
| 1802 |
try { |
| 1803 |
c.process(new Timer()); |
| 1804 |
assert(KmerSort.lastReadsOut<=KmerSort.lastReadsIn) : KmerSort.lastReadsIn+", "+KmerSort.lastBasesIn+", "+KmerSort.lastReadsOut+", "+KmerSort.lastBasesOut; |
| 1805 |
assert(KmerSort.lastBasesOut<=KmerSort.lastBasesIn) : KmerSort.lastReadsIn+", "+KmerSort.lastBasesIn+", "+KmerSort.lastReadsOut+", "+KmerSort.lastBasesOut; |
| 1806 |
assert(KmerSort.lastBasesOut>=KmerSort.lastReadsOut) : KmerSort.lastReadsIn+", "+KmerSort.lastBasesIn+", "+KmerSort.lastReadsOut+", "+KmerSort.lastBasesOut; |
| 1807 |
assert(KmerSort.lastBasesIn>=KmerSort.lastReadsIn) : KmerSort.lastReadsIn+", "+KmerSort.lastBasesIn+", "+KmerSort.lastReadsOut+", "+KmerSort.lastBasesOut; |
| 1808 |
assert(KmerSort.lastReadsOut>=0); |
| 1809 |
assert(KmerSort.lastBasesOut>=0); |
| 1810 |
assert(KmerSort.lastReadsOut>0 || KmerSort.lastReadsIn==0); |
| 1811 |
assert(KmerSort.lastBasesOut>0 || KmerSort.lastBasesIn==0); |
| 1812 |
if(filterstats.readsIn<1){ |
| 1813 |
filterstats.readsIn=KmerSort.lastReadsIn; |
| 1814 |
filterstats.basesIn=KmerSort.lastBasesIn; |
| 1815 |
} |
| 1816 |
filterstats.readsOut=KmerSort.lastReadsOut; |
| 1817 |
filterstats.basesOut=KmerSort.lastBasesOut; |
| 1818 |
filterstats.readsDuplicate=KmerSort.lastReadsIn-KmerSort.lastReadsOut; |
| 1819 |
filterstats.basesDuplicate=KmerSort.lastBasesIn-KmerSort.lastBasesOut; |
| 1820 |
|
| 1821 |
assert(filterstats.toString()!=null); |
| 1822 |
|
| 1823 |
|
| 1824 |
} catch (Exception e) { |
| 1825 |
e.printStackTrace(); |
| 1826 |
log("failed", true); |
| 1827 |
System.exit(1); |
| 1828 |
} |
| 1829 |
} |
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
log("clumpify finish", true); |
| 1834 |
} |
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
private void calcTrueQuality(String sam){ |
| 1841 |
Data.setPath("."); |
| 1842 |
|
| 1843 |
log("calcTrueQuality start", true); |
| 1844 |
|
| 1845 |
String[] args=new String[] {"in="+sam, "ref=phix", "callvars", "usetiles"}; |
| 1846 |
|
| 1847 |
if(reproduceName!=null){ |
| 1848 |
writeReproduceFile(reproduceName, "calctruequality.sh", args); |
| 1849 |
} |
| 1850 |
|
| 1851 |
if(!dryrun){ |
| 1852 |
CalcTrueQuality ctq=new CalcTrueQuality(args); |
| 1853 |
try { |
| 1854 |
ctq.process(); |
| 1855 |
} catch (Exception e) { |
| 1856 |
e.printStackTrace(); |
| 1857 |
log("failed", true); |
| 1858 |
System.exit(1); |
| 1859 |
} |
| 1860 |
Shared.TRIM_READ_COMMENTS=Shared.TRIM_RNAME=false; |
| 1861 |
} |
| 1862 |
|
| 1863 |
log("calcTrueQuality finish", true); |
| 1864 |
} |
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
private void recalibrate(String in1, String in2, String out1, String out2, |
| 1877 |
String inPrefix, String outPrefix, int stepNum){ |
| 1878 |
log("recalibrate start", true); |
| 1879 |
|
| 1880 |
ArrayList<String> argList=new ArrayList<String>(); |
| 1881 |
|
| 1882 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 1883 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 1884 |
|
| 1885 |
{ |
| 1886 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 1887 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 1888 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 1889 |
if(ordered){argList.add("ordered");} |
| 1890 |
if(overwrite) {argList.add("ow");} |
| 1891 |
argList.add("usetiles"); |
| 1892 |
|
| 1893 |
|
| 1894 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 1895 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 1896 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 1897 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 1898 |
} |
| 1899 |
|
| 1900 |
String[] args=argList.toArray(new String[0]); |
| 1901 |
|
| 1902 |
if(reproduceName!=null){ |
| 1903 |
writeReproduceFile(reproduceName, "bbduk.sh", args); |
| 1904 |
} |
| 1905 |
|
| 1906 |
if(!dryrun){ |
| 1907 |
BBDuk duk=new BBDuk(args); |
| 1908 |
try { |
| 1909 |
duk.process(); |
| 1910 |
} catch (Exception e) { |
| 1911 |
e.printStackTrace(); |
| 1912 |
log("failed", true); |
| 1913 |
System.exit(1); |
| 1914 |
} |
| 1915 |
} |
| 1916 |
CalcTrueQuality.unloadMatrices(); |
| 1917 |
log("recalibrate finish", true); |
| 1918 |
} |
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
private void filterByTile(String in1, String in2, String out1, String out2, |
| 1933 |
String outbad, String tiledump, String inPrefix, String outPrefix, int stepNum){ |
| 1934 |
|
| 1935 |
log("filterByTile start", true); |
| 1936 |
|
| 1937 |
ArrayList<String> argList=new ArrayList<String>(); |
| 1938 |
|
| 1939 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 1940 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 1941 |
|
| 1942 |
{ |
| 1943 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 1944 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 1945 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 1946 |
if(overwrite) {argList.add("ow");} |
| 1947 |
|
| 1948 |
|
| 1949 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 1950 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 1951 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 1952 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 1953 |
if(outbad!=null){argList.add("outb="+outbad);} |
| 1954 |
if(tiledump!=null){argList.add("dumpin="+tiledump);} |
| 1955 |
} |
| 1956 |
|
| 1957 |
String[] args=argList.toArray(new String[0]); |
| 1958 |
|
| 1959 |
if(reproduceName!=null){ |
| 1960 |
writeReproduceFile(reproduceName, "filterbytile.sh", args); |
| 1961 |
} |
| 1962 |
|
| 1963 |
if(!dryrun){ |
| 1964 |
AnalyzeFlowCell afc=new AnalyzeFlowCell(args); |
| 1965 |
try { |
| 1966 |
afc.process(new Timer()); |
| 1967 |
filterstats.readsLowQuality+=afc.readsDiscarded; |
| 1968 |
filterstats.basesLowQuality+=afc.basesDiscarded; |
| 1969 |
if(filterstats.readsIn<1){ |
| 1970 |
filterstats.readsIn=afc.readsProcessed; |
| 1971 |
filterstats.basesIn=afc.basesProcessed; |
| 1972 |
} |
| 1973 |
filterstats.readsOut=afc.readsProcessed-afc.readsDiscarded; |
| 1974 |
filterstats.basesOut=afc.basesProcessed-afc.basesDiscarded; |
| 1975 |
|
| 1976 |
assert(filterstats.toString()!=null); |
| 1977 |
} catch (Exception e) { |
| 1978 |
e.printStackTrace(); |
| 1979 |
log("failed", true); |
| 1980 |
System.exit(1); |
| 1981 |
} |
| 1982 |
} |
| 1983 |
|
| 1984 |
|
| 1985 |
|
| 1986 |
log("filterByTile finish", true); |
| 1987 |
} |
| 1988 |
|
| 1989 |
|
| 1990 |
|
| 1991 |
|
| 1992 |
|
| 1993 |
|
| 1994 |
|
| 1995 |
|
| 1996 |
|
| 1997 |
|
| 1998 |
|
| 1999 |
|
| 2000 |
|
| 2001 |
private void ktrim(String in1, String in2, String out1, String out2, String inPrefix, String outPrefix, int stepNum){ |
| 2002 |
|
| 2003 |
log("ktrim start", true); |
| 2004 |
ktrimFlag=true; |
| 2005 |
|
| 2006 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2007 |
|
| 2008 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2009 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2010 |
|
| 2011 |
{ |
| 2012 |
argList.add("ktrim="+(ktrim==null ? "f" : ktrim)); |
| 2013 |
if(ordered){argList.add("ordered");} |
| 2014 |
if(minLen>0){argList.add("minlen="+minLen);} |
| 2015 |
if(minLenFraction>0){argList.add("minlenfraction="+minLenFraction);} |
| 2016 |
if((libType!=CLIP)){ |
| 2017 |
argList.add("mink="+mink); |
| 2018 |
if(libType==FRAG && ("r".equalsIgnoreCase(ktrim) || "right".equalsIgnoreCase(ktrim))){ |
| 2019 |
if(tboFlag){argList.add("tbo");} |
| 2020 |
if(tpeFlag){argList.add("tpe");} |
| 2021 |
} |
| 2022 |
argList.add("rcomp=f"); |
| 2023 |
argList.add("overwrite="+overwrite); |
| 2024 |
argList.add("k="+trim_k); |
| 2025 |
argList.add("hdist="+hdist_trim); |
| 2026 |
if(hdist2_trim>=0){ |
| 2027 |
argList.add("hdist2="+hdist2_trim); |
| 2028 |
} |
| 2029 |
if(forceTrimModulo>0){ |
| 2030 |
argList.add("ftm="+forceTrimModulo); |
| 2031 |
} |
| 2032 |
|
| 2033 |
argList.add("pratio=G,C"); |
| 2034 |
argList.add("plen=20"); |
| 2035 |
if(phistName!=null){argList.add("phist="+phistName);} |
| 2036 |
if(qhistName!=null){argList.add("qhist="+qhistName);} |
| 2037 |
if(bhistName!=null){argList.add("bhist="+bhistName);} |
| 2038 |
if(gchistName!=null){argList.add("gchist="+gchistName);} |
| 2039 |
} |
| 2040 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2041 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2042 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2043 |
|
| 2044 |
|
| 2045 |
for(String s : primaryArgList){argList.add(s);} |
| 2046 |
|
| 2047 |
|
| 2048 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2049 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2050 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 2051 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 2052 |
|
| 2053 |
|
| 2054 |
if(rqcStatsName!=null){argList.add("rqc=hashmap");} |
| 2055 |
if(kmerStatsName_kt!=null){argList.add("outduk="+kmerStatsName_kt);} |
| 2056 |
if(scaffoldStatsName_kt!=null){argList.add("stats="+scaffoldStatsName_kt);} |
| 2057 |
|
| 2058 |
if(copyUndefined){argList.add("cu");} |
| 2059 |
|
| 2060 |
argList.add("loglog"); |
| 2061 |
argList.add("loglogout"); |
| 2062 |
} |
| 2063 |
|
| 2064 |
{ |
| 2065 |
ArrayList<String> refs=new ArrayList<String>(); |
| 2066 |
|
| 2067 |
if(libType==FRAG){ |
| 2068 |
if(discoveredAdaptersValid){argList.add("adapters="+adaptersOutFile);} |
| 2069 |
else{ |
| 2070 |
if(fragAdapterFlag){refs.add(fragAdapter);} |
| 2071 |
if(rnaAdapterFlag){refs.add(rnaAdapter);} |
| 2072 |
} |
| 2073 |
}else if(libType==LFPE){ |
| 2074 |
refs.add(lfpeLinker); |
| 2075 |
}else if(libType==CLIP){ |
| 2076 |
|
| 2077 |
if(clipLinker!=null){ |
| 2078 |
argList.add("literal="+clipLinker); |
| 2079 |
{ |
| 2080 |
String[] split=clipLinker.split(","); |
| 2081 |
int min=split[0].length(); |
| 2082 |
for(String s : split){min=Tools.min(min, s.length());} |
| 2083 |
argList.add("k="+min); |
| 2084 |
argList.add("mink=-1"); |
| 2085 |
argList.add("mm=f"); |
| 2086 |
argList.add("hdist=0"); |
| 2087 |
argList.add("edist=0"); |
| 2088 |
argList.add("ktrimexclusive=t"); |
| 2089 |
} |
| 2090 |
}else{ |
| 2091 |
throw new RuntimeException("Null clip linker."); |
| 2092 |
} |
| 2093 |
}else if(libType==CLRS){ |
| 2094 |
refs.add(clrsLinker); |
| 2095 |
}else{ |
| 2096 |
throw new RuntimeException("Unknown library type."); |
| 2097 |
} |
| 2098 |
|
| 2099 |
StringBuilder refstring=new StringBuilder(); |
| 2100 |
for(String ref : refs){ |
| 2101 |
if(ref!=null){ |
| 2102 |
refstring.append(refstring.length()==0 ? "ref=" : ","); |
| 2103 |
refstring.append(ref); |
| 2104 |
} |
| 2105 |
} |
| 2106 |
|
| 2107 |
if(refstring!=null && refstring.length()>0){ |
| 2108 |
argList.add(refstring.toString()); |
| 2109 |
} |
| 2110 |
} |
| 2111 |
|
| 2112 |
String[] dukargs=argList.toArray(new String[0]); |
| 2113 |
|
| 2114 |
if(reproduceName!=null){ |
| 2115 |
writeReproduceFile(reproduceName, "bbduk.sh", dukargs); |
| 2116 |
} |
| 2117 |
|
| 2118 |
if(!dryrun){ |
| 2119 |
BBDuk duk=new BBDuk(dukargs); |
| 2120 |
try { |
| 2121 |
duk.process(); |
| 2122 |
outstream.println(format("Adapter Sequence Removed:", duk.readsIn, duk.readsOut, duk.basesIn, duk.basesOut)); |
| 2123 |
log("#Input:\t"+duk.readsIn+" reads\t"+duk.basesIn+" bases\t"+duk.loglogIn.cardinality()+" kmers", true, false); |
| 2124 |
log("#Remaining:\t"+duk.readsOut+" reads\t"+duk.basesOut+" bases\t"+duk.loglogOut.cardinality()+" kmers", true, false); |
| 2125 |
if(duk.errorState){throw new Exception("BBDuk did not finish successfully; see above for the error message.");} |
| 2126 |
|
| 2127 |
filterstats.readsFTrimmed=duk.readsFTrimmed; |
| 2128 |
filterstats.basesFTrimmed=duk.basesFTrimmed; |
| 2129 |
|
| 2130 |
filterstats.readsAdapter=duk.readsIn-duk.readsOut; |
| 2131 |
filterstats.basesAdapter=duk.basesIn-duk.basesOut-duk.basesFTrimmed; |
| 2132 |
if(filterstats.readsIn<1){ |
| 2133 |
filterstats.readsIn=duk.readsIn; |
| 2134 |
filterstats.basesIn=duk.basesIn; |
| 2135 |
} |
| 2136 |
filterstats.readsOut=duk.readsOut; |
| 2137 |
filterstats.basesOut=duk.basesOut; |
| 2138 |
|
| 2139 |
filterstats.gcPolymerRatio=duk.getPolymerRatio(); |
| 2140 |
|
| 2141 |
assert(filterstats.toString()!=null); |
| 2142 |
} catch (Exception e) { |
| 2143 |
e.printStackTrace(); |
| 2144 |
log("failed", true); |
| 2145 |
System.exit(1); |
| 2146 |
} |
| 2147 |
} |
| 2148 |
|
| 2149 |
|
| 2150 |
|
| 2151 |
log("ktrim finish", true); |
| 2152 |
} |
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
|
| 2164 |
|
| 2165 |
private void polyfilter(String in1, String in2, String out1, String out2, |
| 2166 |
String inPrefix, String outPrefix, String polymers, int stepNum){ |
| 2167 |
log("polyfilter start", true); |
| 2168 |
|
| 2169 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2170 |
|
| 2171 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2172 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2173 |
|
| 2174 |
{ |
| 2175 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2176 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2177 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2178 |
if(ordered){argList.add("ordered");} |
| 2179 |
if(overwrite) {argList.add("ow");} |
| 2180 |
argList.add("polymers="+polymers); |
| 2181 |
|
| 2182 |
|
| 2183 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2184 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2185 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 2186 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 2187 |
} |
| 2188 |
|
| 2189 |
String[] args=argList.toArray(new String[0]); |
| 2190 |
|
| 2191 |
if(reproduceName!=null){ |
| 2192 |
writeReproduceFile(reproduceName, "polyfilter.sh", args); |
| 2193 |
} |
| 2194 |
|
| 2195 |
if(!dryrun){ |
| 2196 |
PolyFilter x=new PolyFilter(args); |
| 2197 |
try { |
| 2198 |
x.process(new Timer()); |
| 2199 |
filterstats.basesPolyG+=PolyFilter.lastBasesRemoved; |
| 2200 |
filterstats.readsPolyG+=PolyFilter.lastReadsRemoved; |
| 2201 |
filterstats.basesLowQuality+=PolyFilter.lastBasesRemoved; |
| 2202 |
filterstats.readsLowQuality+=PolyFilter.lastReadsRemoved; |
| 2203 |
if(filterstats.readsIn<1){ |
| 2204 |
filterstats.readsIn=x.readsProcessed; |
| 2205 |
filterstats.basesIn=x.basesProcessed; |
| 2206 |
} |
| 2207 |
filterstats.readsOut=x.readsOut; |
| 2208 |
filterstats.basesOut=x.basesOut; |
| 2209 |
} catch (Exception e) { |
| 2210 |
e.printStackTrace(); |
| 2211 |
log("failed", true); |
| 2212 |
System.exit(1); |
| 2213 |
} |
| 2214 |
} |
| 2215 |
log("polyfilter finish", true); |
| 2216 |
} |
| 2217 |
|
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
private void filterSpikein(String in1, String in2, String out1, String out2, String outbad, String inPrefix, String outPrefix, |
| 2230 |
int stepNum){ |
| 2231 |
|
| 2232 |
log("filterSpikein start", true); |
| 2233 |
|
| 2234 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2235 |
|
| 2236 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2237 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2238 |
|
| 2239 |
|
| 2240 |
|
| 2241 |
{ |
| 2242 |
if(ordered){argList.add("ordered");} |
| 2243 |
argList.add("overwrite="+overwrite); |
| 2244 |
argList.add("k="+spikein_k); |
| 2245 |
argList.add("hdist="+hdist_spikein); |
| 2246 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2247 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2248 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2249 |
|
| 2250 |
|
| 2251 |
|
| 2252 |
|
| 2253 |
|
| 2254 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2255 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2256 |
if(out1!=null){argList.add("outu1="+outPre+out1);} |
| 2257 |
if(out2!=null){argList.add("outu2="+outPre+out2);} |
| 2258 |
if(outbad!=null){argList.add("outm="+outbad);} |
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
if(scaffoldStatsNameSpikein!=null){argList.add("stats="+scaffoldStatsNameSpikein);} |
| 2263 |
|
| 2264 |
|
| 2265 |
|
| 2266 |
argList.add("loglog"); |
| 2267 |
argList.add("loglogout"); |
| 2268 |
} |
| 2269 |
|
| 2270 |
{ |
| 2271 |
if(mtstFlag){spikeinRefs.add(mtstRef);} |
| 2272 |
if(kapaFlag){spikeinRefs.add(kapaRef);} |
| 2273 |
|
| 2274 |
if(spikeinRefs.isEmpty()){assert(false) : "spikeinFlag is true but there are no spikein references.";} |
| 2275 |
|
| 2276 |
StringBuilder refstring=new StringBuilder(); |
| 2277 |
for(String ref : spikeinRefs){ |
| 2278 |
if(ref!=null){ |
| 2279 |
refstring.append(refstring.length()==0 ? "ref=" : ","); |
| 2280 |
refstring.append(ref); |
| 2281 |
} |
| 2282 |
} |
| 2283 |
|
| 2284 |
if(refstring!=null && refstring.length()>0){ |
| 2285 |
argList.add(refstring.toString()); |
| 2286 |
} |
| 2287 |
} |
| 2288 |
|
| 2289 |
String[] sealargs=argList.toArray(new String[0]); |
| 2290 |
|
| 2291 |
if(reproduceName!=null){ |
| 2292 |
writeReproduceFile(reproduceName, "seal.sh", sealargs); |
| 2293 |
} |
| 2294 |
|
| 2295 |
if(!dryrun){ |
| 2296 |
Seal seal=new Seal(sealargs); |
| 2297 |
try { |
| 2298 |
seal.process(); |
| 2299 |
outstream.println(format("Spikein Sequence Removed:", seal.readsIn, seal.readsIn-seal.readsMatched, seal.basesIn, seal.basesIn-seal.basesMatched)); |
| 2300 |
log("#Input:\t"+seal.readsIn+" reads\t"+seal.basesIn+" bases\t"+seal.loglog.cardinality()+" kmers", true, false); |
| 2301 |
log("#Remaining:\t"+seal.readsUnmatched+" reads\t"+seal.basesUnmatched+" bases\t"+seal.loglogOut.cardinality()+" kmers", true, false); |
| 2302 |
|
| 2303 |
filterstats.readsSpikin=seal.readsMatched; |
| 2304 |
filterstats.basesSpikin=seal.basesMatched; |
| 2305 |
if(filterstats.readsIn<1){ |
| 2306 |
filterstats.readsIn=seal.readsIn; |
| 2307 |
filterstats.basesIn=seal.basesIn; |
| 2308 |
} |
| 2309 |
filterstats.readsOut=seal.readsIn-seal.readsMatched; |
| 2310 |
filterstats.basesOut=seal.basesIn-seal.basesMatched; |
| 2311 |
|
| 2312 |
assert(filterstats.toString()!=null); |
| 2313 |
} catch (Exception e) { |
| 2314 |
e.printStackTrace(); |
| 2315 |
log("failed", true); |
| 2316 |
System.exit(1); |
| 2317 |
} |
| 2318 |
} |
| 2319 |
|
| 2320 |
|
| 2321 |
|
| 2322 |
log("filterSpikein finish", true); |
| 2323 |
} |
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
|
| 2329 |
|
| 2330 |
|
| 2331 |
|
| 2332 |
|
| 2333 |
|
| 2334 |
|
| 2335 |
|
| 2336 |
private void filter1(String in1, String in2, String out1, String out2, String outbad, String inPrefix, String outPrefix, |
| 2337 |
int stepNum){ |
| 2338 |
|
| 2339 |
log("filter start", true); |
| 2340 |
|
| 2341 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2342 |
|
| 2343 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2344 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2345 |
|
| 2346 |
|
| 2347 |
|
| 2348 |
{ |
| 2349 |
if(swiftFlag){argList.add("swift");} |
| 2350 |
if(minAvgQuality>-1){argList.add("maq="+minAvgQuality+","+minAvgQualityBases);} |
| 2351 |
if(qtrim!=null){ |
| 2352 |
argList.add("trimq="+trimq); |
| 2353 |
argList.add("qtrim="+qtrim); |
| 2354 |
} |
| 2355 |
if(ftl>=0){argList.add("ftl="+ftl);} |
| 2356 |
if(ftr>=0){argList.add("ftr="+ftr);} |
| 2357 |
if(ftr2>=0){argList.add("ftr2="+ftr2);} |
| 2358 |
if(pairedToSingle){argList.add("pairedtosingle");} |
| 2359 |
if(ordered){argList.add("ordered");} |
| 2360 |
argList.add("overwrite="+overwrite); |
| 2361 |
if(maxNs>=0){argList.add("maxns="+maxNs);} |
| 2362 |
if(minLen>0){argList.add("minlen="+minLen);} |
| 2363 |
if(minLenFraction>0){argList.add("minlenfraction="+minLenFraction);} |
| 2364 |
argList.add("k="+filter_k); |
| 2365 |
argList.add("hdist="+hdist_filter); |
| 2366 |
if(qhdist_filter>0){argList.add("qhdist="+qhdist_filter);} |
| 2367 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2368 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2369 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2370 |
|
| 2371 |
if(chastityfilter!=null){argList.add("cf="+chastityfilter);} |
| 2372 |
if(failnobarcode!=null){argList.add("failnobarcode="+failnobarcode);} |
| 2373 |
if(barcodefilter!=null){argList.add("barcodefilter="+barcodefilter);} |
| 2374 |
if(barcodes!=null){argList.add("barcodes="+barcodes);} |
| 2375 |
|
| 2376 |
if(entropyFilter && minEntropy>0){ |
| 2377 |
argList.add("minentropy="+minEntropy); |
| 2378 |
argList.add("entropyk="+entropyk); |
| 2379 |
argList.add("entropywindow="+entropywindow); |
| 2380 |
} |
| 2381 |
|
| 2382 |
|
| 2383 |
for(String s : primaryArgList){argList.add(s);} |
| 2384 |
|
| 2385 |
|
| 2386 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2387 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2388 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 2389 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 2390 |
if(outbad!=null){argList.add("outm="+outbad);} |
| 2391 |
|
| 2392 |
|
| 2393 |
if(rqcStatsName!=null){argList.add("rqc=hashmap");} |
| 2394 |
if(kmerStatsName1!=null){argList.add("outduk="+kmerStatsName1);} |
| 2395 |
if(scaffoldStatsName1!=null){argList.add("stats="+scaffoldStatsName1);} |
| 2396 |
|
| 2397 |
if(copyUndefined){argList.add("cu");} |
| 2398 |
|
| 2399 |
if(bisulfite){argList.add("ftr2=1");} |
| 2400 |
if(trimPolyA){argList.add("trimpolya");} |
| 2401 |
|
| 2402 |
if(trimPolyGLeft>0){argList.add("trimpolygleft="+trimPolyGLeft);} |
| 2403 |
if(trimPolyGRight>0){argList.add("trimpolygright="+trimPolyGRight);} |
| 2404 |
if(filterPolyG>0){argList.add("filterpolyg="+filterPolyG);} |
| 2405 |
argList.add("maxnonpoly=2"); |
| 2406 |
|
| 2407 |
argList.add("loglog"); |
| 2408 |
argList.add("loglogout"); |
| 2409 |
} |
| 2410 |
|
| 2411 |
{ |
| 2412 |
bbdukFilterRefs.add(mainArtifactFile); |
| 2413 |
if(!doNexteraLMP){bbdukFilterRefs.add(nexteraLinkerFile);} |
| 2414 |
if(filterPolyA){bbdukFilterRefs.add(polyAFile);} |
| 2415 |
|
| 2416 |
if(phixFlag){bbdukFilterRefs.add(phixRef);} |
| 2417 |
if(lambdaFlag){bbdukFilterRefs.add(lambdaRef);} |
| 2418 |
if(pjetFlag){bbdukFilterRefs.add(pjetRef);} |
| 2419 |
|
| 2420 |
if(libType==FRAG){ |
| 2421 |
|
| 2422 |
}else if(libType==LFPE){ |
| 2423 |
|
| 2424 |
}else if(libType==CLIP){ |
| 2425 |
|
| 2426 |
}else if(libType==CLRS){ |
| 2427 |
|
| 2428 |
}else{ |
| 2429 |
throw new RuntimeException("Unknown library type."); |
| 2430 |
} |
| 2431 |
|
| 2432 |
StringBuilder refstring=new StringBuilder(); |
| 2433 |
for(String ref : bbdukFilterRefs){ |
| 2434 |
if(ref!=null){ |
| 2435 |
refstring.append(refstring.length()==0 ? "ref=" : ","); |
| 2436 |
refstring.append(ref); |
| 2437 |
} |
| 2438 |
} |
| 2439 |
|
| 2440 |
if(refstring!=null && refstring.length()>0){ |
| 2441 |
argList.add(refstring.toString()); |
| 2442 |
} |
| 2443 |
} |
| 2444 |
|
| 2445 |
String[] dukargs=argList.toArray(new String[0]); |
| 2446 |
|
| 2447 |
if(reproduceName!=null){ |
| 2448 |
writeReproduceFile(reproduceName, "bbduk.sh", dukargs); |
| 2449 |
} |
| 2450 |
|
| 2451 |
if(!dryrun){ |
| 2452 |
BBDuk duk=new BBDuk(dukargs); |
| 2453 |
try { |
| 2454 |
duk.process(); |
| 2455 |
outstream.println(format("Synthetic Contam Sequence Removed:", duk.readsIn, duk.readsOut, duk.basesIn, duk.basesOut)); |
| 2456 |
log("#Input:\t"+duk.readsIn+" reads\t"+duk.basesIn+" bases\t"+duk.loglogIn.cardinality()+" kmers", true, false); |
| 2457 |
log("#Remaining:\t"+duk.readsOut+" reads\t"+duk.basesOut+" bases\t"+duk.loglogOut.cardinality()+" kmers", true, false); |
| 2458 |
if(duk.errorState){throw new Exception("BBDuk did not finish successfully; see above for the error message.");} |
| 2459 |
|
| 2460 |
|
| 2461 |
|
| 2462 |
|
| 2463 |
long rRemoved=duk.readsIn-duk.readsOut; |
| 2464 |
long bRemoved=duk.basesIn-duk.basesOut; |
| 2465 |
|
| 2466 |
filterstats.readsArtifact+=duk.readsKFiltered; |
| 2467 |
filterstats.basesArtifact+=duk.basesKFiltered; |
| 2468 |
filterstats.readsPolyG+=duk.readsPolyTrimmed; |
| 2469 |
filterstats.basesPolyG+=duk.basesPolyTrimmed; |
| 2470 |
filterstats.readsLowQuality+=(rRemoved-duk.readsKFiltered); |
| 2471 |
filterstats.basesLowQuality+=(bRemoved-duk.basesKFiltered); |
| 2472 |
filterstats.readsN+=duk.readsNFiltered; |
| 2473 |
filterstats.basesN+=duk.basesNFiltered; |
| 2474 |
if(filterstats.readsIn<1){ |
| 2475 |
filterstats.readsIn=duk.readsIn; |
| 2476 |
filterstats.basesIn=duk.basesIn; |
| 2477 |
} |
| 2478 |
filterstats.readsOut=duk.readsOut; |
| 2479 |
filterstats.basesOut=duk.basesOut; |
| 2480 |
|
| 2481 |
|
| 2482 |
|
| 2483 |
|
| 2484 |
assert(filterstats.toString()!=null); |
| 2485 |
} catch (Exception e) { |
| 2486 |
e.printStackTrace(); |
| 2487 |
log("failed", true); |
| 2488 |
System.exit(1); |
| 2489 |
} |
| 2490 |
} |
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
log("filter finish", true); |
| 2495 |
} |
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
|
| 2501 |
|
| 2502 |
|
| 2503 |
|
| 2504 |
|
| 2505 |
|
| 2506 |
|
| 2507 |
|
| 2508 |
private void filter2(String in1, String in2, String out1, String out2, String outbad, String inPrefix, String outPrefix, |
| 2509 |
int stepNum){ |
| 2510 |
|
| 2511 |
log("short filter start", true); |
| 2512 |
|
| 2513 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2514 |
|
| 2515 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2516 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2517 |
|
| 2518 |
|
| 2519 |
|
| 2520 |
{ |
| 2521 |
if(ordered){argList.add("ordered");} |
| 2522 |
argList.add("overwrite="+overwrite); |
| 2523 |
argList.add("k="+(doNexteraLMP ? 19 : 20)); |
| 2524 |
argList.add("hdist="+hdist_filter); |
| 2525 |
if(qhdist_filter>0){argList.add("qhdist="+qhdist_filter);} |
| 2526 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2527 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2528 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2529 |
|
| 2530 |
if(recalibrate && quantize!=null) { |
| 2531 |
argList.add("quantize="+quantize); |
| 2532 |
} |
| 2533 |
|
| 2534 |
|
| 2535 |
for(String s : primaryArgList){argList.add(s);} |
| 2536 |
|
| 2537 |
|
| 2538 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2539 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2540 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 2541 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 2542 |
if(outbad!=null){argList.add("outm="+outbad);} |
| 2543 |
|
| 2544 |
|
| 2545 |
if(kmerStatsName2!=null){argList.add("outduk="+kmerStatsName2);} |
| 2546 |
if(scaffoldStatsName2!=null){argList.add("stats="+scaffoldStatsName2);} |
| 2547 |
|
| 2548 |
if(copyUndefined){argList.add("cu");} |
| 2549 |
|
| 2550 |
argList.add("loglog"); |
| 2551 |
argList.add("loglogout"); |
| 2552 |
} |
| 2553 |
|
| 2554 |
{ |
| 2555 |
argList.add("ref="+shortArtifactFile+(doNexteraLMP ? "" : ","+shortArtifactFile)); |
| 2556 |
} |
| 2557 |
|
| 2558 |
String[] dukargs=argList.toArray(new String[0]); |
| 2559 |
|
| 2560 |
if(reproduceName!=null){ |
| 2561 |
writeReproduceFile(reproduceName, "bbduk.sh", dukargs); |
| 2562 |
} |
| 2563 |
|
| 2564 |
if(!dryrun){ |
| 2565 |
BBDuk duk=new BBDuk(dukargs); |
| 2566 |
try { |
| 2567 |
duk.process(); |
| 2568 |
outstream.println(format("Short Synthetic Contam Sequence Removed:", duk.readsIn, duk.readsOut, duk.basesIn, duk.basesOut)); |
| 2569 |
log("#Input:\t"+duk.readsIn+" reads\t"+duk.basesIn+" bases\t"+duk.loglogIn.cardinality()+" kmers", true, false); |
| 2570 |
log("#Remaining:\t"+duk.readsOut+" reads\t"+duk.basesOut+" bases\t"+duk.loglogOut.cardinality()+" kmers", true, false); |
| 2571 |
if(duk.errorState){throw new Exception("BBDuk did not finish successfully; see above for the error message.");} |
| 2572 |
|
| 2573 |
long rRemoved=duk.readsIn-duk.readsOut; |
| 2574 |
long bRemoved=duk.basesIn-duk.basesOut; |
| 2575 |
|
| 2576 |
filterstats.readsArtifact+=duk.readsKFiltered; |
| 2577 |
filterstats.basesArtifact+=duk.basesKFiltered; |
| 2578 |
filterstats.readsLowQuality+=(rRemoved-duk.readsKFiltered); |
| 2579 |
filterstats.basesLowQuality+=(bRemoved-duk.basesKFiltered); |
| 2580 |
filterstats.readsN+=duk.readsNFiltered; |
| 2581 |
filterstats.basesN+=duk.basesNFiltered; |
| 2582 |
if(filterstats.readsIn<1){ |
| 2583 |
filterstats.readsIn=duk.readsIn; |
| 2584 |
filterstats.basesIn=duk.basesIn; |
| 2585 |
} |
| 2586 |
filterstats.readsOut=duk.readsOut; |
| 2587 |
filterstats.basesOut=duk.basesOut; |
| 2588 |
|
| 2589 |
assert(filterstats.toString()!=null); |
| 2590 |
} catch (Exception e) { |
| 2591 |
e.printStackTrace(); |
| 2592 |
log("failed", true); |
| 2593 |
System.exit(1); |
| 2594 |
} |
| 2595 |
} |
| 2596 |
|
| 2597 |
|
| 2598 |
|
| 2599 |
log("short filter finish", true); |
| 2600 |
} |
| 2601 |
|
| 2602 |
|
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
|
| 2607 |
|
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
private void filterRibo(String in1, String in2, String out1, String out2, String outRibo, String inPrefix, String outPrefix, |
| 2615 |
int stepNum){ |
| 2616 |
|
| 2617 |
log("filter ribo start", true); |
| 2618 |
|
| 2619 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2620 |
|
| 2621 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2622 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2623 |
|
| 2624 |
|
| 2625 |
|
| 2626 |
{ |
| 2627 |
if(ordered){argList.add("ordered");} |
| 2628 |
argList.add("k=31"); |
| 2629 |
argList.add("ref="+riboKmers); |
| 2630 |
if(hdist_ribo>0){argList.add("hdist="+hdist_ribo);} |
| 2631 |
if(edist_ribo>0){argList.add("edist="+edist_ribo);} |
| 2632 |
|
| 2633 |
|
| 2634 |
for(String s : primaryArgList){argList.add(s);} |
| 2635 |
|
| 2636 |
|
| 2637 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2638 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2639 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 2640 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 2641 |
if(outRibo!=null){argList.add("outm="+outRibo);} |
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
|
| 2647 |
argList.add("loglog"); |
| 2648 |
argList.add("loglogout"); |
| 2649 |
} |
| 2650 |
|
| 2651 |
String[] dukargs=argList.toArray(new String[0]); |
| 2652 |
|
| 2653 |
if(reproduceName!=null){ |
| 2654 |
writeReproduceFile(reproduceName, "bbduk.sh", dukargs); |
| 2655 |
} |
| 2656 |
|
| 2657 |
if(!dryrun){ |
| 2658 |
BBDuk duk=new BBDuk(dukargs); |
| 2659 |
try { |
| 2660 |
duk.process(); |
| 2661 |
outstream.println(format("Ribosomal Sequence Removed:", duk.readsIn, duk.readsOut, duk.basesIn, duk.basesOut)); |
| 2662 |
log("#Input:\t"+duk.readsIn+" reads\t"+duk.basesIn+" bases\t"+duk.loglogIn.cardinality()+" kmers", true, false); |
| 2663 |
log("#Remaining:\t"+duk.readsOut+" reads\t"+duk.basesOut+" bases\t"+duk.loglogOut.cardinality()+" kmers", true, false); |
| 2664 |
if(duk.errorState){throw new Exception("BBDuk did not finish successfully; see above for the error message.");} |
| 2665 |
|
| 2666 |
filterstats.readsRiboKmer+=duk.readsKFiltered; |
| 2667 |
filterstats.basesRiboKmer+=duk.basesKFiltered; |
| 2668 |
if(filterstats.readsIn<1){ |
| 2669 |
filterstats.readsIn=duk.readsIn; |
| 2670 |
filterstats.basesIn=duk.basesIn; |
| 2671 |
} |
| 2672 |
filterstats.readsOut=duk.readsOut; |
| 2673 |
filterstats.basesOut=duk.basesOut; |
| 2674 |
|
| 2675 |
assert(filterstats.toString()!=null); |
| 2676 |
} catch (Exception e) { |
| 2677 |
e.printStackTrace(); |
| 2678 |
log("failed", true); |
| 2679 |
System.exit(1); |
| 2680 |
} |
| 2681 |
} |
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
log("filter ribo finish", true); |
| 2686 |
} |
| 2687 |
|
| 2688 |
private static String toPercent(long numerator, long denominator){ |
| 2689 |
if(denominator<1){return "0.00%";} |
| 2690 |
return Tools.format("%.2f%%", numerator*100.0/denominator); |
| 2691 |
} |
| 2692 |
|
| 2693 |
private static String format(String prefix, long rin, long rout, long bin, long bout){ |
| 2694 |
long rrmvd=rin-rout; |
| 2695 |
long brmvd=bin-bout; |
| 2696 |
return prefix+"\t"+rrmvd+" reads ("+toPercent(rrmvd, rin)+")\t"+brmvd+" bases ("+toPercent(brmvd, bin)+")"; |
| 2697 |
} |
| 2698 |
|
| 2699 |
|
| 2700 |
|
| 2701 |
|
| 2702 |
|
| 2703 |
|
| 2704 |
|
| 2705 |
|
| 2706 |
|
| 2707 |
|
| 2708 |
private void splitNextera(String in1, String in2, String inPrefix, String outPrefix, int stepNum){ |
| 2709 |
|
| 2710 |
log("splitNextera start", true); |
| 2711 |
splitNexteraFlag=true; |
| 2712 |
|
| 2713 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2714 |
|
| 2715 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2716 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2717 |
|
| 2718 |
final String lmpName, fragName, unknownName, singletonName; |
| 2719 |
final String statsName=outPre+nexteraStats; |
| 2720 |
|
| 2721 |
int dot=rawName.lastIndexOf('.'); |
| 2722 |
if(dot>-1){ |
| 2723 |
lmpName=outPre+rawName.substring(0, dot)+"."+symbols+".lmp"+rawName.substring(dot)+(compress ? ".gz" : ""); |
| 2724 |
fragName=outPre+rawName.substring(0, dot)+"."+symbols+".frag"+rawName.substring(dot)+(compress ? ".gz" : ""); |
| 2725 |
unknownName=outPre+rawName.substring(0, dot)+"."+symbols+".unknown"+rawName.substring(dot)+(compress ? ".gz" : ""); |
| 2726 |
singletonName=outPre+rawName.substring(0, dot)+"."+symbols+".singleton"+rawName.substring(dot)+(compress ? ".gz" : ""); |
| 2727 |
}else{ |
| 2728 |
lmpName=outPre+rawName+"."+symbols+".lmp.fastq"+(compress ? ".gz" : ""); |
| 2729 |
fragName=outPre+rawName+"."+symbols+".frag.fastq"+(compress ? ".gz" : ""); |
| 2730 |
unknownName=outPre+rawName+"."+symbols+".unknown.fastq"+(compress ? ".gz" : ""); |
| 2731 |
singletonName=outPre+rawName+"."+symbols+".singleton.fastq"+(compress ? ".gz" : ""); |
| 2732 |
} |
| 2733 |
|
| 2734 |
{ |
| 2735 |
argList.add("mask"); |
| 2736 |
argList.add("ow="+overwrite); |
| 2737 |
if(minLen>0){argList.add("minlen="+minLen);} |
| 2738 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2739 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2740 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2741 |
|
| 2742 |
|
| 2743 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2744 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2745 |
|
| 2746 |
argList.add("out="+lmpName); |
| 2747 |
argList.add("outu="+unknownName); |
| 2748 |
argList.add("outf="+fragName); |
| 2749 |
argList.add("outs="+singletonName); |
| 2750 |
argList.add("stats="+statsName); |
| 2751 |
} |
| 2752 |
|
| 2753 |
String[] splitargs=argList.toArray(new String[0]); |
| 2754 |
|
| 2755 |
if(reproduceName!=null){ |
| 2756 |
writeReproduceFile(reproduceName, "splitnextera.sh", splitargs); |
| 2757 |
} |
| 2758 |
|
| 2759 |
if(!dryrun){ |
| 2760 |
SplitNexteraLMP split=new SplitNexteraLMP(splitargs); |
| 2761 |
try { |
| 2762 |
split.process(); |
| 2763 |
StringBuilder sb=new StringBuilder(); |
| 2764 |
sb.append("LMP:\t"+split.readsLmp()+" reads\t"+split.basesLmp()+" bases\n"); |
| 2765 |
sb.append("Frag:\t"+split.readsFrag()+" reads\t"+split.basesFrag()+" bases\n"); |
| 2766 |
sb.append("Unknown:\t"+split.readsUnk()+" reads\t"+split.basesUnk()+" bases\n"); |
| 2767 |
sb.append("Single:\t"+split.readsSingle()+" reads\t"+split.basesSingle()+" bases\n"); |
| 2768 |
} catch (Exception e) { |
| 2769 |
e.printStackTrace(); |
| 2770 |
log("failed", true); |
| 2771 |
System.exit(1); |
| 2772 |
} |
| 2773 |
} |
| 2774 |
|
| 2775 |
if(fileListName!=null){ |
| 2776 |
StringBuilder sb=new StringBuilder(); |
| 2777 |
sb.append("lmp="+lmpName).append('\n'); |
| 2778 |
sb.append("frag="+fragName).append('\n'); |
| 2779 |
sb.append("unknown="+unknownName).append('\n'); |
| 2780 |
sb.append("singleton="+singletonName).append('\n'); |
| 2781 |
sb.append("nexterastats="+statsName).append('\n'); |
| 2782 |
|
| 2783 |
if(sb.length()>0){ |
| 2784 |
ReadWrite.writeString(sb, fileListName, true); |
| 2785 |
} |
| 2786 |
} |
| 2787 |
|
| 2788 |
log("splitNextera finish", true); |
| 2789 |
} |
| 2790 |
|
| 2791 |
|
| 2792 |
|
| 2793 |
|
| 2794 |
|
| 2795 |
|
| 2796 |
|
| 2797 |
|
| 2798 |
|
| 2799 |
|
| 2800 |
|
| 2801 |
|
| 2802 |
private void dehumanize(String in1, String in2, String out1, String out2, String outbad, String inPrefix, String outPrefix, |
| 2803 |
int stepNum, boolean mouseCatDogHuman, boolean aggressive, long lastReadsObserved){ |
| 2804 |
|
| 2805 |
log("dehumanize start", true); |
| 2806 |
|
| 2807 |
ArrayList<String> argList=new ArrayList<String>(); |
| 2808 |
|
| 2809 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 2810 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 2811 |
|
| 2812 |
final boolean useBBSplit=mouseCatDogHuman; |
| 2813 |
{ |
| 2814 |
if(deterministic){argList.add("deterministic");} |
| 2815 |
argList.add("ordered="+(ordered && false)); |
| 2816 |
argList.add("k="+map_k); |
| 2817 |
argList.add("idtag=t"); |
| 2818 |
argList.add("usemodulo"); |
| 2819 |
argList.add("printunmappedcount"); |
| 2820 |
argList.add("ow="+overwrite); |
| 2821 |
if(trimUntrim){ |
| 2822 |
argList.add("qtrim=rl"); |
| 2823 |
argList.add("trimq=10"); |
| 2824 |
argList.add("untrim"); |
| 2825 |
} |
| 2826 |
argList.add("kfilter=25"); |
| 2827 |
argList.add("maxsites=1"); |
| 2828 |
argList.add("tipsearch="+0); |
| 2829 |
|
| 2830 |
if(aggressive){ |
| 2831 |
argList.add("minratio=.75"); |
| 2832 |
argList.add("maxindel=8"); |
| 2833 |
argList.add("minhits="+1); |
| 2834 |
argList.add("bw=26"); |
| 2835 |
argList.add("bwr=0.22"); |
| 2836 |
argList.add("build=2"); |
| 2837 |
argList.add("ef=0.02"); |
| 2838 |
}else{ |
| 2839 |
argList.add("minratio=.9"); |
| 2840 |
argList.add("maxindel=3"); |
| 2841 |
argList.add("minhits="+2); |
| 2842 |
argList.add("bw=12"); |
| 2843 |
argList.add("bwr=0.16"); |
| 2844 |
argList.add("fast="+true); |
| 2845 |
argList.add("maxsites2=10"); |
| 2846 |
argList.add("build=1"); |
| 2847 |
argList.add("ef=0.03"); |
| 2848 |
} |
| 2849 |
|
| 2850 |
final int genomes=Tools.max(1, (mouseCatDogHuman ? 4 : 0)+(humanFlag ? 1 : 0)+(dogFlag ? 1 : 0)+(catFlag ? 1 : 0)+(mouseFlag ? 1 : 0)); |
| 2851 |
if(bloomFilter && (dryrun || lastReadsObserved<0 || lastReadsObserved>=minReadsToBloomFilter) && Shared.memAvailableAdvanced()>=(genomes*5000000000L)){ |
| 2852 |
argList.add("bloomfilter"); |
| 2853 |
argList.add("bloomk="+bloomFilterK); |
| 2854 |
argList.add("bloomhashes="+bloomFilterHashes); |
| 2855 |
argList.add("bloomminhits="+bloomFilterMinHits); |
| 2856 |
if(bloomSerial){argList.add("bloomserial");} |
| 2857 |
} |
| 2858 |
|
| 2859 |
if(outbad!=null){argList.add("outm="+outbad);} |
| 2860 |
|
| 2861 |
if(mouseCatDogHuman){ |
| 2862 |
argList.add("path="+mouseCatDogHumanPath); |
| 2863 |
if(refStatsName!=null && useBBSplit){argList.add("refstats="+refStatsName);} |
| 2864 |
}else{ |
| 2865 |
if(humanRef==null){ |
| 2866 |
argList.add("path="+humanPath); |
| 2867 |
}else{ |
| 2868 |
RefToIndex.NODISK=true; |
| 2869 |
argList.add("ref="+humanRef); |
| 2870 |
} |
| 2871 |
} |
| 2872 |
|
| 2873 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 2874 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 2875 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 2876 |
if(useBBSplit){argList.add("forcereadonly");} |
| 2877 |
|
| 2878 |
|
| 2879 |
|
| 2880 |
|
| 2881 |
|
| 2882 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 2883 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 2884 |
if(keepHumanReads){ |
| 2885 |
if(out1!=null){argList.add("out1="+outPre+out1);} |
| 2886 |
if(out2!=null){argList.add("out2="+outPre+out2);} |
| 2887 |
}else{ |
| 2888 |
if(out1!=null){argList.add("outu1="+outPre+out1);} |
| 2889 |
if(out2!=null){argList.add("outu2="+outPre+out2);} |
| 2890 |
} |
| 2891 |
|
| 2892 |
} |
| 2893 |
|
| 2894 |
String[] args=argList.toArray(new String[0]); |
| 2895 |
|
| 2896 |
if(!dryrun){ |
| 2897 |
try { |
| 2898 |
if(useBBSplit){ |
| 2899 |
|
| 2900 |
BBSplitter.main(args); |
| 2901 |
RefToIndex.FORCE_READ_ONLY=false; |
| 2902 |
}else{ |
| 2903 |
BBMap.main(args); |
| 2904 |
} |
| 2905 |
|
| 2906 |
|
| 2907 |
|
| 2908 |
|
| 2909 |
final long lastReadsIn=BBMap.lastReadsIn; |
| 2910 |
final long lastEitherMapped=BBMap.lastEitherMapped; |
| 2911 |
final long lastReadsOut=lastReadsIn-lastEitherMapped; |
| 2912 |
|
| 2913 |
|
| 2914 |
final long lastBasesIn=BBMap.lastBasesIn; |
| 2915 |
final long lastEitherMappedBases=BBMap.lastEitherMappedBases; |
| 2916 |
final long lastBasesOut=lastBasesIn-lastEitherMappedBases; |
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
|
| 2926 |
|
| 2927 |
|
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
|
| 2933 |
|
| 2934 |
if(filterstats.readsIn>0){ |
| 2935 |
assert(lastReadsIn==filterstats.readsOut) : lastReadsIn+", "+filterstats.readsOut; |
| 2936 |
assert(lastBasesIn==filterstats.basesOut) : lastBasesIn+", "+filterstats.basesOut; |
| 2937 |
} |
| 2938 |
|
| 2939 |
|
| 2940 |
|
| 2941 |
|
| 2942 |
|
| 2943 |
|
| 2944 |
|
| 2945 |
|
| 2946 |
|
| 2947 |
if(refStatsName!=null && useBBSplit){ |
| 2948 |
filterstats.parseHuman(refStatsName); |
| 2949 |
}else{ |
| 2950 |
filterstats.readsHuman=lastEitherMapped; |
| 2951 |
filterstats.basesHuman=lastEitherMappedBases; |
| 2952 |
} |
| 2953 |
if(filterstats.readsIn<1){ |
| 2954 |
filterstats.readsIn=lastReadsIn; |
| 2955 |
filterstats.basesIn=lastBasesIn; |
| 2956 |
} |
| 2957 |
filterstats.readsOut=lastReadsOut; |
| 2958 |
filterstats.basesOut=lastBasesOut; |
| 2959 |
|
| 2960 |
|
| 2961 |
|
| 2962 |
assert(filterstats.toString()!=null); |
| 2963 |
|
| 2964 |
outstream.println(format("Human Sequence Removed:", lastReadsIn, lastReadsOut, |
| 2965 |
lastBasesIn, lastBasesOut)); |
| 2966 |
log("#Input:\t"+lastReadsIn+" reads\t"+lastBasesIn+" bases", true, false); |
| 2967 |
log("#Remaining:\t"+lastReadsOut+" reads\t"+lastBasesOut+" bases", true, false); |
| 2968 |
} catch (Exception e) { |
| 2969 |
e.printStackTrace(); |
| 2970 |
log("failed", true); |
| 2971 |
System.exit(1); |
| 2972 |
} |
| 2973 |
} |
| 2974 |
|
| 2975 |
|
| 2976 |
Data.unloadAll(); |
| 2977 |
|
| 2978 |
|
| 2979 |
RefToIndex.NODISK=false; |
| 2980 |
|
| 2981 |
if(reproduceName!=null){ |
| 2982 |
writeReproduceFile(reproduceName, useBBSplit ? "bbsplit.sh" : "bbmap.sh", args); |
| 2983 |
} |
| 2984 |
|
| 2985 |
|
| 2986 |
|
| 2987 |
log("dehumanize finish", true); |
| 2988 |
} |
| 2989 |
|
| 2990 |
|
| 2991 |
public static boolean printFileTaxonomy(String in, String results, String taxTreeFile, boolean ow, boolean app, boolean bestEffort){ |
| 2992 |
if(results==null){return false;} |
| 2993 |
TextFile tf=new TextFile(in); |
| 2994 |
TextStreamWriter tsw=new TextStreamWriter(results, ow, app, false); |
| 2995 |
tsw.start(); |
| 2996 |
TaxTree tree=TaxTree.loadTaxTree(taxTreeFile, outstream, true, false); |
| 2997 |
assert(tree!=null) : taxTreeFile+", "+in+", "+results; |
| 2998 |
LinkedHashSet<TaxNode> nodes=new LinkedHashSet<TaxNode>(); |
| 2999 |
for(String line=tf.nextLine(); line!=null; line=tf.nextLine()){ |
| 3000 |
if(line.startsWith(">")){ |
| 3001 |
TaxNode tn=tree.parseNodeFromHeader(line.substring(1), bestEffort); |
| 3002 |
nodes.add(tn); |
| 3003 |
} |
| 3004 |
} |
| 3005 |
tf.close(); |
| 3006 |
for(TaxNode tn : nodes){ |
| 3007 |
tsw.println(tn.id+"\t"+tn.levelStringExtended(false)+"\t"+tn.name); |
| 3008 |
} |
| 3009 |
return tsw.poisonAndWait(); |
| 3010 |
} |
| 3011 |
|
| 3012 |
|
| 3013 |
|
| 3014 |
|
| 3015 |
private String taxFilter(String in, String out, String results, String level, boolean include, boolean bestEffort, boolean log, boolean ow, boolean app){ |
| 3016 |
if(taxList==null){ |
| 3017 |
printFileTaxonomy(in, results, taxTreeFile, ow, app, true); |
| 3018 |
return in; |
| 3019 |
} |
| 3020 |
if(log){log("taxFilter start", true);} |
| 3021 |
|
| 3022 |
String temp=(tmpDir==null ? outDir : tmpDir)+taxaPrefix+out; |
| 3023 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3024 |
|
| 3025 |
{ |
| 3026 |
argList.add("names="+taxList); |
| 3027 |
argList.add("tree="+taxTreeFile); |
| 3028 |
argList.add("level="+level); |
| 3029 |
argList.add("in="+in); |
| 3030 |
argList.add("out="+temp); |
| 3031 |
argList.add("ow="+ow); |
| 3032 |
argList.add("append="+app); |
| 3033 |
argList.add("include="+include); |
| 3034 |
argList.add("besteffort="+bestEffort); |
| 3035 |
if(results!=null){argList.add("results="+results);} |
| 3036 |
} |
| 3037 |
|
| 3038 |
if(loadGiTable){ |
| 3039 |
GiToTaxid.initialize(giTable); |
| 3040 |
} |
| 3041 |
|
| 3042 |
String[] args=argList.toArray(new String[0]); |
| 3043 |
final FilterByTaxa fbt; |
| 3044 |
{ |
| 3045 |
final boolean OLD_FORCE_INT=FASTQ.FORCE_INTERLEAVED, OLD_TEST_INT=FASTQ.TEST_INTERLEAVED; |
| 3046 |
FASTQ.FORCE_INTERLEAVED=FASTQ.TEST_INTERLEAVED=false; |
| 3047 |
fbt=new FilterByTaxa(args); |
| 3048 |
fbt.process(new Timer()); |
| 3049 |
FASTQ.FORCE_INTERLEAVED=OLD_FORCE_INT; |
| 3050 |
FASTQ.TEST_INTERLEAVED=OLD_TEST_INT; |
| 3051 |
GiToTaxid.unload(); |
| 3052 |
} |
| 3053 |
|
| 3054 |
if(reproduceName!=null){ |
| 3055 |
writeReproduceFile(reproduceName, "filterbytaxa.sh", args); |
| 3056 |
} |
| 3057 |
|
| 3058 |
if(log){log("taxFilter finish", true);} |
| 3059 |
Shared.setBuffers(); |
| 3060 |
|
| 3061 |
|
| 3062 |
|
| 3063 |
return fbt.basesOut>0 ? temp : null; |
| 3064 |
} |
| 3065 |
|
| 3066 |
|
| 3067 |
|
| 3068 |
|
| 3069 |
private String taxFilterList(ArrayList<String> in, String out, boolean include, boolean bestEffort, String initialLevel){ |
| 3070 |
String level=(bestEffort && include) ? initialLevel : taxLevel; |
| 3071 |
|
| 3072 |
if(in.size()<2){return taxFilter(in.get(0), out, null, level, include, bestEffort, true, overwrite, false);} |
| 3073 |
|
| 3074 |
log("taxFilterList start", true); |
| 3075 |
|
| 3076 |
for(int i=0; i<in.size(); i++){ |
| 3077 |
taxFilter(in.get(i), out, null, level, include, bestEffort, false, (i==0 && overwrite), i>0); |
| 3078 |
} |
| 3079 |
|
| 3080 |
String temp=(tmpDir==null ? outDir : tmpDir)+taxaPrefix+out; |
| 3081 |
|
| 3082 |
return temp; |
| 3083 |
} |
| 3084 |
|
| 3085 |
private void detectCommonMicrobes(final String in1, final String in2, final String scafstats, final String inPrefix, final String ref, boolean aggressive, |
| 3086 |
int build, String cmRef, String cmPath){ |
| 3087 |
|
| 3088 |
log("detectCommonMicrobes start", true); |
| 3089 |
|
| 3090 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 3091 |
|
| 3092 |
if(ref==null){ |
| 3093 |
String skipped="Tax filter removed all ref sequences; skipping microbe detection."; |
| 3094 |
outstream.println(skipped); |
| 3095 |
log(skipped, true); |
| 3096 |
log("detectCommonMicrobes finish", true); |
| 3097 |
return; |
| 3098 |
} |
| 3099 |
|
| 3100 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3101 |
{ |
| 3102 |
if(deterministic){argList.add("deterministic");} |
| 3103 |
argList.add("k="+map_k); |
| 3104 |
argList.add("idtag=t"); |
| 3105 |
argList.add("printunmappedcount"); |
| 3106 |
argList.add("ow="+overwrite); |
| 3107 |
if(trimUntrim){ |
| 3108 |
argList.add("qtrim=rl"); |
| 3109 |
argList.add("trimq=10"); |
| 3110 |
argList.add("untrim"); |
| 3111 |
} |
| 3112 |
argList.add("ef=0.001"); |
| 3113 |
if(cmPath!=null && cmRef.equals(ref) && cmRef.startsWith(cmPath)){ |
| 3114 |
RefToIndex.NODISK=false; |
| 3115 |
argList.add("path="+cmPath); |
| 3116 |
}else{ |
| 3117 |
RefToIndex.NODISK=true; |
| 3118 |
argList.add("ref="+ref); |
| 3119 |
} |
| 3120 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 3121 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 3122 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 3123 |
|
| 3124 |
if(aggressive){ |
| 3125 |
argList.add("minid=.85"); |
| 3126 |
argList.add("maxindel=8"); |
| 3127 |
argList.add("minhits="+1); |
| 3128 |
argList.add("bw=26"); |
| 3129 |
argList.add("bwr=0.22"); |
| 3130 |
argList.add("build=2"); |
| 3131 |
argList.add("tipsearch="+2); |
| 3132 |
}else{ |
| 3133 |
argList.add("minid=.95"); |
| 3134 |
argList.add("idfilter=.95"); |
| 3135 |
argList.add("maxindel=3"); |
| 3136 |
argList.add("minhits="+2); |
| 3137 |
argList.add("bw=12"); |
| 3138 |
argList.add("bwr=0.16"); |
| 3139 |
argList.add("fast="+true); |
| 3140 |
argList.add("maxsites2=10"); |
| 3141 |
argList.add("build="+build); |
| 3142 |
argList.add("tipsearch="+0); |
| 3143 |
} |
| 3144 |
|
| 3145 |
|
| 3146 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 3147 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 3148 |
|
| 3149 |
if(scafstats!=null){argList.add("scafstats="+scafstats);} |
| 3150 |
} |
| 3151 |
|
| 3152 |
String[] args=argList.toArray(new String[0]); |
| 3153 |
|
| 3154 |
if(!dryrun){ |
| 3155 |
try { |
| 3156 |
BBMap.main(args); |
| 3157 |
} catch (Exception e) { |
| 3158 |
e.printStackTrace(); |
| 3159 |
log("failed", true); |
| 3160 |
System.exit(1); |
| 3161 |
} |
| 3162 |
} |
| 3163 |
|
| 3164 |
|
| 3165 |
Data.unloadAll(); |
| 3166 |
|
| 3167 |
|
| 3168 |
RefToIndex.NODISK=false; |
| 3169 |
|
| 3170 |
if(reproduceName!=null){ |
| 3171 |
writeReproduceFile(reproduceName, "bbmap.sh", args); |
| 3172 |
} |
| 3173 |
|
| 3174 |
if(ref!=null && !ref.equals(cmRef)){delete(null, ref);} |
| 3175 |
|
| 3176 |
log("detectCommonMicrobes finish", true); |
| 3177 |
} |
| 3178 |
|
| 3179 |
|
| 3180 |
|
| 3181 |
|
| 3182 |
|
| 3183 |
private void removeCommonMicrobes(String in1, String in2, String out1, String out2, String outbad, String scafstats, String inPrefix, String outPrefix, |
| 3184 |
final String ref, int stepNum, boolean aggressive){ |
| 3185 |
|
| 3186 |
log("removeCommonMicrobes start", true); |
| 3187 |
|
| 3188 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 3189 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 3190 |
|
| 3191 |
if(ref==null){ |
| 3192 |
String skipped="Tax filter removed all ref sequences; skipping microbe removal."; |
| 3193 |
outstream.println(skipped); |
| 3194 |
log(skipped, true); |
| 3195 |
|
| 3196 |
try { |
| 3197 |
if(in1!=null){ |
| 3198 |
File a=new File(inPre+in1); |
| 3199 |
File b=new File(outPre+out1); |
| 3200 |
outstream.println("Renaming "+a+" to "+b); |
| 3201 |
assert(a.exists()) : a; |
| 3202 |
assert(!b.exists() || overwrite) : b; |
| 3203 |
a.renameTo(b); |
| 3204 |
writeReproduceFile(reproduceName, "mv", new String[] {a.toString(), b.toString()}); |
| 3205 |
} |
| 3206 |
if(in2!=null && out2!=null){ |
| 3207 |
File a=new File(inPre+in2); |
| 3208 |
File b=new File(outPre+out2); |
| 3209 |
outstream.println("Renaming "+a+" to "+b); |
| 3210 |
assert(a.exists()) : a; |
| 3211 |
assert(!b.exists() || overwrite) : b; |
| 3212 |
a.renameTo(b); |
| 3213 |
writeReproduceFile(reproduceName, "mv", new String[] {a.toString(), b.toString()}); |
| 3214 |
} |
| 3215 |
} catch (Throwable e) { |
| 3216 |
outstream.println(e.getMessage()); |
| 3217 |
e.printStackTrace(); |
| 3218 |
log("failed", true); |
| 3219 |
System.exit(1); |
| 3220 |
} |
| 3221 |
log("removeCommonMicrobes finish", true); |
| 3222 |
return; |
| 3223 |
} |
| 3224 |
|
| 3225 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3226 |
{ |
| 3227 |
if(deterministic){argList.add("deterministic");} |
| 3228 |
if(ordered){argList.add("ordered");} |
| 3229 |
argList.add("quickmatch"); |
| 3230 |
argList.add("k="+map_k); |
| 3231 |
argList.add("idtag=t"); |
| 3232 |
argList.add("printunmappedcount"); |
| 3233 |
argList.add("ow="+overwrite); |
| 3234 |
if(trimUntrim){ |
| 3235 |
argList.add("qtrim=rl"); |
| 3236 |
argList.add("trimq=10"); |
| 3237 |
argList.add("untrim"); |
| 3238 |
} |
| 3239 |
argList.add("ef=0.001"); |
| 3240 |
if(commonMicrobesPath!=null && commonMicrobesRef.equals(ref) && commonMicrobesRef.startsWith(commonMicrobesPath)){ |
| 3241 |
RefToIndex.NODISK=false; |
| 3242 |
argList.add("path="+commonMicrobesPath); |
| 3243 |
}else{ |
| 3244 |
RefToIndex.NODISK=true; |
| 3245 |
argList.add("ref="+ref); |
| 3246 |
} |
| 3247 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 3248 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 3249 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 3250 |
|
| 3251 |
if(aggressive){ |
| 3252 |
argList.add("minid=.85"); |
| 3253 |
argList.add("maxindel=8"); |
| 3254 |
argList.add("minhits="+1); |
| 3255 |
argList.add("bw=26"); |
| 3256 |
argList.add("bwr=0.22"); |
| 3257 |
argList.add("build=2"); |
| 3258 |
argList.add("tipsearch="+2); |
| 3259 |
}else{ |
| 3260 |
argList.add("minid=.95"); |
| 3261 |
argList.add("idfilter=.95"); |
| 3262 |
argList.add("maxindel=3"); |
| 3263 |
argList.add("minhits="+2); |
| 3264 |
argList.add("bw=12"); |
| 3265 |
argList.add("bwr=0.16"); |
| 3266 |
argList.add("fast="+true); |
| 3267 |
argList.add("maxsites2=10"); |
| 3268 |
argList.add("build="+commonMicrobesBuild); |
| 3269 |
argList.add("tipsearch="+0); |
| 3270 |
} |
| 3271 |
|
| 3272 |
|
| 3273 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 3274 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 3275 |
if(out1!=null){argList.add("outu1="+outPre+out1);} |
| 3276 |
if(out2!=null){argList.add("outu2="+outPre+out2);} |
| 3277 |
if(outbad!=null){argList.add("outm="+outbad);} |
| 3278 |
if(scafstats!=null){argList.add("scafstats="+scafstats);} |
| 3279 |
|
| 3280 |
} |
| 3281 |
|
| 3282 |
String[] args=argList.toArray(new String[0]); |
| 3283 |
|
| 3284 |
if(!dryrun){ |
| 3285 |
try { |
| 3286 |
BBMap.main(args); |
| 3287 |
|
| 3288 |
final long lastReadsIn=BBMap.lastReadsIn; |
| 3289 |
final long lastEitherMapped=BBMap.lastEitherMapped; |
| 3290 |
final long lastReadsOut=lastReadsIn-lastEitherMapped; |
| 3291 |
|
| 3292 |
final long lastBasesIn=BBMap.lastBasesIn; |
| 3293 |
final long lastEitherMappedBases=BBMap.lastEitherMappedBases; |
| 3294 |
final long lastBasesOut=lastBasesIn-lastEitherMappedBases; |
| 3295 |
|
| 3296 |
if(filterstats.readsIn>0){ |
| 3297 |
assert(lastReadsIn==filterstats.readsOut) : lastReadsIn+", "+filterstats.readsOut; |
| 3298 |
assert(lastBasesIn==filterstats.basesOut) : lastBasesIn+", "+filterstats.basesOut; |
| 3299 |
} |
| 3300 |
|
| 3301 |
filterstats.readsMicrobe=lastEitherMapped; |
| 3302 |
filterstats.basesMicrobe=lastEitherMappedBases; |
| 3303 |
if(filterstats.readsIn<1){ |
| 3304 |
filterstats.readsIn=lastReadsIn; |
| 3305 |
filterstats.basesIn=lastBasesIn; |
| 3306 |
} |
| 3307 |
filterstats.readsOut=lastReadsOut; |
| 3308 |
filterstats.basesOut=lastBasesOut; |
| 3309 |
|
| 3310 |
assert(filterstats.toString()!=null); |
| 3311 |
|
| 3312 |
outstream.println(format("Microbial Sequence Removed:", lastReadsIn, lastReadsOut, |
| 3313 |
lastBasesIn, lastBasesOut)); |
| 3314 |
log("#Input:\t"+lastReadsIn+" reads\t"+lastReadsOut+" bases", true, false); |
| 3315 |
log("#Remaining:\t"+lastBasesIn+" reads\t"+lastBasesOut+" bases", true, false); |
| 3316 |
} catch (Exception e) { |
| 3317 |
e.printStackTrace(); |
| 3318 |
log("failed", true); |
| 3319 |
System.exit(1); |
| 3320 |
} |
| 3321 |
} |
| 3322 |
|
| 3323 |
|
| 3324 |
Data.unloadAll(); |
| 3325 |
|
| 3326 |
|
| 3327 |
RefToIndex.NODISK=false; |
| 3328 |
|
| 3329 |
if(reproduceName!=null){ |
| 3330 |
writeReproduceFile(reproduceName, "bbmap.sh", args); |
| 3331 |
} |
| 3332 |
|
| 3333 |
if(ref!=null && !ref.equals(commonMicrobesRef)){delete(null, ref);} |
| 3334 |
|
| 3335 |
log("removeCommonMicrobes finish", true); |
| 3336 |
} |
| 3337 |
|
| 3338 |
|
| 3339 |
|
| 3340 |
|
| 3341 |
|
| 3342 |
|
| 3343 |
|
| 3344 |
|
| 3345 |
|
| 3346 |
|
| 3347 |
|
| 3348 |
|
| 3349 |
private void decontamByMapping(String in1, String in2, String out1, String out2, String outbad, String scafstats, String inPrefix, String outPrefix, |
| 3350 |
String ref, int stepNum, boolean addToOtherStats, ArrayList<String> otherArgs){ |
| 3351 |
|
| 3352 |
log("decontamByMapping_"+ref+" start", true); |
| 3353 |
assert(ref!=null) : "Reference was null."; |
| 3354 |
|
| 3355 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3356 |
|
| 3357 |
final String inPre=(inPrefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+inPrefix); |
| 3358 |
final String outPre=(outPrefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+outPrefix); |
| 3359 |
|
| 3360 |
{ |
| 3361 |
if(deterministic){argList.add("deterministic");} |
| 3362 |
if(ordered){argList.add("ordered");} |
| 3363 |
argList.add("minratio=.9"); |
| 3364 |
argList.add("maxindel=3"); |
| 3365 |
argList.add("fast="+true); |
| 3366 |
argList.add("minhits="+2); |
| 3367 |
argList.add("tipsearch="+4); |
| 3368 |
argList.add("bw=12"); |
| 3369 |
argList.add("bwr=0.16"); |
| 3370 |
argList.add("quickmatch"); |
| 3371 |
argList.add("k="+map_k); |
| 3372 |
argList.add("idtag=t"); |
| 3373 |
|
| 3374 |
argList.add("printunmappedcount"); |
| 3375 |
argList.add("ow="+overwrite); |
| 3376 |
if(trimUntrim){ |
| 3377 |
argList.add("qtrim=rl"); |
| 3378 |
argList.add("trimq=10"); |
| 3379 |
argList.add("untrim"); |
| 3380 |
} |
| 3381 |
argList.add("ef=0.03"); |
| 3382 |
if(ref.startsWith("path=")){ |
| 3383 |
argList.add(ref); |
| 3384 |
}else{ |
| 3385 |
RefToIndex.NODISK=true; |
| 3386 |
argList.add("ref="+ref); |
| 3387 |
} |
| 3388 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 3389 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 3390 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 3391 |
|
| 3392 |
|
| 3393 |
|
| 3394 |
|
| 3395 |
|
| 3396 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 3397 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 3398 |
if(out1!=null){argList.add("outu1="+outPre+out1);} |
| 3399 |
if(out2!=null){argList.add("outu2="+outPre+out2);} |
| 3400 |
if(outbad!=null){argList.add("outm="+outbad);} |
| 3401 |
if(scafstats!=null){argList.add("scafstats="+scafstats);} |
| 3402 |
|
| 3403 |
|
| 3404 |
if(otherArgs!=null){ |
| 3405 |
argList.addAll(otherArgs); |
| 3406 |
} |
| 3407 |
} |
| 3408 |
|
| 3409 |
String[] args=argList.toArray(new String[0]); |
| 3410 |
|
| 3411 |
if(!dryrun){ |
| 3412 |
try { |
| 3413 |
BBMap.main(args); |
| 3414 |
|
| 3415 |
long lastReadsIn=BBMap.lastReadsIn; |
| 3416 |
long lastEitherMapped=BBMap.lastEitherMapped; |
| 3417 |
long lastReadsOut=lastReadsIn-lastEitherMapped; |
| 3418 |
|
| 3419 |
long lastBasesIn=BBMap.lastBasesIn; |
| 3420 |
long lastEitherMappedBases=BBMap.lastEitherMappedBases; |
| 3421 |
long lastBasesOut=lastBasesIn-lastEitherMappedBases; |
| 3422 |
|
| 3423 |
outstream.println(format("Other Contam Sequence Removed:", lastReadsIn, lastReadsOut, |
| 3424 |
lastBasesIn, lastBasesOut)); |
| 3425 |
log("#Input:\t"+lastReadsIn+" reads\t"+lastBasesIn+" bases", true, false); |
| 3426 |
log("#Remaining:\t"+lastReadsOut+" reads\t"+lastBasesOut+" bases", true, false); |
| 3427 |
|
| 3428 |
|
| 3429 |
|
| 3430 |
|
| 3431 |
|
| 3432 |
|
| 3433 |
|
| 3434 |
|
| 3435 |
if(addToOtherStats){ |
| 3436 |
filterstats.readsOther+=lastEitherMapped; |
| 3437 |
filterstats.basesOther+=lastEitherMappedBases; |
| 3438 |
} |
| 3439 |
if(filterstats.readsIn<1){ |
| 3440 |
filterstats.readsIn=lastReadsIn; |
| 3441 |
filterstats.basesIn=lastBasesIn; |
| 3442 |
} |
| 3443 |
filterstats.readsOut=lastReadsOut; |
| 3444 |
filterstats.basesOut=lastBasesOut; |
| 3445 |
|
| 3446 |
assert(!addToOtherStats || filterstats.toString()!=null); |
| 3447 |
} catch (Exception e) { |
| 3448 |
e.printStackTrace(); |
| 3449 |
log("failed", true); |
| 3450 |
System.exit(1); |
| 3451 |
} |
| 3452 |
} |
| 3453 |
|
| 3454 |
|
| 3455 |
Data.unloadAll(); |
| 3456 |
|
| 3457 |
|
| 3458 |
RefToIndex.NODISK=false; |
| 3459 |
|
| 3460 |
if(reproduceName!=null){ |
| 3461 |
writeReproduceFile(reproduceName, "bbmap.sh", args); |
| 3462 |
} |
| 3463 |
|
| 3464 |
|
| 3465 |
|
| 3466 |
log("decontamByMapping_"+ref+" finish", true); |
| 3467 |
} |
| 3468 |
|
| 3469 |
private boolean runSketch(String in1, String outFname, String outPrefix){ |
| 3470 |
final String outPre=(outPrefix==null ? outDir : outDir+outPrefix); |
| 3471 |
final String fname=outPre+outFname; |
| 3472 |
|
| 3473 |
boolean success=false; |
| 3474 |
String[] split=new String[] {"refseq"}; |
| 3475 |
if(sketchDB!=null){split=sketchDB.split(",");} |
| 3476 |
for(int i=0; i<split.length; i++){ |
| 3477 |
success=(runSketch_inner(in1, fname, split[i], i>0))|success; |
| 3478 |
} |
| 3479 |
return success; |
| 3480 |
} |
| 3481 |
|
| 3482 |
private boolean runSketch_inner(String in, String fname, String db, boolean append){ |
| 3483 |
SketchObject.reset(); |
| 3484 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3485 |
|
| 3486 |
|
| 3487 |
String name=in; |
| 3488 |
try { |
| 3489 |
if(taxList!=null){ |
| 3490 |
TaxTree tree=TaxTree.loadTaxTree(taxTreeFile, outstream, true, false); |
| 3491 |
TaxNode tn=tree.parseNodeFromHeader(taxList.split(",")[0], true); |
| 3492 |
if(tn!=null){name=tn.name;} |
| 3493 |
} |
| 3494 |
} catch (Exception e1) {} |
| 3495 |
|
| 3496 |
argList.add("in="+in); |
| 3497 |
argList.add("out="+fname); |
| 3498 |
argList.add("reads="+sketchReads); |
| 3499 |
argList.add("name="+name); |
| 3500 |
argList.add("fname="+in1); |
| 3501 |
if(sketchMinProb!=null){argList.add("minprob="+sketchMinProb);} |
| 3502 |
if(sketchSamplerate!=null){argList.add("samplerate="+sketchSamplerate);} |
| 3503 |
if(sketchMerge){argList.add("merge");} |
| 3504 |
argList.add("printname0=f"); |
| 3505 |
argList.add("records=20"); |
| 3506 |
argList.add("color=false"); |
| 3507 |
argList.add("depth"); |
| 3508 |
argList.add("depth2"); |
| 3509 |
argList.add("unique2"); |
| 3510 |
argList.add("unique3"); |
| 3511 |
argList.add("volume"); |
| 3512 |
argList.add("sortbyvolume"); |
| 3513 |
argList.add("contam2=genus"); |
| 3514 |
argList.add("minprob=0.6"); |
| 3515 |
argList.add("refhits"); |
| 3516 |
argList.add(db); |
| 3517 |
|
| 3518 |
|
| 3519 |
if("silva".equalsIgnoreCase(db)){ |
| 3520 |
argList.add("translate=f"); |
| 3521 |
if(SILVA_LOCAL){ |
| 3522 |
argList.add("local"); |
| 3523 |
argList.add("sizemult=1"); |
| 3524 |
}else{ |
| 3525 |
argList.add("sizemult=10"); |
| 3526 |
} |
| 3527 |
argList.add("minkeycount=2"); |
| 3528 |
}else if("prokprot".equalsIgnoreCase(db) || "protein".equalsIgnoreCase(db)){ |
| 3529 |
argList.add("translate=t"); |
| 3530 |
argList.add("sizemult=2.2"); |
| 3531 |
}else if("refseq".equalsIgnoreCase(db)){ |
| 3532 |
argList.add("translate=f"); |
| 3533 |
argList.add("sizemult=2.5"); |
| 3534 |
}else if("nt".equalsIgnoreCase(db)){ |
| 3535 |
argList.add("translate=f"); |
| 3536 |
argList.add("sizemult=1.2"); |
| 3537 |
} |
| 3538 |
|
| 3539 |
if(append){argList.add("append");} |
| 3540 |
else{argList.add("ow");} |
| 3541 |
|
| 3542 |
String[] argArray=argList.toArray(new String[0]); |
| 3543 |
if(reproduceName!=null){ |
| 3544 |
writeReproduceFile(reproduceName, "sendsketch.sh", argArray); |
| 3545 |
} |
| 3546 |
|
| 3547 |
try { |
| 3548 |
|
| 3549 |
|
| 3550 |
if(!dryrun){SendSketch.main(argArray);} |
| 3551 |
return true; |
| 3552 |
} catch (Throwable e) { |
| 3553 |
|
| 3554 |
e.printStackTrace(); |
| 3555 |
return false; |
| 3556 |
} |
| 3557 |
} |
| 3558 |
|
| 3559 |
|
| 3560 |
|
| 3561 |
|
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
private void merge(String in1, String in2, String prefix){ |
| 3567 |
|
| 3568 |
log("merge start", true); |
| 3569 |
|
| 3570 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3571 |
|
| 3572 |
final String inPre=(prefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+prefix); |
| 3573 |
|
| 3574 |
if(extendFlagAuto){ |
| 3575 |
final long cardinality=CardinalityTracker.lastCardinality; |
| 3576 |
final long capacity=kmerCapacity(20, true); |
| 3577 |
outstream.println("cardinality="+cardinality+", capacity="+capacity); |
| 3578 |
|
| 3579 |
extendFlag=(cardinality>0 && cardinality*2<capacity); |
| 3580 |
} |
| 3581 |
|
| 3582 |
{ |
| 3583 |
if(mergeStrictness!=null){argList.add(mergeStrictness);} |
| 3584 |
argList.add("overwrite="+overwrite); |
| 3585 |
|
| 3586 |
|
| 3587 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 3588 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 3589 |
|
| 3590 |
if(ihistName!=null){argList.add("ihist="+ihistName);} |
| 3591 |
if(cardinalityName!=null){argList.add("outc="+cardinalityName);} |
| 3592 |
if(pigz!=null){argList.add("pigz="+pigz);} |
| 3593 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 3594 |
argList.add("zl="+(zl==null ? ""+ReadWrite.ZIPLEVEL : zl)); |
| 3595 |
if(discoveredAdaptersValid){argList.add("adapters="+adaptersOutFile);} |
| 3596 |
else if(fragAdapter!=null){argList.add("adapters="+fragAdapter);} |
| 3597 |
argList.add("mininsert=25"); |
| 3598 |
|
| 3599 |
if(extendFlag){ |
| 3600 |
argList.add("ecct"); |
| 3601 |
|
| 3602 |
|
| 3603 |
argList.add("extend2=100"); |
| 3604 |
argList.add("rem"); |
| 3605 |
argList.add("k=62"); |
| 3606 |
argList.add("prefilter"); |
| 3607 |
argList.add("prealloc=0.9"); |
| 3608 |
System.gc(); |
| 3609 |
} |
| 3610 |
argList.add("loglog"); |
| 3611 |
} |
| 3612 |
|
| 3613 |
String[] mergeargs=argList.toArray(new String[0]); |
| 3614 |
|
| 3615 |
if(reproduceName!=null){ |
| 3616 |
writeReproduceFile(reproduceName, "bbmerge.sh", mergeargs); |
| 3617 |
} |
| 3618 |
|
| 3619 |
if(!dryrun){ |
| 3620 |
final boolean OLD_FORCE_INT=FASTQ.FORCE_INTERLEAVED, OLD_TEST_INT=FASTQ.TEST_INTERLEAVED; |
| 3621 |
BBMerge merger=new BBMerge(mergeargs); |
| 3622 |
try { |
| 3623 |
merger.process(); |
| 3624 |
log("#Input:\t"+(merger.readsProcessedTotal*2)+" reads\t"+merger.basesProcessedTotal+" bases\t"+merger.loglog.cardinality()+" kmers", true, false); |
| 3625 |
log("#Remaining:\t"+(merger.readsProcessedTotal*2)+" reads\t"+merger.basesProcessedTotal+" bases\t"+merger.loglog.cardinality()+" kmers", true, false); |
| 3626 |
} catch (Exception e) { |
| 3627 |
e.printStackTrace(); |
| 3628 |
log("failed", true); |
| 3629 |
System.exit(1); |
| 3630 |
} |
| 3631 |
FASTQ.FORCE_INTERLEAVED=OLD_FORCE_INT; |
| 3632 |
FASTQ.TEST_INTERLEAVED=OLD_TEST_INT; |
| 3633 |
} |
| 3634 |
|
| 3635 |
|
| 3636 |
|
| 3637 |
log("merge finish", true); |
| 3638 |
} |
| 3639 |
|
| 3640 |
|
| 3641 |
|
| 3642 |
|
| 3643 |
|
| 3644 |
|
| 3645 |
|
| 3646 |
|
| 3647 |
|
| 3648 |
private void khist(String in1, String in2, String prefix){ |
| 3649 |
|
| 3650 |
log("khist start", true); |
| 3651 |
|
| 3652 |
ArrayList<String> argList=new ArrayList<String>(); |
| 3653 |
|
| 3654 |
final String inPre=(prefix==null ? outDir : (tmpDir==null ? outDir : tmpDir)+prefix); |
| 3655 |
|
| 3656 |
final long cardinality=CardinalityTracker.lastCardinality; |
| 3657 |
final long capacity=kmerCapacity(12, true); |
| 3658 |
outstream.println("cardinality="+cardinality+", capacity="+capacity); |
| 3659 |
|
| 3660 |
if(cardinality<1 || cardinality*1.5>capacity){ |
| 3661 |
{ |
| 3662 |
argList.add("overwrite="+overwrite); |
| 3663 |
|
| 3664 |
|
| 3665 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 3666 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 3667 |
|
| 3668 |
if(khistName!=null){argList.add("khist="+khistName);} |
| 3669 |
if(peaksName!=null){argList.add("peaks="+peaksName);} |
| 3670 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 3671 |
argList.add("keepall"); |
| 3672 |
argList.add("prefilter"); |
| 3673 |
argList.add("passes=1"); |
| 3674 |
argList.add("bits=16"); |
| 3675 |
argList.add("minprob=0"); |
| 3676 |
argList.add("minqual=0"); |
| 3677 |
argList.add("histcolumns=2"); |
| 3678 |
} |
| 3679 |
|
| 3680 |
String[] khistargs=argList.toArray(new String[0]); |
| 3681 |
|
| 3682 |
if(reproduceName!=null){ |
| 3683 |
writeReproduceFile(reproduceName, "khist.sh", khistargs); |
| 3684 |
} |
| 3685 |
|
| 3686 |
if(!dryrun){ |
| 3687 |
try { |
| 3688 |
KmerNormalize.main(khistargs); |
| 3689 |
} catch (Exception e) { |
| 3690 |
e.printStackTrace(); |
| 3691 |
log("failed", true); |
| 3692 |
System.exit(1); |
| 3693 |
} |
| 3694 |
} |
| 3695 |
}else{ |
| 3696 |
{ |
| 3697 |
argList.add("overwrite="+overwrite); |
| 3698 |
|
| 3699 |
|
| 3700 |
if(in1!=null){argList.add("in1="+inPre+in1);} |
| 3701 |
if(in2!=null){argList.add("in2="+inPre+in2);} |
| 3702 |
|
| 3703 |
if(khistName!=null){argList.add("khist="+khistName);} |
| 3704 |
if(peaksName!=null){argList.add("peaks="+peaksName);} |
| 3705 |
if(unpigz!=null){argList.add("unpigz="+unpigz);} |
| 3706 |
argList.add("gchist"); |
| 3707 |
|
| 3708 |
if(cardinality*4>capacity){ |
| 3709 |
argList.add("prealloc"); |
| 3710 |
} |
| 3711 |
} |
| 3712 |
|
| 3713 |
String[] khistargs=argList.toArray(new String[0]); |
| 3714 |
|
| 3715 |
if(reproduceName!=null){ |
| 3716 |
writeReproduceFile(reproduceName, "kmercountexact.sh", khistargs); |
| 3717 |
} |
| 3718 |
|
| 3719 |
if(!dryrun){ |
| 3720 |
try { |
| 3721 |
KmerCountExact.main(khistargs); |
| 3722 |
} catch (Exception e) { |
| 3723 |
e.printStackTrace(); |
| 3724 |
log("failed", true); |
| 3725 |
System.exit(1); |
| 3726 |
} |
| 3727 |
} |
| 3728 |
} |
| 3729 |
|
| 3730 |
|
| 3731 |
|
| 3732 |
log("khist finish", true); |
| 3733 |
} |
| 3734 |
|
| 3735 |
private static long kmerCapacity(int bytesPerKmer, boolean prealloc){ |
| 3736 |
System.gc(); |
| 3737 |
long memory=Runtime.getRuntime().maxMemory(); |
| 3738 |
double xmsRatio=Shared.xmsRatio(); |
| 3739 |
long usableMemory=(long)Tools.max(((memory-96000000)*(xmsRatio>0.97 ? 0.82 : 0.72)), memory*0.45); |
| 3740 |
long tableMemory=(long)(usableMemory*.95); |
| 3741 |
long estimatedKmerCapacity=(long)((tableMemory*1.0/bytesPerKmer)*(prealloc ? 0.9 : 0.6)); |
| 3742 |
return estimatedKmerCapacity; |
| 3743 |
} |
| 3744 |
|
| 3745 |
|
| 3746 |
|
| 3747 |
|
| 3748 |
|
| 3749 |
|
| 3750 |
private void log(String message, boolean append){log(message, append, true);} |
| 3751 |
|
| 3752 |
|
| 3753 |
|
| 3754 |
|
| 3755 |
|
| 3756 |
|
| 3757 |
private void log(String message, boolean append, boolean printTime){ |
| 3758 |
if(logName!=null){ |
| 3759 |
ReadWrite.writeString(message+(printTime ? ", "+timeString() : "")+"\n", logName, append); |
| 3760 |
} |
| 3761 |
} |
| 3762 |
|
| 3763 |
|
| 3764 |
|
| 3765 |
|
| 3766 |
|
| 3767 |
|
| 3768 |
|
| 3769 |
private void delete(String prefix, String...names){ |
| 3770 |
if(!deleteTemp){return;} |
| 3771 |
log("delete temp files start", true); |
| 3772 |
if(names!=null){ |
| 3773 |
final String pre=(prefix==null ? "" : (tmpDir==null ? outDir : tmpDir)+prefix); |
| 3774 |
for(String s : names){ |
| 3775 |
if(s!=null){ |
| 3776 |
s=pre+s; |
| 3777 |
if(verbose){outstream.println("Trying to delete "+s);} |
| 3778 |
File f=new File(s); |
| 3779 |
if(f.exists() || dryrun){ |
| 3780 |
if(!dryrun){f.delete();} |
| 3781 |
writeReproduceFile(reproduceName, "rm", new String[] {s}); |
| 3782 |
} |
| 3783 |
} |
| 3784 |
} |
| 3785 |
} |
| 3786 |
log("delete temp files finish", true); |
| 3787 |
} |
| 3788 |
|
| 3789 |
|
| 3790 |
|
| 3791 |
|
| 3792 |
private String abbreviation(){ |
| 3793 |
StringBuilder sb=new StringBuilder(); |
| 3794 |
|
| 3795 |
if(mainArtifactFile!=null){sb.append("a");} |
| 3796 |
|
| 3797 |
if(maxNs>=0){sb.append("n");} |
| 3798 |
|
| 3799 |
if(minAvgQuality>0){sb.append("q");} |
| 3800 |
|
| 3801 |
if(rnaArtifactFlag){sb.append("r");} |
| 3802 |
if(dnaArtifactFlag){sb.append("d");} |
| 3803 |
|
| 3804 |
if(libType==CLIP){sb.append("c");} |
| 3805 |
else if(libType==LFPE){sb.append("l");} |
| 3806 |
else if(libType==CLRS){sb.append("s");} |
| 3807 |
|
| 3808 |
if(phixFlag){sb.append("p");} |
| 3809 |
if(humanFlag || mouseCatDogHumanFlag){sb.append("h");} |
| 3810 |
|
| 3811 |
|
| 3812 |
|
| 3813 |
|
| 3814 |
|
| 3815 |
|
| 3816 |
if(doAdapterTrim || qtrimFlag){sb.append("t");} |
| 3817 |
|
| 3818 |
return sb.toString(); |
| 3819 |
} |
| 3820 |
|
| 3821 |
|
| 3822 |
|
| 3823 |
|
| 3824 |
|
| 3825 |
|
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
public static String timeString(){ |
| 3830 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 3831 |
|
| 3832 |
sdf.setTimeZone(TimeZone.getDefault()); |
| 3833 |
return sdf.format(new Date()); |
| 3834 |
} |
| 3835 |
|
| 3836 |
public static String stripDirs(String fname){ |
| 3837 |
return ReadWrite.stripPath(fname); |
| 3838 |
} |
| 3839 |
|
| 3840 |
|
| 3841 |
|
| 3842 |
|
| 3843 |
|
| 3844 |
private static void setPermissions(String...names){ |
| 3845 |
if(names==null){return;} |
| 3846 |
for(String name : names){ |
| 3847 |
if(name!=null && name.trim().length()>0 && new File(name).exists()){ |
| 3848 |
ReadWrite.setPermissions(name, true, true, true, false); |
| 3849 |
} |
| 3850 |
} |
| 3851 |
} |
| 3852 |
|
| 3853 |
|
| 3854 |
|
| 3855 |
|
| 3856 |
|
| 3857 |
|
| 3858 |
|
| 3859 |
private static void writeReproduceFile(String fname, String command, String[] args){ |
| 3860 |
StringBuilder sb=new StringBuilder(); |
| 3861 |
sb.append('\n'); |
| 3862 |
sb.append(command); |
| 3863 |
if(args!=null){ |
| 3864 |
for(String s : args){ |
| 3865 |
sb.append(' ').append(s); |
| 3866 |
} |
| 3867 |
} |
| 3868 |
sb.append('\n'); |
| 3869 |
ReadWrite.writeString(sb, fname, true); |
| 3870 |
} |
| 3871 |
|
| 3872 |
|
| 3873 |
|
| 3874 |
|
| 3875 |
|
| 3876 |
|
| 3877 |
|
| 3878 |
|
| 3879 |
private static void writeReproduceHeader(String fname, String[] args, boolean overwrite){ |
| 3880 |
StringBuilder sb=new StringBuilder(); |
| 3881 |
boolean b=Tools.canWrite(fname, overwrite); |
| 3882 |
assert(b) : "Can't write to "+fname; |
| 3883 |
sb.append("#!/bin/bash\n"); |
| 3884 |
sb.append("#BBTools version "+Shared.BBTOOLS_VERSION_STRING+"\n"); |
| 3885 |
sb.append("#The steps below recapitulate the output of RQCFilter2 when run like this:\n"); |
| 3886 |
sb.append("#rqcfilter2.sh"); |
| 3887 |
if(args!=null){ |
| 3888 |
for(String s : args){ |
| 3889 |
sb.append(' ').append(s); |
| 3890 |
} |
| 3891 |
} |
| 3892 |
sb.append('\n'); |
| 3893 |
sb.append("#Data dependencies are available at http://portal.nersc.gov/dna/microbial/assembly/bushnell/RQCFilterData.tar"); |
| 3894 |
sb.append('\n'); |
| 3895 |
sb.append('\n'); |
| 3896 |
ReadWrite.writeString(sb, fname, false); |
| 3897 |
} |
| 3898 |
|
| 3899 |
|
| 3900 |
|
| 3901 |
|
| 3902 |
|
| 3903 |
private static int toLibType(String s){ |
| 3904 |
if(s==null){return FRAG;} |
| 3905 |
s=s.trim().toLowerCase(); |
| 3906 |
if(s.equals("lfpe")){return LFPE;} |
| 3907 |
if(s.equals("clip")){return CLIP;} |
| 3908 |
if(s.equals("clrs")){return CLRS;} |
| 3909 |
if(s.equals("frag") || s.equals("fragment")){return FRAG;} |
| 3910 |
throw new RuntimeException("Unknown library type "+s); |
| 3911 |
} |
| 3912 |
|
| 3913 |
|
| 3914 |
|
| 3915 |
|
| 3916 |
|
| 3917 |
|
| 3918 |
private static PrintStream outstream=System.err; |
| 3919 |
|
| 3920 |
|
| 3921 |
private final boolean doFilter; |
| 3922 |
|
| 3923 |
private boolean skipFilter=false; |
| 3924 |
|
| 3925 |
private final boolean doSpikein; |
| 3926 |
|
| 3927 |
private boolean doClump=false; |
| 3928 |
|
| 3929 |
private boolean recalibrate=true; |
| 3930 |
|
| 3931 |
private String quantize="2"; |
| 3932 |
|
| 3933 |
private boolean doFilterByTile=true; |
| 3934 |
|
| 3935 |
private String polyfilter="GC"; |
| 3936 |
|
| 3937 |
private final boolean doAdapterTrim; |
| 3938 |
|
| 3939 |
private final boolean doMerge; |
| 3940 |
|
| 3941 |
private boolean doKhist=false; |
| 3942 |
|
| 3943 |
private final boolean doNexteraLMP; |
| 3944 |
|
| 3945 |
|
| 3946 |
private final String symbols; |
| 3947 |
|
| 3948 |
|
| 3949 |
private final String rawName; |
| 3950 |
|
| 3951 |
|
| 3952 |
private int libType=FRAG; |
| 3953 |
|
| 3954 |
private boolean rnaArtifactFlag=false; |
| 3955 |
|
| 3956 |
private boolean dnaArtifactFlag=true; |
| 3957 |
|
| 3958 |
private boolean phixFlag=true; |
| 3959 |
|
| 3960 |
private boolean lambdaFlag=true; |
| 3961 |
|
| 3962 |
private boolean pjetFlag=true; |
| 3963 |
|
| 3964 |
private boolean sipFlag=false; |
| 3965 |
|
| 3966 |
|
| 3967 |
private boolean trimPolyA=false; |
| 3968 |
|
| 3969 |
private boolean filterPolyA=false; |
| 3970 |
|
| 3971 |
|
| 3972 |
public int trimPolyGLeft=6; |
| 3973 |
|
| 3974 |
public int trimPolyGRight=6; |
| 3975 |
|
| 3976 |
public int filterPolyG=0; |
| 3977 |
|
| 3978 |
|
| 3979 |
private boolean mtstFlag=false; |
| 3980 |
|
| 3981 |
private boolean kapaFlag=true; |
| 3982 |
|
| 3983 |
|
| 3984 |
private boolean tboFlag=true; |
| 3985 |
|
| 3986 |
private boolean tpeFlag=true; |
| 3987 |
|
| 3988 |
|
| 3989 |
private String jointSeq=null; |
| 3990 |
|
| 3991 |
private int minLen=25; |
| 3992 |
|
| 3993 |
private float minLenFraction=0.333f; |
| 3994 |
|
| 3995 |
private float trimq=10; |
| 3996 |
|
| 3997 |
private float minAvgQuality=5; |
| 3998 |
|
| 3999 |
private int minAvgQualityBases=0; |
| 4000 |
|
| 4001 |
private int forceTrimModulo=5; |
| 4002 |
|
| 4003 |
private String qtrim="f"; |
| 4004 |
|
| 4005 |
private String ktrim="r"; |
| 4006 |
|
| 4007 |
private int filter_k=31; |
| 4008 |
|
| 4009 |
private int trim_k=23; |
| 4010 |
|
| 4011 |
private int normalize_k=31; |
| 4012 |
|
| 4013 |
private int map_k=14; |
| 4014 |
|
| 4015 |
private int mink=11; |
| 4016 |
|
| 4017 |
private int maxNs=0; |
| 4018 |
|
| 4019 |
private int hdist_filter=1; |
| 4020 |
|
| 4021 |
private int qhdist_filter=0; |
| 4022 |
|
| 4023 |
private int hdist_trim=1; |
| 4024 |
|
| 4025 |
private int hdist2_trim=-1; |
| 4026 |
|
| 4027 |
private int hdist_ribo=0; |
| 4028 |
|
| 4029 |
private int edist_ribo=0; |
| 4030 |
|
| 4031 |
|
| 4032 |
private int spikein_k=31; |
| 4033 |
|
| 4034 |
private int hdist_spikein=0; |
| 4035 |
|
| 4036 |
|
| 4037 |
private int ftl=-1; |
| 4038 |
|
| 4039 |
private int ftr=-1; |
| 4040 |
|
| 4041 |
private int ftr2=-1; |
| 4042 |
|
| 4043 |
|
| 4044 |
private String mergeStrictness="loose"; |
| 4045 |
|
| 4046 |
|
| 4047 |
private boolean fragAdapterFlag=true; |
| 4048 |
|
| 4049 |
private boolean rnaAdapterFlag=false; |
| 4050 |
|
| 4051 |
private boolean swiftFlag=false; |
| 4052 |
|
| 4053 |
|
| 4054 |
private boolean bisulfite=false; |
| 4055 |
|
| 4056 |
|
| 4057 |
private boolean qtrimFlag=false; |
| 4058 |
|
| 4059 |
private boolean ktrimFlag=false; |
| 4060 |
|
| 4061 |
private boolean splitNexteraFlag=false; |
| 4062 |
|
| 4063 |
|
| 4064 |
|
| 4065 |
|
| 4066 |
|
| 4067 |
|
| 4068 |
private boolean humanFlag=false; |
| 4069 |
|
| 4070 |
private boolean dogFlag=false; |
| 4071 |
|
| 4072 |
private boolean catFlag=false; |
| 4073 |
|
| 4074 |
private boolean mouseFlag=false; |
| 4075 |
|
| 4076 |
private boolean mouseCatDogHumanFlag=false; |
| 4077 |
|
| 4078 |
private boolean aggressiveHumanFlag=false; |
| 4079 |
|
| 4080 |
private boolean keepHumanReads=false; |
| 4081 |
|
| 4082 |
|
| 4083 |
private boolean aggressiveMicrobeFlag=false; |
| 4084 |
|
| 4085 |
private boolean removeCommonMicrobeFlag=false; |
| 4086 |
|
| 4087 |
private boolean detectMicrobeFlag=false; |
| 4088 |
|
| 4089 |
private boolean otherMicrobeFlag=false; |
| 4090 |
|
| 4091 |
|
| 4092 |
private boolean bloomFilter=true; |
| 4093 |
|
| 4094 |
private int bloomFilterK=29; |
| 4095 |
|
| 4096 |
private int bloomFilterHashes=1; |
| 4097 |
|
| 4098 |
private int bloomFilterMinHits=6; |
| 4099 |
|
| 4100 |
private long minReadsToBloomFilter=4000000; |
| 4101 |
|
| 4102 |
private boolean bloomSerial=true; |
| 4103 |
|
| 4104 |
private boolean trimUntrim=true; |
| 4105 |
|
| 4106 |
|
| 4107 |
|
| 4108 |
|
| 4109 |
|
| 4110 |
|
| 4111 |
private boolean discoverAdaptersFlag=true; |
| 4112 |
|
| 4113 |
private boolean discoveredAdaptersValid=false; |
| 4114 |
|
| 4115 |
|
| 4116 |
private boolean extendFlag=false; |
| 4117 |
|
| 4118 |
private boolean extendFlagAuto=true; |
| 4119 |
|
| 4120 |
|
| 4121 |
|
| 4122 |
|
| 4123 |
|
| 4124 |
|
| 4125 |
private boolean riboKmerFlag=false; |
| 4126 |
|
| 4127 |
private boolean riboMapFlag=false; |
| 4128 |
|
| 4129 |
private boolean chloroMapFlag=false; |
| 4130 |
|
| 4131 |
private boolean mitoMapFlag=false; |
| 4132 |
|
| 4133 |
|
| 4134 |
|
| 4135 |
|
| 4136 |
|
| 4137 |
|
| 4138 |
private boolean sketchFlag=true; |
| 4139 |
|
| 4140 |
private boolean SILVA_LOCAL=true; |
| 4141 |
|
| 4142 |
private String sketchDB="nt,refseq,silva,prokprot"; |
| 4143 |
|
| 4144 |
|
| 4145 |
private boolean doCardinality=true; |
| 4146 |
|
| 4147 |
|
| 4148 |
private boolean verbose=false; |
| 4149 |
private boolean overwrite=true; |
| 4150 |
private boolean compress=true; |
| 4151 |
|
| 4152 |
private boolean copyUndefined=false; |
| 4153 |
|
| 4154 |
|
| 4155 |
private boolean writeTempToTmpdir=true; |
| 4156 |
|
| 4157 |
|
| 4158 |
private String pigz="t"; |
| 4159 |
|
| 4160 |
private String unpigz="t"; |
| 4161 |
|
| 4162 |
private String zl; |
| 4163 |
|
| 4164 |
|
| 4165 |
private String chastityfilter="t"; |
| 4166 |
|
| 4167 |
private String failnobarcode=null; |
| 4168 |
|
| 4169 |
private String barcodefilter="f"; |
| 4170 |
|
| 4171 |
private String barcodes=null; |
| 4172 |
|
| 4173 |
|
| 4174 |
private ArrayList<String> primaryArgList=new ArrayList<String>(); |
| 4175 |
|
| 4176 |
private ArrayList<String> bbdukFilterRefs=new ArrayList<String>(); |
| 4177 |
|
| 4178 |
private ArrayList<String> spikeinRefs=new ArrayList<String>(); |
| 4179 |
|
| 4180 |
private ArrayList<String> mappingRefs=new ArrayList<String>(); |
| 4181 |
|
| 4182 |
|
| 4183 |
private String taxList=null; |
| 4184 |
|
| 4185 |
private String taxLevel="order"; |
| 4186 |
|
| 4187 |
private boolean loadGiTable=false; |
| 4188 |
|
| 4189 |
|
| 4190 |
private int sketchReads=2000000; |
| 4191 |
private String sketchMinProb="0.2"; |
| 4192 |
private String sketchSamplerate="1.0"; |
| 4193 |
private boolean sketchMerge=true; |
| 4194 |
|
| 4195 |
private boolean entropyFilter=false; |
| 4196 |
private double minEntropy=0.42; |
| 4197 |
private int entropyk=2; |
| 4198 |
private int entropywindow=40; |
| 4199 |
|
| 4200 |
|
| 4201 |
|
| 4202 |
|
| 4203 |
|
| 4204 |
private boolean removeDuplicates=false; |
| 4205 |
private boolean removeAllDuplicates=false; |
| 4206 |
private boolean removeOpticalDuplicates=false; |
| 4207 |
private boolean removeEdgeDuplicates=false; |
| 4208 |
private int duplicatePasses=1; |
| 4209 |
private int duplicateSubs=-1; |
| 4210 |
private int duplicateDist=-1; |
| 4211 |
private boolean lowComplexity=false; |
| 4212 |
private int clumpifyGroups=-1; |
| 4213 |
private boolean clumpifyTmpdir=false; |
| 4214 |
|
| 4215 |
|
| 4216 |
|
| 4217 |
|
| 4218 |
|
| 4219 |
private final String tempSalt; |
| 4220 |
|
| 4221 |
private final String clumpPrefix; |
| 4222 |
private final String recalPrefix; |
| 4223 |
private final String fbtPrefix; |
| 4224 |
private final String trimPrefix; |
| 4225 |
private final String polyPrefix; |
| 4226 |
private final String humanPrefix; |
| 4227 |
private final String spikeinPrefix; |
| 4228 |
private final String filterPrefix1; |
| 4229 |
private final String filterPrefix2; |
| 4230 |
private final String sipPrefix; |
| 4231 |
private final String taxaPrefix; |
| 4232 |
private final String microbePrefix; |
| 4233 |
private final String riboPrefix; |
| 4234 |
private final String chloroPrefix; |
| 4235 |
private final String[] mappingPrefix; |
| 4236 |
|
| 4237 |
|
| 4238 |
private String outDir=""; |
| 4239 |
|
| 4240 |
|
| 4241 |
private String tmpDir=Shared.tmpdir(); |
| 4242 |
|
| 4243 |
|
| 4244 |
private String in1=null; |
| 4245 |
|
| 4246 |
private String in2=null; |
| 4247 |
|
| 4248 |
private String out1=null; |
| 4249 |
|
| 4250 |
private String out2=null; |
| 4251 |
|
| 4252 |
private String phixSam=null; |
| 4253 |
private String tiledump=null; |
| 4254 |
|
| 4255 |
private boolean deleteTemp=true; |
| 4256 |
|
| 4257 |
private boolean deterministic=true; |
| 4258 |
|
| 4259 |
private boolean ordered=false; |
| 4260 |
|
| 4261 |
private boolean dryrun=false; |
| 4262 |
|
| 4263 |
|
| 4264 |
|
| 4265 |
|
| 4266 |
|
| 4267 |
private String riboOutFile="ribo.fq.gz"; |
| 4268 |
private String fbtOutFile="filteredByTile.fq.gz"; |
| 4269 |
private String chloroOutFile="chloro.fq.gz"; |
| 4270 |
private String humanOutFile="human.fq.gz"; |
| 4271 |
private String spikeinOutFile="spikein.fq.gz"; |
| 4272 |
private String synthOutFile1="synth1.fq.gz"; |
| 4273 |
private String synthOutFile2="synth2.fq.gz"; |
| 4274 |
private String microbeOutFile="microbes.fq.gz"; |
| 4275 |
|
| 4276 |
|
| 4277 |
|
| 4278 |
|
| 4279 |
|
| 4280 |
private RQCFilterStats filterstats=new RQCFilterStats(); |
| 4281 |
|
| 4282 |
private String logName="status.log"; |
| 4283 |
private String reproduceName="reproduce.sh"; |
| 4284 |
private String fileListName="file-list.txt"; |
| 4285 |
|
| 4286 |
private String rqcStatsName="filterStats.txt"; |
| 4287 |
private String rqcStatsName2="filterStats2.txt"; |
| 4288 |
private String kmerStatsName1="kmerStats1.txt"; |
| 4289 |
private String kmerStatsName2="kmerStats2.txt"; |
| 4290 |
private String scaffoldStatsName1="scaffoldStats1.txt"; |
| 4291 |
private String scaffoldStatsName2="scaffoldStats2.txt"; |
| 4292 |
private String scaffoldStatsNameSpikein="scaffoldStatsSpikein.txt"; |
| 4293 |
private String refStatsName="refStats.txt"; |
| 4294 |
private String microbeStatsFile="commonMicrobes.txt"; |
| 4295 |
private String microbeStats2File="otherMicrobes.txt"; |
| 4296 |
private String adaptersOutFile="adaptersDetected.fa"; |
| 4297 |
private String microbesUsed="microbesUsed.txt"; |
| 4298 |
private String chloroStatsFile="chloroStats.txt"; |
| 4299 |
private String sipStatsFile="sipSpikeinStats.txt"; |
| 4300 |
private String sipScafStats="sipScafStats.txt"; |
| 4301 |
private String nexteraStats="nexteraStats.txt"; |
| 4302 |
private String ihistName="ihist_merge.txt"; |
| 4303 |
private String khistName="khist.txt"; |
| 4304 |
private String peaksName="peaks.txt"; |
| 4305 |
private String phistName="phist.txt"; |
| 4306 |
private String qhistName="qhist.txt"; |
| 4307 |
private String bhistName="bhist.txt"; |
| 4308 |
private String gchistName="gchist.txt"; |
| 4309 |
private String sketchName="sketch.txt"; |
| 4310 |
|
| 4311 |
private String cardinalityName="cardinality.txt"; |
| 4312 |
|
| 4313 |
|
| 4314 |
private String rqcStatsName_kt; |
| 4315 |
|
| 4316 |
private String kmerStatsName_kt; |
| 4317 |
|
| 4318 |
private String scaffoldStatsName_kt; |
| 4319 |
|
| 4320 |
private String doneFile="RQCFilter_finished.txt"; |
| 4321 |
|
| 4322 |
|
| 4323 |
|
| 4324 |
|
| 4325 |
|
| 4326 |
|
| 4327 |
private void fixReferencePaths(){ |
| 4328 |
|
| 4329 |
if(RQCFilterData==null){RQCFilterData=".";} |
| 4330 |
|
| 4331 |
shortArtifactFile=fixPath(shortArtifactFile); |
| 4332 |
mainArtifactFile=fixPath(mainArtifactFile); |
| 4333 |
polyAFile=fixPath(polyAFile); |
| 4334 |
nexteraLinkerFile=fixPath(nexteraLinkerFile); |
| 4335 |
|
| 4336 |
phixRef=fixPath(phixRef); |
| 4337 |
lambdaRef=fixPath(lambdaRef); |
| 4338 |
lfpeLinker=fixPath(lfpeLinker); |
| 4339 |
clrsLinker=fixPath(clrsLinker); |
| 4340 |
|
| 4341 |
pjetRef=fixPath(pjetRef); |
| 4342 |
riboKmers=fixPath(riboKmers); |
| 4343 |
fragAdapter=fixPath(fragAdapter); |
| 4344 |
rnaAdapter=fixPath(rnaAdapter); |
| 4345 |
mtstRef=fixPath(mtstRef); |
| 4346 |
kapaRef=fixPath(kapaRef); |
| 4347 |
|
| 4348 |
humanPath=fixPath(humanPath); |
| 4349 |
catPath=fixPath(catPath); |
| 4350 |
dogPath=fixPath(dogPath); |
| 4351 |
mousePath=fixPath(mousePath); |
| 4352 |
mouseCatDogHumanPath=fixPath(mouseCatDogHumanPath); |
| 4353 |
humanRef=fixPath(humanRef); |
| 4354 |
|
| 4355 |
chloroplastRef=fixPath(chloroplastRef); |
| 4356 |
mitoRef=fixPath(mitoRef); |
| 4357 |
chloroMitoRef=fixPath(chloroMitoRef); |
| 4358 |
chloroMitoRiboRef=fixPath(chloroMitoRiboRef); |
| 4359 |
mitoRiboRef=fixPath(mitoRiboRef); |
| 4360 |
chloroRiboRef=fixPath(chloroRiboRef); |
| 4361 |
|
| 4362 |
riboRef=fixPath(riboRef); |
| 4363 |
|
| 4364 |
commonMicrobesPath=fixPath(commonMicrobesPath); |
| 4365 |
commonMicrobesRef=fixPath(commonMicrobesRef); |
| 4366 |
|
| 4367 |
otherMicrobesPath=fixPath(otherMicrobesPath); |
| 4368 |
otherMicrobesRef=fixPath(otherMicrobesRef); |
| 4369 |
|
| 4370 |
taxTreeFile=fixPath(taxTreeFile); |
| 4371 |
} |
| 4372 |
|
| 4373 |
private String fixPath(String s){ |
| 4374 |
if(s==null){return null;} |
| 4375 |
s=s.replaceAll("RQCFILTER_PATH", RQCFilterData); |
| 4376 |
File f=new File(s); |
| 4377 |
assert(f.exists() && f.canRead()) : |
| 4378 |
"Cannot read file "+s+"\nPlease be sure RQCFilterData is set correctly."; |
| 4379 |
return s; |
| 4380 |
} |
| 4381 |
|
| 4382 |
private static String getRQCPath() { |
| 4383 |
if(Shared.PERLMUTTER) { |
| 4384 |
return "/global/cfs/cdirs/bbtools/RQCFilterData_Local"; |
| 4385 |
}else if(Shared.DORI) { |
| 4386 |
return "/clusterfs/jgi/groups/gentech/genome_analysis/ref/RQCFilterData"; |
| 4387 |
}else if(Shared.AWS) { |
| 4388 |
return ""; |
| 4389 |
}else { |
| 4390 |
return ""; |
| 4391 |
} |
| 4392 |
} |
| 4393 |
|
| 4394 |
private String RQCFilterData=getRQCPath(); |
| 4395 |
|
| 4396 |
private String shortArtifactFile = "RQCFILTER_PATH/short.fa.gz"; |
| 4397 |
private String mainArtifactFile = "RQCFILTER_PATH/Illumina.artifacts.fa.gz"; |
| 4398 |
private String polyAFile = "RQCFILTER_PATH/polyA.fa.gz"; |
| 4399 |
private String nexteraLinkerFile = "RQCFILTER_PATH/nextera_LMP_linker.fa.gz"; |
| 4400 |
|
| 4401 |
private String phixRef = "RQCFILTER_PATH/phix2.fa.gz"; |
| 4402 |
private String lambdaRef = "RQCFILTER_PATH/lambda.fa.gz"; |
| 4403 |
private String lfpeLinker = "RQCFILTER_PATH/lfpe.linker.fa.gz"; |
| 4404 |
private String clrsLinker = "RQCFILTER_PATH/crelox.fa.gz"; |
| 4405 |
private String clipLinker = clipLinkerDefault; |
| 4406 |
|
| 4407 |
|
| 4408 |
private String pjetRef = "RQCFILTER_PATH/pJET1.2.fa.gz"; |
| 4409 |
private String riboKmers = "RQCFILTER_PATH/riboKmers20fused.fa.gz"; |
| 4410 |
private String fragAdapter = "RQCFILTER_PATH/adapters2.fa.gz"; |
| 4411 |
private String rnaAdapter = "RQCFILTER_PATH/truseq_rna.fa.gz"; |
| 4412 |
private String mtstRef = "RQCFILTER_PATH/mtst.fa.gz"; |
| 4413 |
private String kapaRef = "RQCFILTER_PATH/kapatags.L40.fa.gz"; |
| 4414 |
|
| 4415 |
private String humanPath = "RQCFILTER_PATH/human_genome/"; |
| 4416 |
private String catPath = "RQCFILTER_PATH/cat_genome/"; |
| 4417 |
private String dogPath = "RQCFILTER_PATH/dog_genome/"; |
| 4418 |
private String mousePath = "RQCFILTER_PATH/mouse_genome/"; |
| 4419 |
private String mouseCatDogHumanPath = "RQCFILTER_PATH/mousecatdoghuman/"; |
| 4420 |
private String humanRef = null; |
| 4421 |
|
| 4422 |
private String chloroplastRef = "RQCFILTER_PATH/plastid.fa.gz"; |
| 4423 |
private String mitoRef = "RQCFILTER_PATH/mitochondrion.fa.gz"; |
| 4424 |
private String chloroMitoRef = "RQCFILTER_PATH/chloro_mito.fa.gz"; |
| 4425 |
private String chloroMitoRiboRef = "RQCFILTER_PATH/chloro_mito_ribo.fa.gz"; |
| 4426 |
private String mitoRiboRef = "RQCFILTER_PATH/mito_ribo.fa.gz"; |
| 4427 |
private String chloroRiboRef = "RQCFILTER_PATH/chloro_ribo.fa.gz"; |
| 4428 |
|
| 4429 |
private String riboRef = "RQCFILTER_PATH/SSU_LSU_sorted.fa.gz"; |
| 4430 |
|
| 4431 |
private String commonMicrobesPath = "RQCFILTER_PATH/commonMicrobes/"; |
| 4432 |
private String commonMicrobesRef = "RQCFILTER_PATH/commonMicrobes/fusedERPBBmasked2.fa.gz"; |
| 4433 |
private int commonMicrobesBuild = 1; |
| 4434 |
|
| 4435 |
private String otherMicrobesPath = "RQCFILTER_PATH/otherMicrobes/"; |
| 4436 |
private String otherMicrobesRef = "RQCFILTER_PATH/otherMicrobes/fusedEmasked.fa.gz"; |
| 4437 |
private int otherMicrobesBuild = 1; |
| 4438 |
|
| 4439 |
private String taxTreeFile="RQCFILTER_PATH/tree.taxtree.gz"; |
| 4440 |
private String giTable=null; |
| 4441 |
|
| 4442 |
private boolean pairedToSingle=false; |
| 4443 |
|
| 4444 |
|
| 4445 |
|
| 4446 |
|
| 4447 |
|
| 4448 |
|
| 4449 |
private static final int FRAG=0, LFPE=1, CLIP=2, CLRS=3; |
| 4450 |
private static final String clipLinkerDefault = "CATG"; |
| 4451 |
|
| 4452 |
} |