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

Biopet core code inspection round

parent c181bccd
......@@ -73,7 +73,7 @@ class PedigreeQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testIsMother() = {
def testIsMother(): Unit = {
val script = PedigreeQScriptTest(trioPed :: Nil)
script.init()
script.biopetScript()
......@@ -82,7 +82,7 @@ class PedigreeQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testIsFather() = {
def testIsFather(): Unit = {
val script = PedigreeQScriptTest(trioPed :: Nil)
script.init()
script.biopetScript()
......@@ -91,7 +91,7 @@ class PedigreeQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testIsTrio() = {
def testIsTrio(): Unit = {
val script = PedigreeQScriptTest(trioPed :: Nil)
script.init()
script.biopetScript()
......@@ -106,7 +106,7 @@ class PedigreeQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testConcatenation() = {
def testConcatenation(): Unit = {
val script = PedigreeQScriptTest(sample1 :: sample2 :: sample3 :: trioPed :: Nil)
script.init()
script.biopetScript()
......@@ -171,13 +171,18 @@ object PedigreeQScriptTest {
val trioPed = Map("ped_file" -> resourcePath("/trio.ped"))
def apply(configs: List[Map[String, Any]], only: List[String] = Nil) = {
def apply(configs: List[Map[String, Any]], only: List[String] = Nil): QScript with PedigreeQscript {
def init(): Unit
def biopetScript(): Unit
} = {
new QScript with PedigreeQscript { qscript =>
qSettings = new QSettings()
qSettings.runName = "test"
override val onlySamples = only
override val onlySamples: List[String] = only
var buffer = new ListBuffer[String]()
......
......@@ -26,10 +26,10 @@ import scala.language.reflectiveCalls
*/
class PipelineCommandTest extends TestNGSuite with Matchers {
@Test
def testPipelineCommand: Unit = {
def testPipelineCommand(): Unit = {
val pipeline = new PipelineCommand {
override val globalConfig = new Config(Map())
def getConfig = globalConfig
def getConfig: Config = globalConfig
}
pipeline.pipelineName shouldBe this.getClass.getSimpleName.toLowerCase
......
......@@ -32,7 +32,7 @@ class ReferenceTest extends TestNGSuite with Matchers {
import ReferenceTest._
@Test
def testDefault: Unit = {
def testDefault(): Unit = {
Logging.errors.clear()
make(config :: testReferenceNoIndex :: Nil).referenceFasta()
Logging.checkErrors(true)
......@@ -42,7 +42,7 @@ class ReferenceTest extends TestNGSuite with Matchers {
}
@Test
def testIndexes: Unit = {
def testIndexes(): Unit = {
make(config :: testReferenceNoIndex :: Nil, fai = true, dict = true).referenceFasta()
intercept[IllegalStateException] {
......@@ -60,7 +60,7 @@ class ReferenceTest extends TestNGSuite with Matchers {
}
@Test
def testDbpsnp: Unit = {
def testDbpsnp(): Unit = {
val a = make(config :: Map("dbsnp_version" -> 1) :: testReferenceNoIndex :: Nil,
fai = true,
dict = true)
......@@ -111,12 +111,12 @@ object ReferenceTest {
r: Configurable = null,
fai: Boolean = false,
dict: Boolean = false) = new Reference {
val parent = r
val parent: Configurable = r
override def globalConfig =
new Config(
configs
.foldLeft(Map[String, Any]()) { case (a, b) => ConfigUtils.mergeMaps(a, b) })
override def dictRequired = if (dict) true else super.dictRequired
override def faiRequired = if (fai) true else super.faiRequired
override def dictRequired: Boolean = if (dict) true else super.dictRequired
override def faiRequired: Boolean = if (fai) true else super.faiRequired
}
}
......@@ -24,7 +24,7 @@ import org.testng.annotations.Test
*/
class SampleLibraryTagTest extends TestNGSuite with Matchers {
@Test
def testDefault: Unit = {
def testDefault(): Unit = {
val o = new SampleLibraryTag {
override def parent: Configurable = null
override def globalConfig = new Config(Map())
......@@ -34,7 +34,7 @@ class SampleLibraryTagTest extends TestNGSuite with Matchers {
}
@Test
def testInherit: Unit = {
def testInherit(): Unit = {
val o1 = new SampleLibraryTag {
override def parent: Configurable = null
override def globalConfig = new Config(Map())
......
......@@ -24,7 +24,7 @@ import nl.lumc.sasc.biopet.FullVersion
*/
class ToolCommandTest extends TestNGSuite with Matchers {
@Test
def testToolCommand: Unit = {
def testToolCommand(): Unit = {
val tool = new ToolCommandFunction {
def parent = null
def toolObject = ToolCommandTest
......@@ -33,7 +33,7 @@ class ToolCommandTest extends TestNGSuite with Matchers {
tool.versionCommand shouldBe empty
tool.versionRegex.toString() shouldBe empty
tool.getVersion shouldBe Some("Biopet " + FullVersion)
tool.beforeGraph
tool.beforeGraph()
tool.javaMainClass shouldBe ToolCommandTest.getClass.getName.takeWhile(_ != '$')
}
......
......@@ -31,10 +31,10 @@ class WriteDependenciesTest extends TestNGSuite with Matchers {
import WriteDependenciesTest._
case class Qfunc(in: Seq[File], out: Seq[File]) extends QFunction {
override def inputs = in
override def outputs = out
override def doneOutputs = out.map(x => new File(x.getParentFile, s".${x.getName}.done"))
override def failOutputs = out.map(x => new File(x.getParentFile, s".${x.getName}.fail"))
override def inputs: Seq[File] = in
override def outputs: Seq[File] = out
override def doneOutputs: Seq[File] = out.map(x => new File(x.getParentFile, s".${x.getName}.done"))
override def failOutputs: Seq[File] = out.map(x => new File(x.getParentFile, s".${x.getName}.fail"))
jobOutputFile = new File(out.head + ".out")
}
......@@ -60,19 +60,19 @@ class WriteDependenciesTest extends TestNGSuite with Matchers {
assert(paths.contains(file3.toString))
files
.find(_.get("path") == Some(file1.toString))
.find(_.get("path").contains(file1.toString))
.flatMap(_.get("pipeline_input")) shouldBe Some(true)
files
.find(_.get("path") == Some(file2.toString))
.find(_.get("path").contains(file2.toString))
.flatMap(_.get("pipeline_input")) shouldBe Some(false)
files
.find(_.get("path") == Some(file3.toString))
.find(_.get("path").contains(file3.toString))
.flatMap(_.get("pipeline_input")) shouldBe Some(false)
}
}
object WriteDependenciesTest {
val tempDir = Files.createTempDir()
val tempDir: File = Files.createTempDir()
tempDir.deleteOnExit()
val file1 = new File(tempDir, "file1.txt")
val file2 = new File(tempDir, "file2.txt")
......
......@@ -30,7 +30,7 @@ import org.testng.annotations.Test
*/
class AnnotationTest extends TestNGSuite with Matchers {
@Test
def testAnnotationGtf: Unit = {
def testAnnotationGtf(): Unit = {
val s1 = new AnnotationTest.Script(AnnotationTest.config) with AnnotationGtf
s1.annotationGtf shouldBe new File("")
an[IllegalStateException] shouldBe thrownBy(Logging.checkErrors())
......@@ -38,18 +38,18 @@ class AnnotationTest extends TestNGSuite with Matchers {
val s2 = new AnnotationTest.Script(
AnnotationTest.config ++ Map("species" -> "s1", "reference_name" -> "g1")) with AnnotationGtf
s2.annotationGtf shouldBe new File("no_set.gtf")
noException should be thrownBy (Logging.checkErrors())
noException should be thrownBy Logging.checkErrors()
val s3 = new AnnotationTest.Script(
AnnotationTest.config ++ Map("species" -> "s1",
"reference_name" -> "g1",
"gene_annotation_name" -> "set1")) with AnnotationGtf
s3.annotationGtf shouldBe new File("set1.gtf")
noException should be thrownBy (Logging.checkErrors())
noException should be thrownBy Logging.checkErrors()
}
@Test
def testAnnotationGff: Unit = {
def testAnnotationGff(): Unit = {
val s1 = new AnnotationTest.Script(AnnotationTest.config) with AnnotationGff
s1.annotationGff shouldBe new File("")
an[IllegalStateException] shouldBe thrownBy(Logging.checkErrors())
......@@ -57,18 +57,18 @@ class AnnotationTest extends TestNGSuite with Matchers {
val s2 = new AnnotationTest.Script(
AnnotationTest.config ++ Map("species" -> "s1", "reference_name" -> "g1")) with AnnotationGff
s2.annotationGff shouldBe new File("no_set.gff")
noException should be thrownBy (Logging.checkErrors())
noException should be thrownBy Logging.checkErrors()
val s3 = new AnnotationTest.Script(
AnnotationTest.config ++ Map("species" -> "s1",
"reference_name" -> "g1",
"gene_annotation_name" -> "set1")) with AnnotationGff
s3.annotationGff shouldBe new File("set1.gff")
noException should be thrownBy (Logging.checkErrors())
noException should be thrownBy Logging.checkErrors()
}
@Test
def testAnnotationRefFlat: Unit = {
def testAnnotationRefFlat(): Unit = {
val s1 = new AnnotationTest.Script(AnnotationTest.config) with AnnotationRefFlat
s1.annotationRefFlat.get shouldBe new File("")
an[IllegalStateException] shouldBe thrownBy(Logging.checkErrors())
......@@ -77,14 +77,14 @@ class AnnotationTest extends TestNGSuite with Matchers {
AnnotationTest.config ++ Map("species" -> "s1", "reference_name" -> "g1"))
with AnnotationRefFlat
s2.annotationRefFlat.get shouldBe new File("no_set.refFlat")
noException should be thrownBy (Logging.checkErrors())
noException should be thrownBy Logging.checkErrors()
val s3 = new AnnotationTest.Script(
AnnotationTest.config ++ Map("species" -> "s1",
"reference_name" -> "g1",
"gene_annotation_name" -> "set1")) with AnnotationRefFlat
s3.annotationRefFlat.get shouldBe new File("set1.refFlat")
noException should be thrownBy (Logging.checkErrors())
noException should be thrownBy Logging.checkErrors()
}
}
......
......@@ -31,9 +31,6 @@ import scala.concurrent.duration.Duration
* Created by pjvanthof on 24/02/16.
*/
class MultisampleReportBuilderTest extends TestNGSuite with Matchers {
private def resourcePath(p: String): String = {
Paths.get(getClass.getResource(p).toURI).toString
}
@Test
def testGeneratePages(): Unit = {
......
......@@ -15,7 +15,6 @@
package nl.lumc.sasc.biopet.core.report
import java.io.File
import java.nio.file.Paths
import java.sql.Date
import com.google.common.io.Files
......@@ -32,16 +31,12 @@ import scala.concurrent.duration.Duration
*/
class ReportBuilderTest extends TestNGSuite with Matchers {
private def resourcePath(p: String): String = {
Paths.get(getClass.getResource(p).toURI).toString
}
@DataProvider(name = "testGeneratePages")
def generatePageProvider = {
def generatePageProvider: Array[Array[Any]] = {
val sample = Array(Some("sampleName"), None)
val lib = Array(Some("libName"), None)
val nested = Array(false, true)
for (s <- sample; l <- lib; n <- nested if (!(l.isDefined && s.isEmpty))) yield Array(s, l, n)
for (s <- sample; l <- lib; n <- nested if !(l.isDefined && s.isEmpty)) yield Array(s, l, n)
}
@Test(dataProvider = "testGeneratePages")
......@@ -51,7 +46,7 @@ class ReportBuilderTest extends TestNGSuite with Matchers {
def reportName: String = "test"
def indexPage: Future[ReportPage] =
Future(
ReportPage((if (nested) "p1" -> Future(ReportPage(Nil, Nil, Map())) :: Nil else Nil),
ReportPage(if (nested) "p1" -> Future(ReportPage(Nil, Nil, Map())) :: Nil else Nil,
Nil,
Map()))
}
......@@ -107,7 +102,7 @@ class ReportBuilderTest extends TestNGSuite with Matchers {
// }
@Test
def testRenderTemplate: Unit = {
def testRenderTemplate(): Unit = {
ReportBuilder.renderTemplate("/template.ssp", Map("arg" -> "test")) shouldBe "test"
ReportBuilder.renderTemplate("/template.ssp", Map("arg" -> "bla")) shouldBe "bla"
}
......
......@@ -24,7 +24,7 @@ import org.testng.annotations.Test
class ReportSectionTest extends TestNGSuite with Matchers {
@Test
def testSectionRender: Unit = {
def testSectionRender(): Unit = {
ReportSection("/template.ssp", Map("arg" -> "test")).render() shouldBe "test"
ReportSection("/template.ssp").render(Map("arg" -> "test")) shouldBe "test"
}
......
......@@ -25,7 +25,7 @@ import org.testng.annotations.Test
*/
class SummarizableTest extends TestNGSuite with Matchers {
@Test
def testDefaultMerge: Unit = {
def testDefaultMerge(): Unit = {
val summarizable = new Summarizable {
def summaryFiles: Map[String, File] = ???
def summaryStats: Any = ???
......@@ -35,11 +35,11 @@ class SummarizableTest extends TestNGSuite with Matchers {
}
}
def testOverrideMerge: Unit = {
def testOverrideMerge(): Unit = {
val summarizable = new Summarizable {
def summaryFiles: Map[String, File] = ???
def summaryStats: Any = ???
override def resolveSummaryConflict(v1: Any, v2: Any, key: String) = v1
override def resolveSummaryConflict(v1: Any, v2: Any, key: String): Any = v1
}
summarizable.resolveSummaryConflict("1", "1", "key") shouldBe "1"
}
......
......@@ -30,7 +30,7 @@ import SummaryQScriptTest._
*/
class SummaryQScriptTest extends TestNGSuite with Matchers {
@Test
def testNoJobs: Unit = {
def testNoJobs(): Unit = {
SummaryQScript.md5sumCache.clear()
val script = makeQscript()
script.addSummaryJobs()
......@@ -38,7 +38,7 @@ class SummaryQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testFiles: Unit = {
def testFiles(): Unit = {
SummaryQScript.md5sumCache.clear()
val file = new File(s".${File.separator}bla")
val script = makeQscript(files = Map("file" -> file))
......@@ -55,7 +55,7 @@ class SummaryQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testDuplicateFiles: Unit = {
def testDuplicateFiles(): Unit = {
SummaryQScript.md5sumCache.clear()
val file = new File(s".${File.separator}bla")
val script = makeQscript(files = Map("file" -> file, "file2" -> file))
......@@ -72,7 +72,7 @@ class SummaryQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testAddSummarizable: Unit = {
def testAddSummarizable(): Unit = {
SummaryQScript.md5sumCache.clear()
val file = new File(s".${File.separator}bla")
val script = makeQscript()
......@@ -91,7 +91,7 @@ class SummaryQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testInputFile: Unit = {
def testInputFile(): Unit = {
SummaryQScript.md5sumCache.clear()
val file = new File(s".${File.separator}bla")
val script = makeQscript()
......@@ -112,7 +112,7 @@ class SummaryQScriptTest extends TestNGSuite with Matchers {
}
@Test
def testAddQscript: Unit = {
def testAddQscript(): Unit = {
SummaryQScript.md5sumCache.clear()
val script = makeQscript()
script.addSummaryQScript(script)
......@@ -129,7 +129,7 @@ object SummaryQScriptTest {
override def globalConfig = new Config(c)
def summarySettings: Map[String, Any] = settings
def summaryFiles: Map[String, File] = files
val tempFile = File.createTempFile("summary", ".json")
val tempFile: File = File.createTempFile("summary", ".json")
tempFile.deleteOnExit()
def summaryFile: File = tempFile
def init(): Unit = ???
......
......@@ -41,7 +41,7 @@ import scala.util.matching.Regex
class WriteSummaryTest extends TestNGSuite with Matchers {
@Test
def testCreateFile: Unit = {
def testCreateFile(): Unit = {
val dbFile = File.createTempFile("summary.", ".db")
dbFile.deleteOnExit()
val db = SummaryDb.openSqliteSummary(dbFile)
......@@ -295,7 +295,7 @@ class WriteSummaryTest extends TestNGSuite with Matchers {
}
@AfterClass
def removeDirs: Unit = {
def removeDirs(): Unit = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
......@@ -325,7 +325,7 @@ object WriteSummaryTest {
override def globalConfig = new Config(c)
def summarySettings: Map[String, Any] = settings
def summaryFiles: Map[String, File] = files
val tempFile = File.createTempFile("summary", ".json")
val tempFile: File = File.createTempFile("summary", ".json")
tempFile.deleteOnExit()
def summaryFile: File = tempFile
def init(): Unit = {}
......@@ -348,7 +348,7 @@ object WriteSummaryTest {
override def globalConfig = new Config(c + ("exe" -> "test"))
def summarySettings: Map[String, Any] = settings
def summaryFiles: Map[String, File] = files
val tempFile = File.createTempFile("summary", ".json")
val tempFile: File = File.createTempFile("summary", ".json")
tempFile.deleteOnExit()
def summaryFile: File = tempFile
def init(): Unit = {}
......@@ -367,7 +367,7 @@ object WriteSummaryTest {
override def globalConfig = new Config(c + ("exe" -> "test"))
def summarySettings: Map[String, Any] = settings
def summaryFiles: Map[String, File] = files
val tempFile = File.createTempFile("summary", ".json")
val tempFile: File = File.createTempFile("summary", ".json")
tempFile.deleteOnExit()
def summaryFile: File = tempFile
def init(): Unit = {}
......
......@@ -25,12 +25,12 @@ import org.testng.annotations.Test
*/
class VcfFilterTest extends TestNGSuite with Matchers {
def cmd(s: String) = {
def cmd(s: String): String = {
s.replace("'", "").replace(" ", " ").trim
}
@Test
def testBeforeGraph() = {
def testBeforeGraph(): Unit = {
val filterer = new VcfFilter(null)
val iVcf = File.createTempFile("vcfFilter", ".vcf.gz")
val oVcf = File.createTempFile("vcfFilter", ".vcf.gz")
......@@ -43,29 +43,29 @@ class VcfFilterTest extends TestNGSuite with Matchers {
filterer.outputVcfIndex.getAbsolutePath shouldBe oVcf.getAbsolutePath + ".tbi"
}
@Test def testMinSampleDepth() = testCommand(minSampleDepth = Some(2))
@Test def testMinTotalDepth() = testCommand(minTotalDepth = Some(2))
@Test def testMinAlternateDepth() = testCommand(minAlternateDepth = Some(2))
@Test def testMinSamplesPass() = testCommand(minSamplesPass = Some(2))
@Test def testMinGenomeQuality() = testCommand(minGenomeQuality = Some(50))
@Test def testFilterRefCalls() = testCommand(filterRefCalls = true)
@Test def testInvertedOutputVcf() =
@Test def testMinSampleDepth(): Unit = testCommand(minSampleDepth = Some(2))
@Test def testMinTotalDepth(): Unit = testCommand(minTotalDepth = Some(2))
@Test def testMinAlternateDepth(): Unit = testCommand(minAlternateDepth = Some(2))
@Test def testMinSamplesPass(): Unit = testCommand(minSamplesPass = Some(2))
@Test def testMinGenomeQuality(): Unit = testCommand(minGenomeQuality = Some(50))
@Test def testFilterRefCalls(): Unit = testCommand(filterRefCalls = true)
@Test def testInvertedOutputVcf(): Unit =
testCommand(invertedOutputVcf = Some(File.createTempFile("vcfFilter", ".vcf")))
@Test def testResToDom() = testCommand(resToDom = Some("dummy"))
@Test def testTrioCompound() = testCommand(trioCompound = Some("dummy"))
@Test def testDeNovoInSample() = testCommand(deNovoInSample = Some("dummy"))
@Test def testDeNovoTrio() = testCommand(deNovoTrio = Some("dummy"))
@Test def testTrioLossOfHet() = testCommand(trioLossOfHet = Some("dummy"))
@Test def testMustHaveVariant() = testCommand(mustHaveVariant = List("sample1", "sample2"))
@Test def testCalledIn() = testCommand(calledIn = List("sample1", "sample2"))
@Test def testMustHaveGenotype() =
@Test def testResToDom(): Unit = testCommand(resToDom = Some("dummy"))
@Test def testTrioCompound(): Unit = testCommand(trioCompound = Some("dummy"))
@Test def testDeNovoInSample(): Unit = testCommand(deNovoInSample = Some("dummy"))
@Test def testDeNovoTrio(): Unit = testCommand(deNovoTrio = Some("dummy"))
@Test def testTrioLossOfHet(): Unit = testCommand(trioLossOfHet = Some("dummy"))
@Test def testMustHaveVariant(): Unit = testCommand(mustHaveVariant = List("sample1", "sample2"))
@Test def testCalledIn(): Unit = testCommand(calledIn = List("sample1", "sample2"))
@Test def testMustHaveGenotype(): Unit =
testCommand(mustHaveGenotype = List("sample1:HET", "sample2:HET"))
@Test def testDiffGenotype() =
@Test def testDiffGenotype(): Unit =
testCommand(diffGenotype = List("sample1:sample2", "sample2:sample3"))
@Test def testMinQualScore() = testCommand(minQualScore = Some(50.0))
@Test def testFilterHetVarToHomVar() = testCommand(filterHetVarToHomVar = List("dummy"))
@Test def testId() = testCommand(id = List("rs01", "rs02"))
@Test def testIdFile() = testCommand(idFile = Some(File.createTempFile("vcfFilter", ".txt")))
@Test def testMinQualScore(): Unit = testCommand(minQualScore = Some(50.0))
@Test def testFilterHetVarToHomVar(): Unit = testCommand(filterHetVarToHomVar = List("dummy"))
@Test def testId(): Unit = testCommand(id = List("rs01", "rs02"))
@Test def testIdFile(): Unit = testCommand(idFile = Some(File.createTempFile("vcfFilter", ".txt")))
protected def testCommand(minSampleDepth: Option[Int] = None,
minTotalDepth: Option[Int] = None,
......
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