Skip to content
Snippets Groups Projects
Commit 7339ef7b authored by bow's avatar bow
Browse files

Merge branch 'patch-mapping' into 'develop'

Patch mapping

Fix for #122

See merge request !120
parents 6b6fa613 780ab2df
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ import java.io.File ...@@ -20,7 +20,7 @@ import java.io.File
import java.util.Date import java.util.Date
import nl.lumc.sasc.biopet.core.summary.SummaryQScript import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ SampleLibraryTag, BiopetQScript, PipelineCommand } import nl.lumc.sasc.biopet.core.{ SampleLibraryTag, BiopetQScript, PipelineCommand }
import nl.lumc.sasc.biopet.extensions.{ Ln, Star, Stampy, Bowtie } import nl.lumc.sasc.biopet.extensions._
import nl.lumc.sasc.biopet.extensions.bwa.{ BwaSamse, BwaSampe, BwaAln, BwaMem } import nl.lumc.sasc.biopet.extensions.bwa.{ BwaSamse, BwaSampe, BwaAln, BwaMem }
import nl.lumc.sasc.biopet.pipelines.bamtobigwig.Bam2Wig import nl.lumc.sasc.biopet.pipelines.bamtobigwig.Bam2Wig
import nl.lumc.sasc.biopet.tools.FastqSplitter import nl.lumc.sasc.biopet.tools.FastqSplitter
...@@ -163,9 +163,14 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S ...@@ -163,9 +163,14 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
chunks += (chunkDir -> (removeGz(chunkDir + input_R1.getName), chunks += (chunkDir -> (removeGz(chunkDir + input_R1.getName),
if (paired) removeGz(chunkDir + input_R2.get.getName) else "")) if (paired) removeGz(chunkDir + input_R2.get.getName) else ""))
} }
else chunks += (outputDir -> ( else if (skipFlexiprep) {
flexiprep.extractIfNeeded(input_R1, flexiprep.outputDir), chunks += (outputDir -> (
if (paired) flexiprep.extractIfNeeded(input_R2.get, flexiprep.outputDir) else "") extractIfNeeded(input_R1, flexiprep.outputDir),
if (paired) extractIfNeeded(input_R2.get, outputDir) else "")
)
} else chunks += (outputDir -> (
flexiprep.outputFiles("fastq_input_R1"),
if (paired) flexiprep.outputFiles("fastq_input_R2") else "")
) )
if (chunking) { if (chunking) {
...@@ -441,6 +446,32 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S ...@@ -441,6 +446,32 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
return RG.substring(0, RG.lastIndexOf("\\t")) return RG.substring(0, RG.lastIndexOf("\\t"))
} }
//FIXME: This is code duplication from flexiprep, need general class to pass jobs inside a util function
/**
* Extracts file if file is compressed
* @param file
* @param runDir
* @return returns extracted file
*/
def extractIfNeeded(file: File, runDir: File): File = {
if (file == null) return file
else if (file.getName().endsWith(".gz") || file.getName().endsWith(".gzip")) {
var newFile: File = swapExt(runDir, file, ".gz", "")
if (file.getName().endsWith(".gzip")) newFile = swapExt(runDir, file, ".gzip", "")
val zcatCommand = Zcat(this, file, newFile)
zcatCommand.isIntermediate = true
add(zcatCommand)
return newFile
} else if (file.getName().endsWith(".bz2")) {
val newFile = swapExt(runDir, file, ".bz2", "")
val pbzip2 = Pbzip2(this, file, newFile)
pbzip2.isIntermediate = true
add(pbzip2)
return newFile
} else return file
}
} }
object Mapping extends PipelineCommand object Mapping extends PipelineCommand
\ No newline at end of file
...@@ -37,18 +37,23 @@ class MappingTest extends TestNGSuite with Matchers { ...@@ -37,18 +37,23 @@ class MappingTest extends TestNGSuite with Matchers {
val chunks = Array(1, 5, 10, 100) val chunks = Array(1, 5, 10, 100)
val skipMarkDuplicates = Array(true, false) val skipMarkDuplicates = Array(true, false)
val skipFlexipreps = Array(true, false) val skipFlexipreps = Array(true, false)
val zipped = Array(true, false)
for ( for (
aligner <- aligners; aligner <- aligners;
pair <- paired; pair <- paired;
chunk <- chunks; chunk <- chunks;
skipMarkDuplicate <- skipMarkDuplicates; skipMarkDuplicate <- skipMarkDuplicates;
skipFlexiprep <- skipFlexipreps skipFlexiprep <- skipFlexipreps;
) yield Array(aligner, pair, chunk, skipMarkDuplicate, skipFlexiprep) zipped <- zipped
) yield Array(aligner, pair, chunk, skipMarkDuplicate, skipFlexiprep, zipped)
} }
@Test(dataProvider = "mappingOptions") @Test(dataProvider = "mappingOptions")
def testMapping(aligner: String, paired: Boolean, chunks: Int, skipMarkDuplicate: Boolean, skipFlexiprep: Boolean) = { def testMapping(aligner: String, paired: Boolean, chunks: Int,
skipMarkDuplicate: Boolean,
skipFlexiprep: Boolean,
zipped: Boolean) = {
val map = ConfigUtils.mergeMaps(Map("output_dir" -> MappingTest.outputDir, val map = ConfigUtils.mergeMaps(Map("output_dir" -> MappingTest.outputDir,
"aligner" -> aligner, "aligner" -> aligner,
"number_chunks" -> chunks, "number_chunks" -> chunks,
...@@ -57,15 +62,20 @@ class MappingTest extends TestNGSuite with Matchers { ...@@ -57,15 +62,20 @@ class MappingTest extends TestNGSuite with Matchers {
), Map(MappingTest.executables.toSeq: _*)) ), Map(MappingTest.executables.toSeq: _*))
val mapping: Mapping = initPipeline(map) val mapping: Mapping = initPipeline(map)
mapping.input_R1 = new File(mapping.outputDir, "bla_R1.fq") if (zipped) {
if (paired) mapping.input_R2 = Some(new File(mapping.outputDir, "bla_R2.fq")) mapping.input_R1 = new File(mapping.outputDir, "bla_R1.fq.gz")
if (paired) mapping.input_R2 = Some(new File(mapping.outputDir, "bla_R2.fq.gz"))
} else {
mapping.input_R1 = new File(mapping.outputDir, "bla_R1.fq")
if (paired) mapping.input_R2 = Some(new File(mapping.outputDir, "bla_R2.fq"))
}
mapping.sampleId = Some("1") mapping.sampleId = Some("1")
mapping.libId = Some("1") mapping.libId = Some("1")
mapping.script() mapping.script()
//Flexiprep //Flexiprep
mapping.functions.count(_.isInstanceOf[Fastqc]) shouldBe (if (skipFlexiprep) 0 else if (paired) 4 else 2) mapping.functions.count(_.isInstanceOf[Fastqc]) shouldBe (if (skipFlexiprep) 0 else if (paired) 4 else 2)
mapping.functions.count(_.isInstanceOf[Zcat]) shouldBe 0 mapping.functions.count(_.isInstanceOf[Zcat]) shouldBe (if (!zipped || (chunks > 1 && skipFlexiprep)) 0 else if (paired) 2 else 1)
mapping.functions.count(_.isInstanceOf[Seqstat]) shouldBe ((if (skipFlexiprep) 0 else if (paired) 4 else 2) * chunks) mapping.functions.count(_.isInstanceOf[Seqstat]) shouldBe ((if (skipFlexiprep) 0 else if (paired) 4 else 2) * chunks)
mapping.functions.count(_.isInstanceOf[SeqtkSeq]) shouldBe ((if (skipFlexiprep) 0 else if (paired) 2 else 1) * chunks) mapping.functions.count(_.isInstanceOf[SeqtkSeq]) shouldBe ((if (skipFlexiprep) 0 else if (paired) 2 else 1) * chunks)
mapping.functions.count(_.isInstanceOf[Cutadapt]) shouldBe ((if (skipFlexiprep) 0 else if (paired) 2 else 1) * chunks) mapping.functions.count(_.isInstanceOf[Cutadapt]) shouldBe ((if (skipFlexiprep) 0 else if (paired) 2 else 1) * chunks)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment