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

Add automatic sample detection

parent 6362081c
......@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.tools
import java.io.File
import java.io.PrintWriter
import htsjdk.samtools.SamReaderFactory
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.ToolCommand
import nl.lumc.sasc.biopet.core.config.Configurable
......@@ -59,6 +60,16 @@ class MpileupToVcf(val root: Configurable) extends BiopetJavaCommandLineFunction
val samtoolsMpileup = new SamtoolsMpileup(this)
}
override def beforeCmd: Unit = {
if (sample == null && inputBam.exists()) {
val inputSam = SamReaderFactory.makeDefault.open(inputBam)
val readGroups = inputSam.getFileHeader.getReadGroups
val samples = readGroups.map(readGroup => readGroup.getSample).distinct
sample = samples.head
inputSam.close
}
}
override def commandLine = {
(if (inputMpileup == null) {
val samtoolsMpileup = new SamtoolsMpileup(this)
......
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