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
9e6d1d88
Commit
9e6d1d88
authored
May 11, 2016
by
Peter van 't Hof
Browse files
Added basic unit tests
parent
2f77340b
Changes
8
Hide whitespace changes
Inline
Side-by-side
kopisu/pom.xml
View file @
9e6d1d88
...
...
@@ -43,5 +43,17 @@
<artifactId>
BiopetExtensions
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
6.8
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.scalatest
</groupId>
<artifactId>
scalatest_2.10
</artifactId>
<version>
2.2.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
kopisu/src/main/scala/nl/lumc/sasc/biopet/pipelines/kopisu/Kopisu.scala
View file @
9e6d1d88
...
...
@@ -16,9 +16,9 @@
package
nl.lumc.sasc.biopet.pipelines.kopisu
import
nl.lumc.sasc.biopet.core.summary.SummaryQScript
import
nl.lumc.sasc.biopet.core.
{
PipelineCommand
,
Reference
}
import
nl.lumc.sasc.biopet.core.
{
PipelineCommand
,
Reference
}
import
nl.lumc.sasc.biopet.pipelines.kopisu.methods.FreecMethod
import
nl.lumc.sasc.biopet.utils.BamUtils
import
nl.lumc.sasc.biopet.utils.
{
BamUtils
,
Logging
}
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
org.broadinstitute.gatk.queue.QScript
...
...
@@ -35,6 +35,7 @@ class Kopisu(val root: Configurable) extends QScript with SummaryQScript with Re
def
init
()
:
Unit
=
{
if
(
inputBamsArg
.
nonEmpty
)
inputBams
=
BamUtils
.
sampleBamMap
(
inputBamsArg
)
if
(
inputBams
.
isEmpty
)
Logging
.
addError
(
"No input bams found"
)
}
lazy
val
freecMethod
=
if
(
config
(
"use_freec_method"
,
default
=
true
))
{
...
...
@@ -43,6 +44,8 @@ class Kopisu(val root: Configurable) extends QScript with SummaryQScript with Re
// This script is in fact FreeC only.
def
biopetScript
()
{
if
(
freecMethod
.
isEmpty
)
Logging
.
addError
(
"No method selected"
)
freecMethod
.
foreach
{
method
=>
method
.
inputBams
=
inputBams
method
.
outputDir
=
new
File
(
outputDir
,
"freec_method"
)
...
...
kopisu/src/test/resources/paired01.bam
0 → 100644
View file @
9e6d1d88
File added
kopisu/src/test/resources/paired01.bam.bai
0 → 100644
View file @
9e6d1d88
File added
kopisu/src/test/resources/ref.dict
0 → 100644
View file @
9e6d1d88
@HD VN:1.4 SO:unsorted
@SQ SN:chr1 LN:9 UR:file:/home/pjvan_thof/pipelines/biopet/public/mapping/src/test/resources/ref.fa M5:fe15dbbd0900310caf32827f6da57550
kopisu/src/test/resources/ref.fa
0 → 100644
View file @
9e6d1d88
>chr1
AGTAGTAGT
kopisu/src/test/resources/ref.fa.fai
0 → 100644
View file @
9e6d1d88
chr1 9 6 9 10
kopisu/src/test/scala/nl/lumc/sasc/biopet/pipelines/kopisu/KopisuTest.scala
0 → 100644
View file @
9e6d1d88
/**
* Biopet is built on top of GATK Queue for building bioinformatic
* pipelines. It is mainly intended to support LUMC SHARK cluster which is running
* SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
* should also be able to execute Biopet tools and pipelines.
*
* Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
*
* Contact us at: sasc@lumc.nl
*
* A dual licensing mode is applied. The source code within this project that are
* not part of GATK Queue is freely available for non-commercial use under an AGPL
* license; For commercial users or users who do not want to follow the AGPL
* license, please contact us to obtain a separate license.
*/
package
nl.lumc.sasc.biopet.pipelines.kopisu
import
java.io.
{
File
,
FileOutputStream
}
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.extensions.freec.
{
FreeC
,
FreeCAssessSignificancePlot
,
FreeCCNVPlot
}
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
scala.collection.mutable.ListBuffer
/**
* Test class for [[Kopisu]]
*
* Created by pjvan_thof on 3/2/15.
*/
class
KopisuTest
extends
TestNGSuite
with
Matchers
{
def
initPipeline
(
map
:
Map
[
String
,
Any
])
:
Kopisu
=
{
new
Kopisu
()
{
override
def
configNamespace
=
"kopisu"
override
def
globalConfig
=
new
Config
(
ConfigUtils
.
mergeMaps
(
map
,
KopisuTest
.
config
))
qSettings
=
new
QSettings
qSettings
.
runName
=
"test"
}
}
@DataProvider
(
name
=
"shivaSvCallingOptions"
)
def
shivaSvCallingOptions
=
{
val
bool
=
Array
(
true
,
false
)
(
for
(
bams
<-
0
to
3
;
freec
<-
bool
)
yield
Array
(
bams
,
freec
)).
toArray
}
@Test
(
dataProvider
=
"shivaSvCallingOptions"
)
def
testShivaSvCalling
(
bams
:
Int
,
freec
:
Boolean
)
=
{
val
callers
:
ListBuffer
[
String
]
=
ListBuffer
()
val
map
=
Map
(
"sv_callers"
->
callers
.
toList
)
val
pipeline
=
initPipeline
(
map
++
Map
(
"use_freec_method"
->
freec
))
pipeline
.
inputBams
=
(
for
(
n
<-
1
to
bams
)
yield
n
.
toString
->
KopisuTest
.
inputTouch
(
"bam_"
+
n
+
".bam"
)).
toMap
val
illegalArgumentException
=
pipeline
.
inputBams
.
isEmpty
||
(!
freec
)
if
(
illegalArgumentException
)
intercept
[
IllegalStateException
]
{
pipeline
.
init
()
pipeline
.
script
()
}
if
(!
illegalArgumentException
)
{
pipeline
.
init
()
pipeline
.
script
()
pipeline
.
freecMethod
.
isDefined
shouldBe
freec
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
FreeC
])
shouldBe
(
if
(
freec
)
bams
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
FreeCAssessSignificancePlot
])
shouldBe
(
if
(
freec
)
bams
else
0
)
pipeline
.
functions
.
count
(
_
.
isInstanceOf
[
FreeCCNVPlot
])
shouldBe
(
if
(
freec
)
bams
else
0
)
}
}
}
object
KopisuTest
{
val
outputDir
=
Files
.
createTempDir
()
outputDir
.
deleteOnExit
()
new
File
(
outputDir
,
"input"
).
mkdirs
()
private
def
inputTouch
(
name
:
String
)
:
File
=
{
val
file
=
new
File
(
outputDir
,
"input"
+
File
.
separator
+
name
).
getAbsoluteFile
Files
.
touch
(
file
)
file
}
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"
,
"output_dir"
->
outputDir
,
"reference_fasta"
->
(
outputDir
+
File
.
separator
+
"ref.fa"
),
"gatk_jar"
->
"test"
,
"samtools"
->
Map
(
"exe"
->
"test"
),
"md5sum"
->
Map
(
"exe"
->
"test"
),
"bgzip"
->
Map
(
"exe"
->
"test"
),
"tabix"
->
Map
(
"exe"
->
"test"
),
"freec"
->
Map
(
"exe"
->
"test"
,
"chrFiles"
->
"test"
,
"chrLenFile"
->
"test"
)
)
}
\ No newline at end of file
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