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
b10509f2
Commit
b10509f2
authored
Apr 27, 2016
by
Peter van 't Hof
Browse files
Move shiva testing to public
parent
d7b0ecdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaTest.scala
deleted
100644 → 0
View file @
d7b0ecdc
/**
* Due to the license issue with GATK, this part of Biopet can only be used inside the
* LUMC. Please refer to https://git.lumc.nl/biopet/biopet/wikis/home for instructions
* on how to use this protected part of biopet or contact us at sasc@lumc.nl
*/
package
nl.lumc.sasc.biopet.pipelines.gatk
import
java.io.
{
File
,
FileOutputStream
}
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.utils.config.Config
import
nl.lumc.sasc.biopet.extensions.bwa.BwaMem
import
nl.lumc.sasc.biopet.extensions.gatk.broad._
import
nl.lumc.sasc.biopet.extensions.picard.
{
MarkDuplicates
,
SortSam
}
import
nl.lumc.sasc.biopet.extensions.tools.VcfStats
import
nl.lumc.sasc.biopet.pipelines.shiva.Shiva
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.
{
DataProvider
,
Test
}
/**
* Class for testing shiva
*
* 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
configNamespace
=
"shiva"
override
def
globalConfig
=
new
Config
(
ConfigUtils
.
mergeMaps
(
map
,
ShivaTest
.
config
))
qSettings
=
new
QSettings
qSettings
.
runName
=
"test"
}
}
@DataProvider
(
name
=
"shivaOptions"
)
def
shivaOptions
=
{
val
bool
=
Array
(
true
,
false
)
for
(
s1
<-
bool
;
s2
<-
bool
;
multi
<-
bool
;
dbsnp
<-
bool
;
realign
<-
bool
;
baseRecalibration
<-
bool
)
yield
Array
(
""
,
s1
,
s2
,
multi
,
dbsnp
,
realign
,
baseRecalibration
)
}
@Test
(
dataProvider
=
"shivaOptions"
)
def
testShiva
(
f
:
String
,
sample1
:
Boolean
,
sample2
:
Boolean
,
multi
:
Boolean
,
dbsnp
:
Boolean
,
realign
:
Boolean
,
baseRecalibration
:
Boolean
)
:
Unit
=
{
val
map
=
{
var
m
:
Map
[
String
,
Any
]
=
ShivaTest
.
config
if
(
sample1
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample1
,
m
)
if
(
sample2
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample2
,
m
)
if
(
dbsnp
)
m
=
ConfigUtils
.
mergeMaps
(
Map
(
"dbsnp"
->
"test.vcf.gz"
),
m
)
ConfigUtils
.
mergeMaps
(
Map
(
"multisample_variantcalling"
->
multi
,
"use_indel_realigner"
->
realign
,
"use_base_recalibration"
->
baseRecalibration
),
m
)
}
if
(!
sample1
&&
!
sample2
)
{
// When no samples
intercept
[
IllegalArgumentException
]
{
initPipeline
(
map
).
script
()
}
}
else
{
val
pipeline
=
initPipeline
(
map
)
pipeline
.
script
()
val
numberLibs
=
(
if
(
sample1
)
1
else
0
)
+
(
if
(
sample2
)
2
else
0
)
val
numberSamples
=
(
if
(
sample1
)
1
else
0
)
+
(
if
(
sample2
)
1
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
MarkDuplicates
])
shouldBe
(
numberLibs
+
(
if
(
sample2
)
1
else
0
))
// Gatk preprocess
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
IndelRealigner
])
shouldBe
(
numberLibs
*
(
if
(
realign
)
1
else
0
)
+
(
if
(
sample2
&&
realign
)
1
else
0
))
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
RealignerTargetCreator
])
shouldBe
(
numberLibs
*
(
if
(
realign
)
1
else
0
)
+
(
if
(
sample2
&&
realign
)
1
else
0
))
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
BaseRecalibrator
])
shouldBe
(
if
(
dbsnp
&&
baseRecalibration
)
numberLibs
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
PrintReads
])
shouldBe
(
if
(
dbsnp
&&
baseRecalibration
)
numberLibs
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
VcfStats
])
shouldBe
(
if
(
multi
)
2
else
0
)
}
}
}
object
ShivaTest
{
val
outputDir
=
Files
.
createTempDir
()
new
File
(
outputDir
,
"input"
).
mkdirs
()
def
inputTouch
(
name
:
String
)
:
String
=
{
val
file
=
new
File
(
outputDir
,
"input"
+
File
.
separator
+
name
)
Files
.
touch
(
file
)
file
.
getAbsolutePath
}
private
def
copyFile
(
name
:
String
)
:
Unit
=
{
val
is
=
getClass
.
getResourceAsStream
(
"/"
+
name
)
val
os
=
new
FileOutputStream
(
new
File
(
outputDir
,
name
))
org
.
apache
.
commons
.
io
.
IOUtils
.
copy
(
is
,
os
)
os
.
close
()
}
copyFile
(
"ref.fa"
)
copyFile
(
"ref.dict"
)
copyFile
(
"ref.fa.fai"
)
val
config
=
Map
(
"name_prefix"
->
"test"
,
"cache"
->
true
,
"dir"
->
"test"
,
"vep_script"
->
"test"
,
"output_dir"
->
outputDir
,
"reference_fasta"
->
(
outputDir
+
File
.
separator
+
"ref.fa"
),
"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"
),
"md5sum"
->
Map
(
"exe"
->
"test"
),
"bgzip"
->
Map
(
"exe"
->
"test"
),
"tabix"
->
Map
(
"exe"
->
"test"
)
)
val
sample1
=
Map
(
"samples"
->
Map
(
"sample1"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
inputTouch
(
"1_1_R1.fq"
),
"R2"
->
inputTouch
(
"1_1_R2.fq"
)
)
)
)))
val
sample2
=
Map
(
"samples"
->
Map
(
"sample3"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
inputTouch
(
"2_1_R1.fq"
),
"R2"
->
inputTouch
(
"2_1_R2.fq"
)
),
"lib2"
->
Map
(
"R1"
->
inputTouch
(
"2_2_R1.fq"
),
"R2"
->
inputTouch
(
"2_2_R2.fq"
)
)
)
)))
}
\ No newline at end of file
public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTest.scala
View file @
b10509f2
...
...
@@ -15,24 +15,24 @@
*/
package
nl.lumc.sasc.biopet.pipelines.shiva
import
java.io.
{
File
,
FileOutputStream
}
import
java.io.
{
File
,
FileOutputStream
}
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.utils.config.Config
import
nl.lumc.sasc.biopet.extensions.bwa.BwaMem
import
nl.lumc.sasc.biopet.extensions.picard.
{
MarkDuplicates
,
SortSam
}
import
nl.lumc.sasc.biopet.extensions.gatk.broad._
import
nl.lumc.sasc.biopet.extensions.picard.MarkDuplicates
import
nl.lumc.sasc.biopet.extensions.tools.VcfStats
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
nl.lumc.sasc.biopet.utils.config.Config
import
org.broadinstitute.gatk.queue.QSettings
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.
{
DataProvider
,
Test
}
import
org.testng.annotations.
{
DataProvider
,
Test
}
/**
*
Test c
lass for
[[S
hiva
]]
*
* Created by pjvan_thof on 3/2/15.
*/
*
C
lass for
testing s
hiva
*
* Created by pjvan_thof on 3/2/15.
*/
class
ShivaTest
extends
TestNGSuite
with
Matchers
{
def
initPipeline
(
map
:
Map
[
String
,
Any
])
:
Shiva
=
{
new
Shiva
()
{
...
...
@@ -47,24 +47,28 @@ class ShivaTest extends TestNGSuite with Matchers {
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
)
for
(
s1
<-
bool
;
s2
<-
bool
;
multi
<-
bool
;
dbsnp
<-
bool
;
realign
<-
bool
;
baseRecalibration
<-
bool
)
yield
Array
(
""
,
s1
,
s2
,
multi
,
dbsnp
,
realign
,
baseRecalibration
)
}
@Test
(
dataProvider
=
"shivaOptions"
)
def
testShiva
(
f
:
String
,
sample1
:
Boolean
,
sample2
:
Boolean
,
sample3
:
Boolean
,
multi
:
Boolean
,
single
:
Boolean
,
library
:
Boolean
)
:
Unit
=
{
def
testShiva
(
f
:
String
,
sample1
:
Boolean
,
sample2
:
Boolean
,
multi
:
Boolean
,
dbsnp
:
Boolean
,
realign
:
Boolean
,
baseRecalibration
:
Boolean
)
:
Unit
=
{
val
map
=
{
var
m
:
Map
[
String
,
Any
]
=
ShivaTest
.
config
if
(
sample1
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample1
,
m
)
if
(
sample2
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample2
,
m
)
if
(
sample3
)
m
=
ConfigUtils
.
mergeMaps
(
ShivaTest
.
sample3
,
m
)
if
(
dbsnp
)
m
=
ConfigUtils
.
mergeMaps
(
Map
(
"dbsnp"
->
"test.vcf.gz"
)
,
m
)
ConfigUtils
.
mergeMaps
(
Map
(
"multisample_variantcalling"
->
multi
,
"single_sample_variantcalling"
->
single
,
"library_variantcalling"
->
library
),
m
)
"use_indel_realigner"
->
realign
,
"use_base_recalibration"
->
baseRecalibration
),
m
)
}
if
(!
sample1
&&
!
sample2
&&
!
sample3
)
{
// When no samples
if
(!
sample1
&&
!
sample2
)
{
// When no samples
intercept
[
IllegalArgumentException
]
{
initPipeline
(
map
).
script
()
}
...
...
@@ -72,13 +76,18 @@ class ShivaTest extends TestNGSuite with Matchers {
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
)
val
numberLibs
=
(
if
(
sample1
)
1
else
0
)
+
(
if
(
sample2
)
2
else
0
)
val
numberSamples
=
(
if
(
sample1
)
1
else
0
)
+
(
if
(
sample2
)
1
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
MarkDuplicates
])
shouldBe
(
numberLibs
+
(
if
(
sample2
)
1
else
0
))
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
MarkDuplicates
])
shouldBe
(
numberLibs
+
(
if
(
sample3
)
1
else
0
))
// Gatk preprocess
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
IndelRealigner
])
shouldBe
(
numberLibs
*
(
if
(
realign
)
1
else
0
)
+
(
if
(
sample2
&&
realign
)
1
else
0
))
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
RealignerTargetCreator
])
shouldBe
(
numberLibs
*
(
if
(
realign
)
1
else
0
)
+
(
if
(
sample2
&&
realign
)
1
else
0
))
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
BaseRecalibrator
])
shouldBe
(
if
(
dbsnp
&&
baseRecalibration
)
numberLibs
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
PrintReads
])
shouldBe
(
if
(
dbsnp
&&
baseRecalibration
)
numberLibs
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
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
VcfStats
])
shouldBe
(
if
(
multi
)
2
else
0
)
}
}
}
...
...
@@ -105,10 +114,10 @@ object ShivaTest {
val
config
=
Map
(
"name_prefix"
->
"test"
,
"output_dir"
->
outputDir
,
"cache"
->
true
,
"dir"
->
"test"
,
"vep_script"
->
"test"
,
"output_dir"
->
outputDir
,
"reference_fasta"
->
(
outputDir
+
File
.
separator
+
"ref.fa"
),
"gatk_jar"
->
"test"
,
"samtools"
->
Map
(
"exe"
->
"test"
),
...
...
@@ -140,23 +149,14 @@ object ShivaTest {
)))
val
sample2
=
Map
(
"samples"
->
Map
(
"sample
2
"
->
Map
(
"libraries"
->
Map
(
"samples"
->
Map
(
"sample
3
"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
inputTouch
(
"2_1_R1.fq"
),
"R2"
->
inputTouch
(
"2_1_R2.fq"
)
)
)
)))
val
sample3
=
Map
(
"samples"
->
Map
(
"sample3"
->
Map
(
"libraries"
->
Map
(
"lib1"
->
Map
(
"R1"
->
inputTouch
(
"3_1_R1.fq"
),
"R2"
->
inputTouch
(
"3_1_R2.fq"
)
),
"lib2"
->
Map
(
"R1"
->
inputTouch
(
"
3
_2_R1.fq"
),
"R2"
->
inputTouch
(
"
3
_2_R2.fq"
)
"R1"
->
inputTouch
(
"
2
_2_R1.fq"
),
"R2"
->
inputTouch
(
"
2
_2_R2.fq"
)
)
)
)))
...
...
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