Commit 20871e07 authored by sajvanderzeeuw's avatar sajvanderzeeuw
Browse files

Merge commit '18e080e1' into sander

parents d0768d9f 18e080e1
......@@ -50,8 +50,9 @@ object BiopetFlagstat extends Logging {
val max = 60
for (t <- 0 to (max / m))
flagstatCollector.addFunction("MAPQ>" + (t * m), record => record.getMappingQuality > (t * m))
flagstatCollector.addFunction("First normal, second read inverted (paired end orientation)", record => {
if (record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag != record.getMateNegativeStrandFlag &&
flagstatCollector.addFunction("First normal, second read inverted (paired end orientation)", record => {
if (record.getReadPairedFlag &&
record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag != record.getMateNegativeStrandFlag &&
((record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
......@@ -59,7 +60,8 @@ object BiopetFlagstat extends Logging {
else false
})
flagstatCollector.addFunction("First normal, second read normal", record => {
if (record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag == record.getMateNegativeStrandFlag &&
if (record.getReadPairedFlag &&
record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag == record.getMateNegativeStrandFlag &&
((record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
......@@ -67,7 +69,8 @@ object BiopetFlagstat extends Logging {
else false
})
flagstatCollector.addFunction("First inverted, second read inverted", record => {
if (record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag == record.getMateNegativeStrandFlag &&
if (record.getReadPairedFlag &&
record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag == record.getMateNegativeStrandFlag &&
((record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
......@@ -75,16 +78,17 @@ object BiopetFlagstat extends Logging {
else false
})
flagstatCollector.addFunction("First inverted, second read normal", record => {
if (record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag != record.getMateNegativeStrandFlag &&
if (record.getReadPairedFlag &&
record.getReferenceIndex == record.getMateReferenceIndex && record.getReadNegativeStrandFlag != record.getMateNegativeStrandFlag &&
((record.getFirstOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getFirstOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && record.getReadNegativeStrandFlag && record.getAlignmentStart < record.getMateAlignmentStart) ||
(record.getSecondOfPairFlag && !record.getReadNegativeStrandFlag && record.getAlignmentStart > record.getMateAlignmentStart))) true
else false
})
flagstatCollector.addFunction("Mate in same strand", record => record.getReadNegativeStrandFlag && record.getMateNegativeStrandFlag &&
flagstatCollector.addFunction("Mate in same strand", record => record.getReadPairedFlag && record.getReadNegativeStrandFlag && record.getMateNegativeStrandFlag &&
record.getReferenceIndex == record.getMateReferenceIndex)
flagstatCollector.addFunction("Mate on other chr", record => record.getReferenceIndex != record.getMateReferenceIndex)
flagstatCollector.addFunction("Mate on other chr", record => record.getReadPairedFlag && record.getReferenceIndex != record.getMateReferenceIndex)
for (record <- inputSam.iterator) {
if (flagstatCollector.readsCount % 1e6 == 0 && flagstatCollector.readsCount > 0)
......@@ -107,18 +111,18 @@ object BiopetFlagstat extends Logging {
addFunction("All", record => true)
addFunction("Mapped", record => !record.getReadUnmappedFlag)
addFunction("Duplicates", record => record.getDuplicateReadFlag)
addFunction("FirstOfPair", record => record.getFirstOfPairFlag)
addFunction("SecondOfPair", record => record.getSecondOfPairFlag)
addFunction("FirstOfPair", record => if (record.getReadPairedFlag) record.getFirstOfPairFlag else false)
addFunction("SecondOfPair", record => if (record.getReadPairedFlag) record.getSecondOfPairFlag else false)
addFunction("ReadNegativeStrand", record => record.getReadNegativeStrandFlag)
addFunction("NotPrimaryAlignment", record => record.getNotPrimaryAlignmentFlag)
addFunction("ReadPaired", record => record.getReadPairedFlag)
addFunction("ProperPair", record => record.getProperPairFlag)
addFunction("ProperPair", record => if (record.getReadPairedFlag) record.getProperPairFlag else false)
addFunction("MateNegativeStrand", record => record.getMateNegativeStrandFlag)
addFunction("MateUnmapped", record => record.getMateUnmappedFlag)
addFunction("MateNegativeStrand", record => if (record.getReadPairedFlag) record.getMateNegativeStrandFlag else false)
addFunction("MateUnmapped", record => if (record.getReadPairedFlag) record.getMateUnmappedFlag else false)
addFunction("ReadFailsVendorQualityCheck", record => record.getReadFailsVendorQualityCheckFlag)
addFunction("SupplementaryAlignment", record => record.getSupplementaryAlignmentFlag)
......
......@@ -27,12 +27,12 @@ class Config(var map: Map[String, Any]) extends Logging {
logger.debug("Jsonfile: " + configFile)
val jsonText = scala.io.Source.fromFile(configFile).mkString
val json = Parse.parseOption(jsonText)
if (json == None) {
throw new IllegalStateException("The config JSON file is either not properly formatted or not a JSON file, file: " + configFile)
}
logger.debug(json)
val configJson = jsonToMap(json.get)
logger.debug("Contain: " + configJson)
if (configJson == None) {
throw new IllegalStateException("The config JSON file is either not properly formatted or not a JSON file, file: " + configFile)
}
if (map.isEmpty) map = configJson
else map = Config.mergeMaps(configJson, map)
......
......@@ -25,9 +25,9 @@ trait Picard extends BiopetJavaCommandLineFunction {
@Argument(doc = "CREATE_MD5_FILE", required = false)
var createMd5: Boolean = config("createmd5", default = false, submodule = "picard")
override def versionCommand = executable + " " + javaOpts + " " + javaExecutable + " -h"
override val versionRegex = """Version: (.*)""".r
override val versionExitcode = List(0, 1)
// override def versionCommand = executable + " " + javaOpts + " " + javaExecutable + " -h"
// override val versionRegex = """Version: (.*)""".r
// override val versionExitcode = List(0, 1)
override val defaultVmem = "8G"
memoryLimit = Option(5.0)
......
......@@ -75,6 +75,8 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
var RGPI: Int = _
var paired: Boolean = false
val flexiprep = new Flexiprep(this)
def init() {
for (file <- configfiles) globalConfig.loadConfigFile(file)
......@@ -123,7 +125,6 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
def biopetScript() {
var fastq_R1: File = input_R1
var fastq_R2: File = if (paired) input_R2 else ""
val flexiprep = new Flexiprep(this)
if (!skipFlexiprep) {
flexiprep.outputDir = outputDir + "flexiprep/"
flexiprep.input_R1 = fastq_R1
......@@ -144,11 +145,11 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
}
var chunks: Map[String, (String, String)] = Map()
if (chunking) for (t <- 1 to numberChunks.getOrElse(1)) {
chunks += ("chunk_" + t -> (removeGz(outputDir + "chunk_" + t + "/" + fastq_R1.getName),
if (paired) removeGz(outputDir + "chunk_" + t + "/" + fastq_R2.getName) else ""))
}
else chunks += ("flexiprep" -> (flexiprep.extractIfNeeded(fastq_R1, flexiprep.outputDir),
flexiprep.extractIfNeeded(fastq_R2, flexiprep.outputDir)))
val chunkDir = "chunks/" + t + "/"
chunks += (chunkDir -> (removeGz(chunkDir + fastq_R1.getName),
if (paired) removeGz(chunkDir + fastq_R2.getName) else ""))
} else chunks += ("flexiprep/" -> (flexiprep.extractIfNeeded(fastq_R1, flexiprep.outputDir),
flexiprep.extractIfNeeded(fastq_R2, flexiprep.outputDir)))
if (chunking) {
val fastSplitter_R1 = new FastqSplitter(this)
......@@ -172,7 +173,7 @@ class Mapping(val root: Configurable) extends QScript with BiopetQScript {
var R1 = fastqfile._1
var R2 = fastqfile._2
var deps: List[File] = Nil
val chunkDir = if (chunking) outputDir + chunk + "/" else outputDir
val chunkDir = if (chunking) outputDir + chunk else outputDir
if (!skipFlexiprep) {
val flexiout = flexiprep.runTrimClip(R1, R2, chunkDir + "flexiprep/", chunk)
logger.debug(chunk + " - " + flexiout)
......
Supports Markdown
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