Commit 18cee8f8 authored by Sander Bollen's avatar Sander Bollen

Merge branch 'fix-BIOPET-481' into 'develop'

Fixing BIOPET-481



See merge request !486
parents 057f8873 2373dae2
......@@ -14,7 +14,7 @@
*/
package nl.lumc.sasc.biopet.utils
import java.io.{File, PrintWriter}
import java.io.{ File, PrintWriter }
import java.util
import argonaut.Argonaut._
......
......@@ -15,6 +15,7 @@
package nl.lumc.sasc.biopet
import scala.util.{ Failure, Success, Try }
import scala.math._
/**
* General utility functions.
......@@ -29,6 +30,15 @@ package object utils {
/** Regular expression for matching entire decimal numbers (compatible with the scientific notation) */
val isDecimal = """^([-+]?\d*\.?\d+(?:[eE][-+]?[0-9]+)?)$""".r
def textToSize(text: String): Long = {
text.last match {
case 'g' | 'G' => ((1L << 30) * text.stripSuffix("g").stripSuffix("G").toDouble).toLong
case 'm' | 'M' => ((1L << 20) * text.stripSuffix("g").stripSuffix("G").toDouble).toLong
case 'k' | 'K' => ((1L << 10) * text.stripSuffix("g").stripSuffix("G").toDouble).toLong
case _ => text.toLong
}
}
/**
* Tries to convert the given string with the given conversion functions recursively.
*
......
......@@ -19,11 +19,11 @@ import java.util.Date
import nl.lumc.sasc.biopet.core._
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.bowtie.{ Bowtie2, Bowtie }
import nl.lumc.sasc.biopet.extensions.bwa.{ BwaAln, BwaMem, BwaSampe, BwaSamse }
import nl.lumc.sasc.biopet.extensions.bowtie.{Bowtie, Bowtie2}
import nl.lumc.sasc.biopet.extensions.bwa.{BwaAln, BwaMem, BwaSampe, BwaSamse}
import nl.lumc.sasc.biopet.extensions.gmap.Gsnap
import nl.lumc.sasc.biopet.extensions.hisat.Hisat2
import nl.lumc.sasc.biopet.extensions.picard.{ AddOrReplaceReadGroups, MarkDuplicates, MergeSamFiles, ReorderSam, SortSam }
import nl.lumc.sasc.biopet.extensions.picard.{AddOrReplaceReadGroups, MarkDuplicates, MergeSamFiles, ReorderSam, SortSam}
import nl.lumc.sasc.biopet.extensions.tools.FastqSplitter
import nl.lumc.sasc.biopet.extensions._
import nl.lumc.sasc.biopet.pipelines.bammetrics.BamMetrics
......@@ -31,6 +31,7 @@ import nl.lumc.sasc.biopet.pipelines.bamtobigwig.Bam2Wig
import nl.lumc.sasc.biopet.pipelines.flexiprep.Flexiprep
import nl.lumc.sasc.biopet.pipelines.gears.GearsSingle
import nl.lumc.sasc.biopet.pipelines.mapping.scripts.TophatRecondition
import nl.lumc.sasc.biopet.utils.textToSize
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript
......@@ -163,10 +164,10 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
if (numberChunks.isEmpty) {
if (config.contains("numberchunks")) numberChunks = config("numberchunks", default = None)
else {
val chunkSize: Int = config("chunksize", 1 << 30)
val chunkSize: String = config("chunksize", default = "5G")
val filesize = if (inputR1.getName.endsWith(".gz") || inputR1.getName.endsWith(".gzip")) inputR1.length * 3
else inputR1.length
numberChunks = Option(ceil(filesize.toDouble / chunkSize).toInt)
numberChunks = Option(ceil(filesize.toDouble / textToSize(chunkSize)).toInt)
}
}
logger.debug("Chunks: " + numberChunks.getOrElse(1))
......
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