From 6894dd4dbe8fb41653dfd1d5074f060380946828 Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Mon, 11 Apr 2016 09:45:48 +0200 Subject: [PATCH] Adding test to GensToVcf --- .../src/test/resources/gens.samples | 5 ++ .../biopet-tools/src/test/resources/test.gens | 3 ++ .../src/test/resources/test.gens_info | 4 ++ .../sasc/biopet/tools/GensToVcfTest.scala | 48 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 public/biopet-tools/src/test/resources/gens.samples create mode 100644 public/biopet-tools/src/test/resources/test.gens create mode 100644 public/biopet-tools/src/test/resources/test.gens_info create mode 100644 public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/GensToVcfTest.scala diff --git a/public/biopet-tools/src/test/resources/gens.samples b/public/biopet-tools/src/test/resources/gens.samples new file mode 100644 index 000000000..1789a409e --- /dev/null +++ b/public/biopet-tools/src/test/resources/gens.samples @@ -0,0 +1,5 @@ +ID_1 ID_2 missing hip knee hand knee_or_hip sex age bmi +0 0 0 D D D D D P P +sample-1 fam-1 0.0 2 NA 2 2 1 59.0767123287671 27.1314117909924 +sample-2 fam-1 0.0 2 NA NA 2 2 48.4958904109589 23.8754325259516 +sample-3 fam-1 0.0 NA NA NA NA 2 57.0876712328767 45.8842609074008 diff --git a/public/biopet-tools/src/test/resources/test.gens b/public/biopet-tools/src/test/resources/test.gens new file mode 100644 index 000000000..bec79dab8 --- /dev/null +++ b/public/biopet-tools/src/test/resources/test.gens @@ -0,0 +1,3 @@ +--- rs1 30 A C 1 0 0 0 1 0 0 0 1 +--- rs2 40 A - 1 0 0 0 1 0 0 0 1 +--- rs3 50 A AT 1 0 0 0 1 0 0 0 1 \ No newline at end of file diff --git a/public/biopet-tools/src/test/resources/test.gens_info b/public/biopet-tools/src/test/resources/test.gens_info new file mode 100644 index 000000000..250a9677f --- /dev/null +++ b/public/biopet-tools/src/test/resources/test.gens_info @@ -0,0 +1,4 @@ +snp_id rs_id position exp_freq_a1 info certainty type info_type0 concord_type0 r2_type0 +--- rs1 30 0.037 0.535 0.958 0 -1 -1 -1 +--- rs2 40 0.023 0.621 0.978 0 -1 -1 -1 +--- rs3 50 0.000 0.114 0.999 0 -1 -1 -1 diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/GensToVcfTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/GensToVcfTest.scala new file mode 100644 index 000000000..01a196a79 --- /dev/null +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/GensToVcfTest.scala @@ -0,0 +1,48 @@ +package nl.lumc.sasc.biopet.tools + +import java.io.File +import java.nio.file.Paths + +import org.scalatest.Matchers +import org.scalatest.testng.TestNGSuite +import org.testng.annotations.Test + +/** + * Created by pjvan_thof on 4/11/16. + */ +class GensToVcfTest extends TestNGSuite with Matchers { + @Test + def testGensOnly: Unit = { + val output = File.createTempFile("test.", ".vcf.gz") + GensToVcf.main(Array( + "--inputGenotypes", GensToVcfTest.resourcePath("/test.gens"), + "--outputVcf", output.getAbsolutePath, + "--referenceFasta", GensToVcfTest.resourcePath("/fake_chrQ.fa"), + "--contig", "chrQ", + "--samplesFile", GensToVcfTest.resourcePath("/gens.samples") + )) + } + + @Test + def testGensInfo: Unit = { + val output = File.createTempFile("test.", ".vcf.gz") + GensToVcf.main(Array( + "--inputGenotypes", GensToVcfTest.resourcePath("/test.gens"), + "--inputInfo", GensToVcfTest.resourcePath("/test.gens_info"), + "--outputVcf", output.getAbsolutePath, + "--referenceFasta", GensToVcfTest.resourcePath("/fake_chrQ.fa"), + "--contig", "chrQ", + "--samplesFile", GensToVcfTest.resourcePath("/gens.samples"), + "--sortInput" + )) + } + +} + +object GensToVcfTest { + private def resourcePath(p: String): String = { + Paths.get(getClass.getResource(p).toURI).toString + } + + +} -- GitLab