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
6455b8d4
Commit
6455b8d4
authored
Sep 28, 2016
by
Peter van 't Hof
Browse files
Added basic testing to sage
parent
d43c8265
Changes
6
Hide whitespace changes
Inline
Side-by-side
sage/pom.xml
View file @
6455b8d4
...
...
@@ -42,5 +42,17 @@
<artifactId>
Mapping
</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>
sage/src/main/scala/nl/lumc/sasc/biopet/pipelines/sage/Sage.scala
View file @
6455b8d4
...
...
@@ -15,15 +15,15 @@
package
nl.lumc.sasc.biopet.pipelines.sage
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core.
{
MultiSampleQScript
,
PipelineCommand
}
import
nl.lumc.sasc.biopet.core.
{
MultiSampleQScript
,
PipelineCommand
}
import
nl.lumc.sasc.biopet.extensions.Cat
import
nl.lumc.sasc.biopet.extensions.bedtools.BedtoolsCoverage
import
nl.lumc.sasc.biopet.extensions.picard.MergeSamFiles
import
nl.lumc.sasc.biopet.pipelines.flexiprep.Flexiprep
import
nl.lumc.sasc.biopet.pipelines.mapping.Mapping
import
nl.lumc.sasc.biopet.extensions.tools.SquishBed
import
nl.lumc.sasc.biopet.extensions.tools.
{
BedtoolsCoverageToCounts
,
PrefixFastq
,
SageCountFastq
,
SageCreateLibrary
,
SageCreateTagCounts
}
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
nl.lumc.sasc.biopet.extensions.tools.
{
BedtoolsCoverageToCounts
,
PrefixFastq
,
SageCountFastq
,
SageCreateLibrary
,
SageCreateTagCounts
}
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
import
org.broadinstitute.gatk.queue.QScript
class
Sage
(
val
root
:
Configurable
)
extends
QScript
with
MultiSampleQScript
{
...
...
@@ -54,26 +54,20 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript {
def
summaryFile
:
File
=
new
File
(
outputDir
,
"Sage.summary.json"
)
//TODO: Add summary
def
summaryFiles
:
Map
[
String
,
File
]
=
Map
()
//TODO: Add summary
def
summarySettings
:
Map
[
String
,
Any
]
=
Map
()
def
makeSample
(
id
:
String
)
=
new
Sample
(
id
)
class
Sample
(
sampleId
:
String
)
extends
AbstractSample
(
sampleId
)
{
//TODO: Add summary
def
summaryFiles
:
Map
[
String
,
File
]
=
Map
()
//TODO: Add summary
def
summaryStats
:
Map
[
String
,
Any
]
=
Map
()
def
makeLibrary
(
id
:
String
)
=
new
Library
(
id
)
class
Library
(
libId
:
String
)
extends
AbstractLibrary
(
libId
)
{
//TODO: Add summary
def
summaryFiles
:
Map
[
String
,
File
]
=
Map
()
//TODO: Add summary
def
summaryStats
:
Map
[
String
,
Any
]
=
Map
()
val
inputFastq
:
File
=
config
(
"R1"
)
...
...
@@ -92,9 +86,7 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript {
flexiprep
.
outputDir
=
new
File
(
libDir
,
"flexiprep/"
)
flexiprep
.
inputR1
=
inputFastq
flexiprep
.
init
()
flexiprep
.
biopetScript
()
qscript
.
addAll
(
flexiprep
.
functions
)
add
(
flexiprep
)
val
flexiprepOutput
=
for
((
key
,
file
)
<-
flexiprep
.
outputFiles
if
key
.
endsWith
(
"output_R1"
))
yield
file
val
pf
=
new
PrefixFastq
(
qscript
)
...
...
@@ -106,9 +98,7 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript {
mapping
.
inputR1
=
pf
.
outputFastq
mapping
.
outputDir
=
libDir
mapping
.
init
()
mapping
.
biopetScript
()
qscript
.
addAll
(
mapping
.
functions
)
add
(
mapping
)
if
(
config
(
"library_counts"
,
default
=
false
).
asBoolean
)
{
addBedtoolsCounts
(
mapping
.
finalBamFile
,
sampleId
+
"-"
+
libId
,
libDir
)
...
...
@@ -142,9 +132,9 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript {
def
init
()
{
if
(
transcriptome
.
isEmpty
&&
tagsLibrary
.
isEmpty
)
throw
new
IllegalStateException
(
"No transcriptome or taglib found"
)
Logging
.
addError
(
"No transcriptome or taglib found"
)
if
(
countBed
.
isEmpty
)
throw
new
IllegalStateException
(
"No bedfile supplied, please add a countBed"
)
Logging
.
addError
(
"No bedfile supplied, please add a countBed"
)
}
def
biopetScript
()
{
...
...
sage/src/test/resources/ref.dict
0 → 100644
View file @
6455b8d4
@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
sage/src/test/resources/ref.fa
0 → 100644
View file @
6455b8d4
>chr1
AGTAGTAGT
sage/src/test/resources/ref.fa.fai
0 → 100644
View file @
6455b8d4
chr1 9 6 9 10
sage/src/test/scala/nl/lumc/sasc/biopet/pipelines/sage/SageTest.scala
0 → 100644
View file @
6455b8d4
package
nl.lumc.sasc.biopet.pipelines.sage
import
java.io.
{
File
,
FileOutputStream
}
import
com.google.common.io.Files
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
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
}
/**
* Created by pjvanthof on 28/09/16.
*/
class
SageTest
extends
TestNGSuite
with
Matchers
{
def
initPipeline
(
map
:
Map
[
String
,
Any
])
:
Sage
=
{
new
Sage
()
{
override
def
configNamespace
=
"sage"
override
def
globalConfig
=
new
Config
(
ConfigUtils
.
mergeMaps
(
map
,
SageTest
.
config
))
qSettings
=
new
QSettings
qSettings
.
runName
=
"test"
}
}
@DataProvider
(
name
=
"sageOptions"
)
def
sageOptions
=
{
for
(
s1
<-
sample1
;
s2
<-
sample2
)
yield
Array
(
""
,
s1
,
s2
)
}
def
sample1
=
Array
(
false
,
true
)
def
sample2
=
Array
(
false
,
true
)
@Test
(
dataProvider
=
"sageOptions"
)
def
testSage
(
f
:
String
,
sample1
:
Boolean
,
sample2
:
Boolean
)
:
Unit
=
{
val
map
=
{
var
m
:
Map
[
String
,
Any
]
=
SageTest
.
config
if
(
sample1
)
m
=
ConfigUtils
.
mergeMaps
(
SageTest
.
sample1
,
m
)
if
(
sample2
)
m
=
ConfigUtils
.
mergeMaps
(
SageTest
.
sample2
,
m
)
ConfigUtils
.
mergeMaps
(
Map
(
// Config values
),
m
)
}
if
(!
sample1
&&
!
sample2
)
{
// When no samples
intercept
[
IllegalStateException
]
{
initPipeline
(
map
).
script
()
}
Logging
.
errors
.
clear
()
}
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
.
summaryFile
shouldBe
new
File
(
SageTest
.
outputDir
,
"Sage.summary.json"
)
pipeline
.
summaryFiles
shouldBe
Map
()
pipeline
.
summarySettings
shouldBe
Map
()
pipeline
.
samples
.
foreach
{
case
(
sampleId
,
sample
)
=>
sample
.
summaryFiles
shouldBe
Map
()
sample
.
summaryStats
shouldBe
Map
()
sample
.
summarySettings
shouldBe
Map
()
sample
.
libraries
.
foreach
{
case
(
libId
,
lib
)
=>
lib
.
summaryFiles
shouldBe
Map
()
lib
.
summaryStats
shouldBe
Map
()
lib
.
summarySettings
shouldBe
Map
()
}
}
}
}
}
object
SageTest
{
val
outputDir
=
Files
.
createTempDir
()
outputDir
.
deleteOnExit
()
new
File
(
outputDir
,
"input"
).
mkdirs
()
def
inputTouch
(
name
:
String
)
:
String
=
{
val
file
=
new
File
(
outputDir
,
"input"
+
File
.
separator
+
name
)
Files
.
touch
(
file
)
file
.
getAbsolutePath
}
inputTouch
(
"ref.ebwt"
)
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
[
String
,
Any
]
=
Map
(
"reference_fasta"
->
(
outputDir
+
File
.
separator
+
"ref.fa"
),
"output_dir"
->
outputDir
.
getAbsolutePath
,
"transcriptome"
->
inputTouch
(
"trans.fa"
),
"count_bed"
->
inputTouch
(
"count.bed"
),
"fastqc"
->
Map
(
"exe"
->
"test"
),
"seqtk"
->
Map
(
"exe"
->
"test"
),
"md5sum"
->
Map
(
"exe"
->
"test"
),
"bedtools"
->
Map
(
"exe"
->
"test"
),
"bowtie"
->
Map
(
"exe"
->
"test"
),
"bowtie_index"
->
inputTouch
(
"ref"
)
)
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
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