Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
f330f2f8
Commit
f330f2f8
authored
Mar 02, 2015
by
Peter van 't Hof
Browse files
Added unit test to do some magic
parent
68182a4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcallingTest.scala
→
protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcalling
Gatk
Test.scala
View file @
f330f2f8
...
...
@@ -5,25 +5,25 @@ import java.io.File
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.core.config.Config
import
nl.lumc.sasc.biopet.extensions.gatk.CombineVariants
import
nl.lumc.sasc.biopet.extensions.gatk.broad.
{
UnifiedGenotyper
,
HaplotypeCaller
}
import
nl.lumc.sasc.biopet.tools.
{
VcfStats
,
MpileupToVcf
,
VcfFilter
}
import
nl.lumc.sasc.biopet.extensions.gatk.broad.
{
UnifiedGenotyper
,
HaplotypeCaller
}
import
nl.lumc.sasc.biopet.tools.
{
VcfStats
,
MpileupToVcf
,
VcfFilter
}
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
org.apache.commons.io.FileUtils
import
org.broadinstitute.gatk.queue.QSettings
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.
{
DataProvider
,
Test
,
AfterClass
}
import
org.testng.annotations.
{
DataProvider
,
Test
,
AfterClass
}
import
scala.collection.mutable.ListBuffer
/**
* Created by pjvan_thof on 3/2/15.
*/
class
ShivaVariantcallingTest
extends
TestNGSuite
with
Matchers
{
class
ShivaVariantcalling
Gatk
Test
extends
TestNGSuite
with
Matchers
{
def
initPipeline
(
map
:
Map
[
String
,
Any
])
:
ShivaVariantcallingGatk
=
{
new
ShivaVariantcallingGatk
()
{
override
def
configName
=
"shivavariantcalling"
override
def
globalConfig
=
new
Config
(
ConfigUtils
.
mergeMaps
(
map
,
ShivaVariantcallingTest
.
config
))
override
def
globalConfig
=
new
Config
(
ConfigUtils
.
mergeMaps
(
map
,
ShivaVariantcalling
Gatk
Test
.
config
))
qSettings
=
new
QSettings
qSettings
.
runName
=
"test"
}
...
...
@@ -31,23 +31,17 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
@DataProvider
(
name
=
"shivaVariantcallingOptions"
)
def
shivaVariantcallingOptions
=
{
val
raw
=
Array
(
true
,
false
)
val
bcftools
=
Array
(
true
,
false
)
val
haplotypeCallerGvcf
=
Array
(
true
,
false
)
val
haplotypeCallerAllele
=
Array
(
true
,
false
)
val
unifiedGenotyperAllele
=
Array
(
true
,
false
)
val
unifiedGenotyper
=
Array
(
true
,
false
)
val
haplotypeCaller
=
Array
(
true
,
false
)
val
bool
=
Array
(
true
,
false
)
(
for
(
bams
<-
0
to
2
;
raw
<-
raw
;
bcftools
<-
b
cft
ool
s
;
haplotypeCallerGvcf
<-
haplotypeCallerGvcf
;
haplotypeCallerAllele
<-
haplotypeCallerAllele
;
unifiedGenotyperAllele
<-
unifiedGenotyperAllele
;
unifiedGenotyper
<-
unifiedGenotyper
;
haplotypeCaller
<-
haplotypeCaller
raw
<-
bool
;
bcftools
<-
bool
;
haplotypeCallerGvcf
<-
bool
;
haplotypeCallerAllele
<-
bool
;
unifiedGenotyperAllele
<-
bool
;
unifiedGenotyper
<-
bool
;
haplotypeCaller
<-
bool
)
yield
Array
[
Any
](
bams
,
raw
,
bcftools
,
unifiedGenotyper
,
haplotypeCaller
,
haplotypeCallerGvcf
,
haplotypeCallerAllele
,
unifiedGenotyperAllele
)
).
toArray
}
...
...
@@ -69,7 +63,7 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
if
(
haplotypeCallerAllele
)
callers
.
append
(
"haplotypecaller_allele"
)
if
(
unifiedGenotyperAllele
)
callers
.
append
(
"unifiedgenotyper_allele"
)
if
(
haplotypeCaller
)
callers
.
append
(
"haplotypecaller"
)
val
map
=
Map
(
"variantcallers"
->
callers
.
toList
)
val
map
=
Map
(
"variantcallers"
->
callers
.
toList
)
val
pipeline
=
initPipeline
(
map
)
pipeline
.
inputBams
=
(
for
(
n
<-
1
to
bams
)
yield
new
File
(
"bam_"
+
n
+
".bam"
)).
toList
...
...
@@ -100,11 +94,11 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
}
@AfterClass
def
removeTempOutputDir
()
=
{
FileUtils
.
deleteDirectory
(
ShivaVariantcallingTest
.
outputDir
)
FileUtils
.
deleteDirectory
(
ShivaVariantcalling
Gatk
Test
.
outputDir
)
}
}
object
ShivaVariantcallingTest
{
object
ShivaVariantcalling
Gatk
Test
{
val
outputDir
=
Files
.
createTempDir
()
val
config
=
Map
(
...
...
public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTrait.scala
View file @
f330f2f8
...
...
@@ -185,7 +185,7 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
addPerLibJobs
()
if
(
preProcessBam
.
isDefined
)
{
val
bamMetrics
=
new
BamMetrics
(
roo
t
)
val
bamMetrics
=
new
BamMetrics
(
qscrip
t
)
bamMetrics
.
sampleId
=
Some
(
sampleId
)
bamMetrics
.
inputBam
=
preProcessBam
.
get
bamMetrics
.
outputDir
=
sampleDir
...
...
public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTest.scala
0 → 100644
View file @
f330f2f8
package
nl.lumc.sasc.biopet.pipelines.shiva
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.core.config.Config
import
nl.lumc.sasc.biopet.extensions.bwa.BwaMem
import
nl.lumc.sasc.biopet.extensions.picard.
{
MarkDuplicates
,
MergeSamFiles
,
SortSam
}
import
nl.lumc.sasc.biopet.tools.VcfStats
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
org.broadinstitute.gatk.queue.QSettings
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.
{
Test
,
DataProvider
}
/**
* Created by pjvan_thof on 3/2/15.
*/
class
ShivaTest
extends
TestNGSuite
with
Matchers
{
def
initPipeline
(
map
:
Map
[
String
,
Any
])
:
Shiva
=
{
new
Shiva
()
{
override
def
configName
=
"shiva"
override
def
globalConfig
=
new
Config
(
ConfigUtils
.
mergeMaps
(
map
,
ShivaVariantcallingTest
.
config
))
qSettings
=
new
QSettings
qSettings
.
runName
=
"test"
}
}
@DataProvider
(
name
=
"shivaOptions"
)
def
shivaOptions
=
{
val
bool
=
Array
(
true
,
false
)
for
(
s1
<-
bool
;
s2
<-
bool
;
s3
<-
bool
;
multi
<-
bool
;
single
<-
bool
;
library
<-
bool
)
yield
Array
(
""
,
s1
,
s2
,
s3
,
multi
,
single
,
library
)
}
@Test
(
dataProvider
=
"shivaOptions"
)
def
testShiva
(
f
:
String
,
sample1
:
Boolean
,
sample2
:
Boolean
,
sample3
:
Boolean
,
multi
:
Boolean
,
single
:
Boolean
,
library
:
Boolean
)
:
Unit
=
{
val
map
=
{
var
m
:
Map
[
String
,
Any
]
=
ShivaTest
.
config
if
(
sample1
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample1
,
m
.
toMap
)
if
(
sample2
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample2
,
m
.
toMap
)
if
(
sample3
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample3
,
m
.
toMap
)
ConfigUtils
.
mergeMaps
(
Map
(
"multisample_sample_variantcalling"
->
multi
,
"single_sample_variantcalling"
->
single
,
"library_variantcalling"
->
library
),
m
.
toMap
)
}
if
(!
sample1
&&
!
sample2
&&
!
sample3
)
{
// When no samples
intercept
[
IllegalArgumentException
]
{
initPipeline
(
map
).
script
()
}
}
else
{
val
pipeline
=
initPipeline
(
map
)
pipeline
.
script
()
val
numberLibs
=
(
if
(
sample1
)
1
else
0
)
+
(
if
(
sample2
)
1
else
0
)
+
(
if
(
sample3
)
2
else
0
)
val
numberSamples
=
(
if
(
sample1
)
1
else
0
)
+
(
if
(
sample2
)
1
else
0
)
+
(
if
(
sample3
)
1
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
BwaMem
])
shouldBe
numberLibs
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
SortSam
])
shouldBe
numberLibs
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
MarkDuplicates
])
shouldBe
(
numberLibs
+
(
if
(
sample3
)
1
else
0
))
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
VcfStats
])
shouldBe
(
if
(
multi
)
2
else
0
)
+
(
if
(
single
)
numberSamples
*
2
else
0
)
+
(
if
(
library
)
numberLibs
*
2
else
0
)
}
}
}
object
ShivaTest
{
val
outputDir
=
Files
.
createTempDir
()
val
config
=
Map
(
"name_prefix"
->
"test"
,
"output_dir"
->
outputDir
,
"reference"
->
"test"
,
"gatk_jar"
->
"test"
,
"samtools"
->
Map
(
"exe"
->
"test"
),
"bcftools"
->
Map
(
"exe"
->
"test"
),
"fastqc"
->
Map
(
"exe"
->
"test"
),
"input_alleles"
->
"test"
,
"variantcallers"
->
"raw"
,
"fastqc"
->
Map
(
"exe"
->
"test"
),
"seqtk"
->
Map
(
"exe"
->
"test"
),
"sickle"
->
Map
(
"exe"
->
"test"
),
"cutadapt"
->
Map
(
"exe"
->
"test"
),
"bwa"
->
Map
(
"exe"
->
"test"
),
"samtools"
->
Map
(
"exe"
->
"test"
),
"macs2"
->
Map
(
"exe"
->
"test"
),
"igvtools"
->
Map
(
"exe"
->
"test"
),
"wigtobigwig"
->
Map
(
"exe"
->
"test"
)
)
val
sample1
=
Map
(
"samples"
->
Map
(
"sample1"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
"1_1_R1.fq"
,
"R2"
->
"1_1_R2.fq"
)
)
)))
val
sample2
=
Map
(
"samples"
->
Map
(
"sample2"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
"2_1_R1.fq"
,
"R2"
->
"2_1_R2.fq"
)
)
)))
val
sample3
=
Map
(
"samples"
->
Map
(
"sample3"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
"3_1_R1.fq"
,
"R2"
->
"3_1_R2.fq"
),
"lib2"
->
Map
(
"R1"
->
"3_2_R1.fq"
,
"R2"
->
"3_2_R2.fq"
)
)
)))
}
\ No newline at end of file
public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTest.scala
View file @
f330f2f8
...
...
@@ -5,7 +5,7 @@ import java.io.File
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.core.config.Config
import
nl.lumc.sasc.biopet.extensions.gatk.CombineVariants
import
nl.lumc.sasc.biopet.tools.
{
VcfFilter
,
MpileupToVcf
}
import
nl.lumc.sasc.biopet.tools.
{
VcfFilter
,
MpileupToVcf
}
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
org.apache.commons.io.FileUtils
import
org.broadinstitute.gatk.queue.QSettings
...
...
@@ -30,15 +30,8 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
@DataProvider
(
name
=
"shivaVariantcallingOptions"
)
def
shivaVariantcallingOptions
=
{
val
raw
=
Array
(
true
,
false
)
val
bcftools
=
Array
(
true
,
false
)
(
for
(
bams
<-
0
to
3
;
raw
<-
raw
;
bcftools
<-
bcftools
)
yield
Array
[
Any
](
bams
,
raw
,
bcftools
)
).
toArray
val
bool
=
Array
(
true
,
false
)
(
for
(
bams
<-
0
to
3
;
raw
<-
bool
;
bcftools
<-
bool
)
yield
Array
(
bams
,
raw
,
bcftools
)).
toArray
}
@Test
(
dataProvider
=
"shivaVariantcallingOptions"
)
...
...
@@ -46,7 +39,7 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
val
callers
:
ListBuffer
[
String
]
=
ListBuffer
()
if
(
raw
)
callers
.
append
(
"raw"
)
if
(
bcftools
)
callers
.
append
(
"bcftools"
)
val
map
=
Map
(
"variantcallers"
->
callers
.
toList
)
val
map
=
Map
(
"variantcallers"
->
callers
.
toList
)
val
pipeline
=
initPipeline
(
map
)
pipeline
.
inputBams
=
(
for
(
n
<-
1
to
bams
)
yield
new
File
(
"bam_"
+
n
+
".bam"
)).
toList
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment