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
fbc8e4ab
Commit
fbc8e4ab
authored
Apr 03, 2017
by
akaljuvee
Browse files
using the new summary
parent
1d34f764
Changes
2
Hide whitespace changes
Inline
Side-by-side
shiva/src/main/resources/nl/lumc/sasc/biopet/pipelines/shiva/sampleVariantsSv.ssp
View file @
fbc8e4ab
#import(nl.lumc.sasc.biopet.utils.summary.Summary)
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
#import(nl.lumc.sasc.biopet.utils.summary.db.Schema.Sample)
#import(java.io.File)
<%@ var summary: SummaryDb %>
<%@ var allSamples: Seq[Sample]%>
<%@ var rootPath: String %>
<%@ var outputDir: File %>
<%@ var
sampleId: Option[String] = None
%>
<%@ var s
ummary: Summary
%>
<%@ var
runId: Int
%>
<%@ var s
ampleId: Option[Int] = None
%>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true %>
#{
val sampleNames:
List
[String] = sampleId match {
case Some(sample
Name) => List(sampleName.toString
)
case _ =>
summary.samples.toList
.sorted
val sampleNames:
Seq
[String] = sampleId match {
case Some(sample
Id) => Seq(allSamples.filter(s => s.id == sampleId).head.name
)
case _ =>
allSamples.collect({case s: Sample => s.name})
.sorted
}
val counts: Map[String, Map[String, Array[Long]]] = ShivaSvCallingReport.parseSummaryForSvCounts(summary)
val traCounts: Map[String, Long] = ShivaSvCallingReport.parseSummaryForTranslocations(summary)
val counts: Map[String, Map[String, Array[Long]]] = ShivaSvCallingReport.parseSummaryForSvCounts(summary
, runId, sampleNames
)
val traCounts: Map[String, Long] = ShivaSvCallingReport.parseSummaryForTranslocations(summary
, runId, sampleNames
)
var svTypes = List(
SvTypeForReport("DEL", "Deletions", "svSummaryDeletions.tsv", "svSummaryDeletions.png"),
...
...
shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaSvCallingReport.scala
View file @
fbc8e4ab
...
...
@@ -3,7 +3,11 @@ package nl.lumc.sasc.biopet.pipelines.shiva
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.utils.rscript.LinePlot
import
nl.lumc.sasc.biopet.utils.summary.Summary
import
nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import
nl.lumc.sasc.biopet.utils.summary.db.SummaryDb.
{
ModuleName
,
PipelineName
,
SampleName
}
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
object
ShivaSvCallingReport
{
...
...
@@ -11,11 +15,11 @@ object ShivaSvCallingReport {
val
histogramPlotTicks
:
Array
[
Int
]
=
Array
(
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
100000000
)
val
histogramText
:
List
[
String
]
=
List
(
"<=100bp"
,
"0.1-1kb"
,
"1-10kb"
,
"10-100kb"
,
"0.1-1Mb"
,
"1-10Mb"
,
">10Mb"
)
def
parseSummaryForSvCounts
(
summary
:
Summary
)
:
Map
[
String
,
Map
[
String
,
Array
[
Long
]]]
=
{
def
parseSummaryForSvCounts
(
summary
:
Summary
Db
,
runId
:
Int
,
sampleNames
:
Seq
[
String
]
)
:
Map
[
String
,
Map
[
String
,
Array
[
Long
]]]
=
{
var
delCounts
,
insCounts
,
dupCounts
,
invCounts
:
Map
[
String
,
Array
[
Long
]]
=
Map
()
for
(
sampleName
<-
s
ummary
.
s
amples
)
{
va
r
sampleCounts
:
Map
[
String
,
Any
]
=
summary
.
getSampleValue
(
sampl
eName
,
"shivasvcalling"
,
"stats"
,
"variantsBySizeAndType"
)
.
get
.
asInstanceOf
[
Map
[
String
,
Any
]]
for
(
sampleName
<-
sampl
eNam
es
)
{
va
l
sampleCounts
:
Map
[
String
,
Any
]
=
Await
.
result
(
summary
.
getStat
(
runId
,
Pipelin
eName
(
"shivasvcalling"
)
,
ModuleName
(
"variantsBySizeAndType"
)
,
SampleName
(
sampleName
)),
Duration
.
Inf
).
get
for
((
svType
,
counts
)
<-
sampleCounts
.
collect
({
case
(
k
,
v
:
List
[
_
])
=>
(
k
,
v
.
toArray
[
Any
])
}))
{
val
elem
:
Tuple2
[
String
,
Array
[
Long
]]
=
(
sampleName
,
counts
.
collect
({
case
x
:
Long
=>
x
}))
svType
match
{
...
...
@@ -35,16 +39,16 @@ object ShivaSvCallingReport {
result
}
def
parseSummaryForTranslocations
(
summary
:
Summary
)
:
Map
[
String
,
Long
]
=
{
def
parseSummaryForTranslocations
(
summary
:
Summary
Db
,
runId
:
Int
,
sampleNames
:
Seq
[
String
]
)
:
Map
[
String
,
Long
]
=
{
var
traCounts
:
Map
[
String
,
Long
]
=
Map
()
for
(
sampleName
<-
s
ummary
.
s
amples
)
{
va
r
counts
:
Map
[
String
,
Any
]
=
summary
.
getSampleValue
(
sampl
eName
,
"shivasvcalling"
,
"stats"
,
"variantsBySizeAndType"
)
.
get
.
asInstanceOf
[
Map
[
String
,
Any
]]
for
(
sampleName
<-
sampl
eNam
es
)
{
va
l
counts
:
Map
[
String
,
Any
]
=
Await
.
result
(
summary
.
getStat
(
runId
,
Pipelin
eName
(
"shivasvcalling"
)
,
ModuleName
(
"variantsBySizeAndType"
)
,
SampleName
(
sampleName
)),
Duration
.
Inf
).
get
traCounts
+=
(
sampleName
->
counts
.
get
(
"TRA"
).
get
.
asInstanceOf
[
Long
])
}
if
(
traCounts
.
exists
(
elem
=>
elem
.
_2
>
0
))
traCounts
else
Map
.
empty
}
def
writeTsvFiles
(
sampleNames
:
List
[
String
],
counts
:
Map
[
String
,
Map
[
String
,
Array
[
Long
]]],
svTypes
:
List
[
SvTypeForReport
],
outFileAllTypes
:
String
,
outDir
:
File
)
:
Unit
=
{
def
writeTsvFiles
(
sampleNames
:
Seq
[
String
],
counts
:
Map
[
String
,
Map
[
String
,
Array
[
Long
]]],
svTypes
:
List
[
SvTypeForReport
],
outFileAllTypes
:
String
,
outDir
:
File
)
:
Unit
=
{
val
tsvWriter
=
new
PrintWriter
(
new
File
(
outDir
,
outFileAllTypes
))
tsvWriter
.
print
(
"sv_type\tsample"
)
...
...
@@ -64,7 +68,7 @@ object ShivaSvCallingReport {
tsvWriter
.
close
()
}
def
writeTsvFileForSvType
(
svType
:
SvTypeForReport
,
counts
:
Map
[
String
,
Array
[
Long
]],
sampleNames
:
List
[
String
],
outDir
:
File
)
:
Unit
=
{
def
writeTsvFileForSvType
(
svType
:
SvTypeForReport
,
counts
:
Map
[
String
,
Array
[
Long
]],
sampleNames
:
Seq
[
String
],
outDir
:
File
)
:
Unit
=
{
val
tsvWriter
=
new
PrintWriter
(
new
File
(
outDir
,
svType
.
tsvFileName
))
tsvWriter
.
print
(
"histogramBin"
)
...
...
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