Commit 020ffb1f authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Switch to method for adapters

parent 600c5f11
......@@ -28,12 +28,15 @@ import nl.lumc.sasc.biopet.core.config.Configurable
import scala.collection.mutable.Map
class Cutadapt(root: Configurable) extends nl.lumc.sasc.biopet.extensions.Cutadapt(root) {
@Input(doc = "Fastq contams file", required = false)
var contams_file: File = _
var fastqc: Fastqc = _
override def beforeCmd() {
super.beforeCmd
getContamsFromFile
val foundAdapters = fastqc.getFoundAdapters.map(_.seq)
if (default_clip_mode == "3") opt_adapter ++= foundAdapters
else if (default_clip_mode == "5") opt_front ++= foundAdapters
else if (default_clip_mode == "both") opt_anywhere ++= foundAdapters
}
override def cmdLine = {
......@@ -46,24 +49,6 @@ class Cutadapt(root: Configurable) extends nl.lumc.sasc.biopet.extensions.Cutada
}
}
def getContamsFromFile {
if (contams_file != null) {
if (contams_file.exists()) {
for (line <- Source.fromFile(contams_file).getLines) {
var s: String = line.substring(line.lastIndexOf("\t") + 1, line.size)
if (default_clip_mode == "3") opt_adapter += s
else if (default_clip_mode == "5") opt_front += s
else if (default_clip_mode == "both") opt_anywhere += s
else {
opt_adapter += s
logger.warn("Option default_clip_mode should be '3', '5' or 'both', falling back to default: '3'")
}
logger.info("Adapter: " + s + " found in: " + fastq_input)
}
} else logger.warn("File : " + contams_file + " does not exist")
}
}
def getSummary: Json = {
val trimR = """.*Trimmed reads: *(\d*) .*""".r
val tooShortR = """.*Too short reads: *(\d*) .*""".r
......
......@@ -101,7 +101,6 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
add(fastqc_R1)
summary.addFastqc(fastqc_R1)
outputFiles += ("fastqc_R1" -> fastqc_R1.output)
outputFiles += ("contams_R1" -> getContams(fastqc_R1, R1_name))
val md5sum_R1 = Md5sum(this, input_R1, outputDir)
add(md5sum_R1)
......@@ -112,7 +111,6 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
add(fastqc_R2)
summary.addFastqc(fastqc_R2, R2 = true)
outputFiles += ("fastqc_R2" -> fastqc_R2.output)
outputFiles += ("contams_R2" -> getContams(fastqc_R2, R2_name))
val md5sum_R2 = Md5sum(this, input_R2, outputDir)
add(md5sum_R2)
......@@ -120,15 +118,6 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
}
}
def getContams(fastqc: Fastqc, pairname: String): File = {
val fastqcToContams = new FastqcToContams(this)
fastqcToContams.fastqc_output = fastqc.output
fastqcToContams.out = new File(outputDir + pairname + ".contams.txt")
fastqcToContams.contams_file = fastqc.contaminants
add(fastqcToContams)
return fastqcToContams.out
}
def runTrimClip(R1_in: File, outDir: String, chunk: String): (File, File, List[File]) = {
runTrimClip(R1_in, new File(""), outDir, chunk)
}
......@@ -146,13 +135,13 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
var R2: File = new File(R2_in)
var deps: List[File] = if (paired) List(R1, R2) else List(R1)
val seqtkSeq_R1 = SeqtkSeq.apply(this, R1, swapExt(outDir, R1, R1_ext, ".sanger" + R1_ext), fastqc_R1)
val seqtkSeq_R1 = SeqtkSeq(this, R1, swapExt(outDir, R1, R1_ext, ".sanger" + R1_ext), fastqc_R1)
add(seqtkSeq_R1, isIntermediate = true)
R1 = seqtkSeq_R1.output
deps ::= R1
if (paired) {
val seqtkSeq_R2 = SeqtkSeq.apply(this, R2, swapExt(outDir, R2, R2_ext, ".sanger" + R2_ext), fastqc_R2)
val seqtkSeq_R2 = SeqtkSeq(this, R2, swapExt(outDir, R2, R2_ext, ".sanger" + R2_ext), fastqc_R2)
add(seqtkSeq_R2, isIntermediate = true)
R2 = seqtkSeq_R2.output
deps ::= R2
......@@ -171,7 +160,7 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
if (!skipClip) { // Adapter clipping
val cutadapt_R1 = Cutadapt(this, R1, swapExt(outDir, R1, R1_ext, ".clip" + R1_ext))
if (outputFiles.contains("contams_R1")) cutadapt_R1.contams_file = outputFiles("contams_R1")
cutadapt_R1.fastqc = fastqc_R1
add(cutadapt_R1, isIntermediate = true)
summary.addCutadapt(cutadapt_R1, R2 = false, chunk)
R1 = cutadapt_R1.fastq_output
......@@ -181,7 +170,7 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
if (paired) {
val cutadapt_R2 = Cutadapt(this, R2, swapExt(outDir, R2, R2_ext, ".clip" + R2_ext))
outputFiles += ("cutadapt_R2_stats" -> cutadapt_R2.stats_output)
if (outputFiles.contains("contams_R2")) cutadapt_R2.contams_file = outputFiles("contams_R2")
cutadapt_R2.fastqc = fastqc_R2
add(cutadapt_R2, isIntermediate = true)
summary.addCutadapt(cutadapt_R2, R2 = true, chunk)
R2 = cutadapt_R2.fastq_output
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment