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
eb4539c3
Commit
eb4539c3
authored
Feb 21, 2017
by
Peter van 't Hof
Browse files
Fix style
parent
74d3c3a9
Changes
8
Hide whitespace changes
Inline
Side-by-side
bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BammetricsReport.scala
View file @
eb4539c3
...
...
@@ -14,12 +14,12 @@
*/
package
nl.lumc.sasc.biopet.pipelines.bammetrics
import
java.io.
{
File
,
PrintWriter
}
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core.report.
{
ReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.core.report.
{
ReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
nl.lumc.sasc.biopet.utils.rscript.
{
LinePlot
,
StackedBarPlot
}
import
nl.lumc.sasc.biopet.utils.rscript.
{
LinePlot
,
StackedBarPlot
}
import
nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import
scala.concurrent.ExecutionContext.Implicits.global
...
...
@@ -69,10 +69,9 @@ object BammetricsReport extends ReportBuilder {
val
insertsizeMetrics
=
summary
.
getStatKeys
(
runId
,
Right
(
metricsTag
),
Some
(
Right
(
"CollectInsertSizeMetrics"
)),
sample
=
sampleId
.
map
(
Left
(
_
)),
library
=
libId
.
map
(
Left
(
_
)),
Map
(
"metrics"
->
List
(
"metrics"
)))
.
exists
(
_
.
_2
.
isDefined
)
.
exists
(
_
.
_2
.
isDefined
)
val
targetSettings
=
summary
.
getSettingKeys
(
runId
,
Right
(
metricsTag
),
None
,
sample
=
sampleId
.
map
(
Left
(
_
)),
library
=
libId
.
map
(
Left
(
_
)),
val
targetSettings
=
summary
.
getSettingKeys
(
runId
,
Right
(
metricsTag
),
None
,
sample
=
sampleId
.
map
(
Left
(
_
)),
library
=
libId
.
map
(
Left
(
_
)),
Map
(
"amplicon_name"
->
List
(
"amplicon_name"
),
"roi_name"
->
List
(
"roi_name"
)))
val
targets
=
(
targetSettings
(
"amplicon_name"
),
...
...
@@ -136,9 +135,9 @@ object BammetricsReport extends ReportBuilder {
summary
.
getStatsForLibraries
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"bamstats"
)),
sampleId
=
sampleId
,
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
.
_1
,
Some
(
x
.
_1
.
_2
))
->
x
.
_2
)
}
else
summary
.
getStatsForSamples
(
runId
,
Right
(
"bammetrics"
),
Some
(
Right
(
"bamstats"
)),
sample
=
sampleId
.
map
(
Left
(
_
)),
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
)
sample
=
sampleId
.
map
(
Left
(
_
)),
keyValues
=
statsPaths
).
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
)
for
(((
s
,
l
),
result
)
<-
results
)
{
for
(((
s
,
l
),
result
)
<-
results
)
{
val
sampleName
:
String
=
summary
.
getSampleName
(
s
).
map
(
_
.
get
)
val
libName
:
Option
[
String
]
=
l
.
flatMap
(
x
=>
Await
.
result
(
summary
.
getLibraryName
(
x
),
Duration
.
Inf
))
val
sb
=
new
StringBuffer
()
...
...
@@ -168,20 +167,20 @@ object BammetricsReport extends ReportBuilder {
}
def
writePlotFromSummary
(
outputDir
:
File
,
prefix
:
String
,
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libraryId
:
Option
[
Int
]
=
None
,
statsPaths
:
Map
[
String
,
List
[
String
]],
xKey
:
String
,
yKey
:
String
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]],
xlabel
:
Option
[
String
]
=
None
,
ylabel
:
Option
[
String
]
=
None
,
title
:
Option
[
String
]
=
None
,
removeZero
:
Boolean
=
true
)
:
Unit
=
{
prefix
:
String
,
summary
:
SummaryDb
,
libraryLevel
:
Boolean
=
false
,
sampleId
:
Option
[
Int
]
=
None
,
libraryId
:
Option
[
Int
]
=
None
,
statsPaths
:
Map
[
String
,
List
[
String
]],
xKey
:
String
,
yKey
:
String
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]],
xlabel
:
Option
[
String
]
=
None
,
ylabel
:
Option
[
String
]
=
None
,
title
:
Option
[
String
]
=
None
,
removeZero
:
Boolean
=
true
)
:
Unit
=
{
val
tsvFile
=
new
File
(
outputDir
,
prefix
+
".tsv"
)
val
pngFile
=
new
File
(
outputDir
,
prefix
+
".png"
)
...
...
@@ -191,14 +190,15 @@ object BammetricsReport extends ReportBuilder {
}
else
summary
.
getStatsForSamples
(
runId
,
pipeline
,
module
,
sample
=
sampleId
.
map
(
Left
(
_
)),
keyValues
=
statsPaths
)
.
map
(
x
=>
(
x
.
_1
,
None
)
->
x
.
_2
.
map
(
x
=>
x
.
_1
->
x
.
_2
.
map
(
ConfigUtils
.
any2list
(
_
).
toArray
)))
val
tables
:
Array
[
Map
[
String
,
Array
[
Any
]]]
=
results
.
map
{
case
((
sample
,
library
),
map
)
=>
val
tables
:
Array
[
Map
[
String
,
Array
[
Any
]]]
=
results
.
map
{
case
((
sample
,
library
),
map
)
=>
val
sampleName
=
Await
.
result
(
summary
.
getSampleName
(
sample
),
Duration
.
Inf
)
.
getOrElse
(
throw
new
IllegalStateException
(
"Sample must be there"
))
val
libraryName
=
library
.
flatMap
(
l
=>
Await
.
result
(
summary
.
getLibraryName
(
l
),
Duration
.
Inf
))
Map
(
yKey
->
map
(
yKey
).
getOrElse
(
Array
()),
(
sampleName
+
libraryName
.
map
(
"-"
+
_
)
getOrElse
(
""
))
->
map
(
xKey
).
getOrElse
(
Array
())
)
Map
(
yKey
->
map
(
yKey
).
getOrElse
(
Array
()),
(
sampleName
+
libraryName
.
map
(
"-"
+
_
)
getOrElse
(
""
))
->
map
(
xKey
).
getOrElse
(
Array
())
)
}.
toArray
writeTableToTsv
(
tsvFile
,
mergeTables
(
tables
,
yKey
),
yKey
)
...
...
@@ -230,7 +230,7 @@ object BammetricsReport extends ReportBuilder {
"count"
->
List
(
"histogram"
,
"All_Reads.fr_count"
)
)
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
writePlotFromSummary
(
outputDir
,
prefix
,
summary
,
libraryLevel
,
sampleId
,
libraryId
,
statsPaths
,
"insert_size"
,
"count"
,
Right
(
"bammetrics"
),
Some
(
Right
(
"CollectInsertSizeMetrics"
)),
"Insert size"
,
"Reads"
,
"Insert size"
)
}
...
...
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/MultisampleReportBuilder.scala
View file @
eb4539c3
...
...
@@ -50,14 +50,14 @@ trait MultisampleReportBuilder extends ReportBuilder {
val
samplePages
=
samples
.
map
(
_
.
id
)
.
map
(
sampleId
=>
sampleId
->
samplePage
(
sampleId
,
args
++
Map
(
"sampleId"
->
Some
(
sampleId
))))
.
toList
ReportPage
(
samplePages
.
map
(
x
=>
samples
.
find
(
_
.
name
==
x
.
_1
).
get
.
name
->
x
.
_2
),
samplesSections
,
args
)
ReportPage
(
samplePages
.
map
(
x
=>
samples
.
find
(
_
.
id
==
x
.
_1
).
get
.
name
->
x
.
_2
),
samplesSections
,
args
)
}
/** Generate the libraries page for a single sample with a subpage for eacht library */
def
generateLibraryPage
(
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
sampleId
=
args
(
"sampleId"
)
match
{
case
Some
(
x
:
Int
)
=>
x
case
None
=>
throw
new
IllegalStateException
(
"Sample not found"
)
case
None
=>
throw
new
IllegalStateException
(
"Sample not found"
)
}
val
libraries
=
Await
.
result
(
summary
.
getLibraries
(
runId
=
Some
(
runId
),
sampleId
=
Some
(
sampleId
)),
Duration
.
Inf
)
...
...
@@ -65,6 +65,6 @@ trait MultisampleReportBuilder extends ReportBuilder {
val
libPages
=
libraries
.
map
(
_
.
id
)
.
map
(
libId
=>
libId
->
libraryPage
(
sampleId
,
libId
,
args
++
Map
(
"libId"
->
Some
(
libId
))))
.
toList
ReportPage
(
libPages
.
map
(
x
=>
libraries
.
find
(
_
.
name
==
x
.
_1
).
get
.
name
->
x
.
_2
),
librariesSections
,
args
)
ReportPage
(
libPages
.
map
(
x
=>
libraries
.
find
(
_
.
id
==
x
.
_1
).
get
.
name
->
x
.
_2
),
librariesSections
,
args
)
}
}
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala
View file @
eb4539c3
...
...
@@ -17,15 +17,15 @@ package nl.lumc.sasc.biopet.core.report
import
java.io._
import
nl.lumc.sasc.biopet.core.ToolCommandFunction
import
nl.lumc.sasc.biopet.utils.summary.db.Schema.
{
Library
,
Sample
}
import
nl.lumc.sasc.biopet.utils.summary.db.Schema.
{
Library
,
Sample
}
import
nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import
nl.lumc.sasc.biopet.utils.
{
IoUtils
,
Logging
,
ToolCommand
}
import
nl.lumc.sasc.biopet.utils.
{
IoUtils
,
Logging
,
ToolCommand
}
import
org.broadinstitute.gatk.utils.commandline.Input
import
nl.lumc.sasc.biopet.utils.tryToParseNumber
import
org.fusesource.scalate.
{
TemplateEngine
,
TemplateSource
}
import
org.fusesource.scalate.
{
TemplateEngine
,
TemplateSource
}
import
scala.collection.mutable
import
scala.concurrent.
{
Await
,
Future
}
import
scala.concurrent.
{
Await
,
Future
}
import
scala.concurrent.duration.Duration
import
scala.language.postfixOps
...
...
@@ -73,8 +73,8 @@ trait ReportBuilderExtension extends ToolCommandFunction {
trait
ReportBuilder
extends
ToolCommand
{
implicit
def
toOption
[
T
](
x
:
T
)
:
Option
[
T
]
=
Option
(
x
)
implicit
def
autoWait
[
T
](
x
:
Future
[
T
])
:
T
=
Await
.
result
(
x
,
Duration
.
Inf
)
implicit
def
toOption
[
T
](
x
:
T
)
:
Option
[
T
]
=
Option
(
x
)
implicit
def
autoWait
[
T
](
x
:
Future
[
T
])
:
T
=
Await
.
result
(
x
,
Duration
.
Inf
)
case
class
Args
(
summaryDbFile
:
File
=
null
,
outputDir
:
File
=
null
,
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/implicits/Either.scala
View file @
eb4539c3
package
nl.lumc.sasc.biopet.utils.implicits
/**
* Created by pjvanthof on 20/02/2017.
*/
* Created by pjvanthof on 20/02/2017.
*/
object
Either
{
implicit
def
optionEitherLeft
[
T
](
x
:
Option
[
Either
[
T
,
_
]])
:
Option
[
Option
[
T
]]
=
{
implicit
def
optionEitherLeft
[
T
](
x
:
Option
[
Either
[
T
,
_
]])
:
Option
[
Option
[
T
]]
=
{
x
match
{
case
Some
(
i
:
Either
[
T
,
_
])
if
i
.
isLeft
=>
Some
(
i
.
left
.
toOption
)
case
_
=>
None
case
Some
(
i
:
Either
[
T
,
_
])
if
i
.
isLeft
=>
Some
(
i
.
left
.
toOption
)
case
_
=>
None
}
}
implicit
def
optionEitherRight
[
T
](
x
:
Option
[
Either
[
_
,
T
]])
:
Option
[
Option
[
T
]]
=
{
implicit
def
optionEitherRight
[
T
](
x
:
Option
[
Either
[
_
,
T
]])
:
Option
[
Option
[
T
]]
=
{
x
match
{
case
Some
(
i
:
Either
[
_
,
T
])
if
i
.
isRight
=>
Some
(
i
.
right
.
toOption
)
case
_
=>
None
case
Some
(
i
:
Either
[
_
,
T
])
if
i
.
isRight
=>
Some
(
i
.
right
.
toOption
)
case
_
=>
None
}
}
implicit
def
eitherLeft
[
T
](
x
:
Either
[
T
,
_
])
:
Option
[
T
]
=
{
implicit
def
eitherLeft
[
T
](
x
:
Either
[
T
,
_
])
:
Option
[
T
]
=
{
x
match
{
case
Left
(
x
)
=>
Some
(
x
)
case
_
=>
None
case
_
=>
None
}
}
implicit
def
eitherRight
[
T
](
x
:
Either
[
_
,
T
])
:
Option
[
T
]
=
{
implicit
def
eitherRight
[
T
](
x
:
Either
[
_
,
T
])
:
Option
[
T
]
=
{
x
match
{
case
Right
(
x
)
=>
Some
(
x
)
case
_
=>
None
case
_
=>
None
}
}
implicit
def
left
[
T
](
x
:
T
)
:
Left
[
T
,
_
]
=
Left
(
x
)
implicit
def
right
[
T
](
x
:
T
)
:
Right
[
_
,
T
]
=
Right
(
x
)
implicit
def
left
[
T
](
x
:
Option
[
T
])
:
Option
[
Left
[
T
,
_
]]
=
x
.
map
(
Left
(
_
))
implicit
def
right
[
T
](
x
:
Option
[
T
])
:
Option
[
Right
[
_
,
T
]]
=
x
.
map
(
Right
(
_
))
implicit
def
left
[
T
](
x
:
T
)
:
Left
[
T
,
_
]
=
Left
(
x
)
implicit
def
right
[
T
](
x
:
T
)
:
Right
[
_
,
T
]
=
Right
(
x
)
implicit
def
left
[
T
](
x
:
Option
[
T
])
:
Option
[
Left
[
T
,
_
]]
=
x
.
map
(
Left
(
_
))
implicit
def
right
[
T
](
x
:
Option
[
T
])
:
Option
[
Right
[
_
,
T
]]
=
x
.
map
(
Right
(
_
))
}
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
View file @
eb4539c3
...
...
@@ -207,31 +207,31 @@ class SummaryDb(val db: Database) extends Closeable {
/** Return a Query for [[Stats]] */
def
statsFilter
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
lib
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
=
{
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
=
{
var
f
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
]
=
stats
runId
.
foreach
(
r
=>
f
=
f
.
filter
(
_
.
runId
===
r
))
f
=
pipeline
match
{
case
Some
(
Left
(
id
))
=>
f
.
filter
(
_
.
pipelineId
===
id
)
case
Some
(
Left
(
id
))
=>
f
.
filter
(
_
.
pipelineId
===
id
)
case
Some
(
Right
(
name
))
=>
f
.
join
(
pipelines
).
on
(
_
.
pipelineId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
_
=>
f
case
_
=>
f
}
f
=
module
match
{
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
moduleId
===
id
)
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
moduleId
===
id
)
case
Some
(
Some
(
Right
(
name
)))
=>
f
.
join
(
modules
).
on
(
_
.
moduleId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
Some
(
None
)
=>
f
.
filter
(
_
.
moduleId
.
isEmpty
)
case
_
=>
f
case
Some
(
None
)
=>
f
.
filter
(
_
.
moduleId
.
isEmpty
)
case
_
=>
f
}
f
=
sample
match
{
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
sampleId
===
id
)
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
sampleId
===
id
)
case
Some
(
Some
(
Right
(
name
)))
=>
f
.
join
(
samples
).
on
(
_
.
sampleId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
Some
(
None
)
=>
f
.
filter
(
_
.
sampleId
.
isEmpty
)
case
_
=>
f
case
Some
(
None
)
=>
f
.
filter
(
_
.
sampleId
.
isEmpty
)
case
_
=>
f
}
f
=
module
match
{
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
libraryId
===
id
)
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
libraryId
===
id
)
case
Some
(
Some
(
Right
(
name
)))
=>
f
.
join
(
libraries
).
on
(
_
.
libraryId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
Some
(
None
)
=>
f
.
filter
(
_
.
libraryId
.
isEmpty
)
case
_
=>
f
case
Some
(
None
)
=>
f
.
filter
(
_
.
libraryId
.
isEmpty
)
case
_
=>
f
}
if
(
mustHaveSample
)
f
=
f
.
filter
(
_
.
sampleId
.
nonEmpty
)
...
...
@@ -242,14 +242,14 @@ class SummaryDb(val db: Database) extends Closeable {
/** Return all stats that match given criteria */
def
getStats
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
lib
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
:
Future
[
Seq
[
Stat
]]
=
{
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
:
Future
[
Seq
[
Stat
]]
=
{
db
.
run
(
statsFilter
(
runId
,
pipeline
,
module
,
sample
,
lib
,
mustHaveSample
,
mustHaveLibrary
).
result
)
}
/** Return number of results */
def
getStatsSize
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
library
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
:
Future
[
Int
]
=
{
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
:
Future
[
Int
]
=
{
db
.
run
(
statsFilter
(
runId
,
pipeline
,
module
,
sample
,
library
,
mustHaveSample
,
mustHaveLibrary
).
size
.
result
)
}
...
...
@@ -264,11 +264,12 @@ class SummaryDb(val db: Database) extends Closeable {
sample
:
Option
[
Either
[
Int
,
String
]]
=
None
,
library
:
Option
[
Either
[
Int
,
String
]]
=
None
,
keyValues
:
Map
[
String
,
List
[
String
]])
:
Map
[
String
,
Option
[
Any
]]
=
{
val
stats
=
Await
.
result
(
getStat
(
runId
,
pipeline
,
module
,
sample
,
library
),
Duration
.
Inf
)
keyValues
.
map
{
case
(
key
,
path
)
=>
stats
match
{
case
Some
(
map
)
=>
key
->
ConfigUtils
.
getValueFromPath
(
map
,
path
)
case
None
=>
key
->
None
}
keyValues
.
map
{
case
(
key
,
path
)
=>
stats
match
{
case
Some
(
map
)
=>
key
->
ConfigUtils
.
getValueFromPath
(
map
,
path
)
case
None
=>
key
->
None
}
}
}
...
...
@@ -295,32 +296,32 @@ class SummaryDb(val db: Database) extends Closeable {
}
def
settingsFilter
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
lib
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
=
{
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
lib
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
=
{
var
f
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
]
=
settings
runId
.
foreach
(
r
=>
f
=
f
.
filter
(
_
.
runId
===
r
))
f
=
pipeline
match
{
case
Some
(
Left
(
id
))
=>
f
.
filter
(
_
.
pipelineId
===
id
)
case
Some
(
Left
(
id
))
=>
f
.
filter
(
_
.
pipelineId
===
id
)
case
Some
(
Right
(
name
))
=>
f
.
join
(
pipelines
).
on
(
_
.
pipelineId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
_
=>
f
case
_
=>
f
}
f
=
module
match
{
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
moduleId
===
id
)
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
moduleId
===
id
)
case
Some
(
Some
(
Right
(
name
)))
=>
f
.
join
(
modules
).
on
(
_
.
moduleId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
Some
(
None
)
=>
f
.
filter
(
_
.
moduleId
.
isEmpty
)
case
_
=>
f
case
Some
(
None
)
=>
f
.
filter
(
_
.
moduleId
.
isEmpty
)
case
_
=>
f
}
f
=
sample
match
{
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
sampleId
===
id
)
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
sampleId
===
id
)
case
Some
(
Some
(
Right
(
name
)))
=>
f
.
join
(
samples
).
on
(
_
.
sampleId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
Some
(
None
)
=>
f
.
filter
(
_
.
sampleId
.
isEmpty
)
case
_
=>
f
case
Some
(
None
)
=>
f
.
filter
(
_
.
sampleId
.
isEmpty
)
case
_
=>
f
}
f
=
module
match
{
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
libraryId
===
id
)
case
Some
(
Some
(
Left
(
id
)))
=>
f
.
filter
(
_
.
libraryId
===
id
)
case
Some
(
Some
(
Right
(
name
)))
=>
f
.
join
(
libraries
).
on
(
_
.
libraryId
===
_
.
id
).
filter
(
_
.
_2
.
name
===
name
).
map
(
_
.
_1
)
case
Some
(
None
)
=>
f
.
filter
(
_
.
libraryId
.
isEmpty
)
case
_
=>
f
case
Some
(
None
)
=>
f
.
filter
(
_
.
libraryId
.
isEmpty
)
case
_
=>
f
}
if
(
mustHaveSample
)
f
=
f
.
filter
(
_
.
sampleId
.
nonEmpty
)
...
...
@@ -328,7 +329,6 @@ class SummaryDb(val db: Database) extends Closeable {
f
}
/** This method creates or update a setting. */
def
createOrUpdateSetting
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
,
content
:
String
)
:
Future
[
Int
]
=
{
...
...
@@ -339,38 +339,39 @@ class SummaryDb(val db: Database) extends Closeable {
}
/** Return all settings that match the given criteria */
def
getSettings
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
library
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
)
:
Future
[
Seq
[
Setting
]]
=
{
def
getSettings
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
library
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
)
:
Future
[
Seq
[
Setting
]]
=
{
db
.
run
(
settingsFilter
(
runId
,
pipeline
,
module
,
sample
,
library
).
result
)
}
/** Return a specific setting as [[Map[String, Any]] */
def
getSetting
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sample
:
Option
[
Either
[
Int
,
String
]]
=
None
,
library
:
Option
[
Either
[
Int
,
String
]]
=
None
)
:
Future
[
Option
[
Map
[
String
,
Any
]]]
=
{
def
getSetting
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sample
:
Option
[
Either
[
Int
,
String
]]
=
None
,
library
:
Option
[
Either
[
Int
,
String
]]
=
None
)
:
Future
[
Option
[
Map
[
String
,
Any
]]]
=
{
getSettings
(
Some
(
runId
),
Some
(
pipeline
),
Some
(
module
),
Some
(
sample
),
Some
(
library
))
.
map
(
_
.
headOption
.
map
(
x
=>
ConfigUtils
.
jsonTextToMap
(
x
.
content
)))
}
def
getSettingKeys
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sample
:
Option
[
Either
[
Int
,
String
]]
=
None
,
library
:
Option
[
Either
[
Int
,
String
]]
=
None
,
def
getSettingKeys
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sample
:
Option
[
Either
[
Int
,
String
]]
=
None
,
library
:
Option
[
Either
[
Int
,
String
]]
=
None
,
keyValues
:
Map
[
String
,
List
[
String
]])
:
Map
[
String
,
Option
[
Any
]]
=
{
val
stats
=
Await
.
result
(
getSetting
(
runId
,
pipeline
,
module
,
sample
,
library
),
Duration
.
Inf
)
keyValues
.
map
{
case
(
key
,
path
)
=>
stats
match
{
case
Some
(
map
)
=>
key
->
ConfigUtils
.
getValueFromPath
(
map
,
path
)
case
None
=>
key
->
None
}
keyValues
.
map
{
case
(
key
,
path
)
=>
stats
match
{
case
Some
(
map
)
=>
key
->
ConfigUtils
.
getValueFromPath
(
map
,
path
)
case
None
=>
key
->
None
}
}
}
def
getSettingsForSamples
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
keyValues
:
Map
[
String
,
List
[
String
]])
=
{
def
getSettingsForSamples
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
keyValues
:
Map
[
String
,
List
[
String
]])
=
{
val
samples
=
Await
.
result
(
getSamples
(
runId
=
Some
(
runId
),
sampleId
=
sampleId
),
Duration
.
Inf
)
(
for
(
sample
<-
samples
)
yield
{
sample
.
id
->
getSettingKeys
(
runId
,
pipeline
,
module
,
Some
(
Left
(
sample
.
id
)),
None
,
keyValues
=
keyValues
)
}).
toMap
}
def
getSettingsForLibraries
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
keyValues
:
Map
[
String
,
List
[
String
]])
=
{
def
getSettingsForLibraries
(
runId
:
Int
,
pipeline
:
Either
[
Int
,
String
],
module
:
Option
[
Either
[
Int
,
String
]]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
keyValues
:
Map
[
String
,
List
[
String
]])
=
{
val
libraries
=
Await
.
result
(
getLibraries
(
runId
=
Some
(
runId
),
sampleId
=
sampleId
),
Duration
.
Inf
)
(
for
(
lib
<-
libraries
)
yield
{
(
lib
.
sampleId
,
lib
.
id
)
->
getSettingKeys
(
runId
,
pipeline
,
module
,
Some
(
Left
(
lib
.
sampleId
)),
Some
(
Left
(
lib
.
id
)),
keyValues
=
keyValues
)
...
...
gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/GearsReport.scala
View file @
eb4539c3
...
...
@@ -15,7 +15,7 @@
package
nl.lumc.sasc.biopet.pipelines.gears
import
nl.lumc.sasc.biopet.utils.implicits.Either._
import
nl.lumc.sasc.biopet.core.report.
{
MultisampleReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.core.report.
{
MultisampleReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import
nl.lumc.sasc.biopet.utils.config.Configurable
...
...
@@ -86,7 +86,6 @@ object GearsReport extends MultisampleReportBuilder {
val
qiimeClosesOtuTable
=
Await
.
result
(
summary
.
getFile
(
runId
,
"gears"
,
None
,
sampleName
,
None
,
key
=
"qiime_closed_otu_table"
),
Duration
.
Inf
)
val
qiimeOpenOtuTable
=
Await
.
result
(
summary
.
getFile
(
runId
,
"gears"
,
None
,
sampleName
,
None
,
key
=
"qiime_open_otu_table"
),
Duration
.
Inf
)
ReportPage
((
if
(
centrifugeExecuted
)
List
(
"Centriguge analysis"
->
ReportPage
(
List
(
"Non-unique"
->
ReportPage
(
List
(),
List
(
"All mappings"
->
ReportSection
(
"/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
,
Map
(
"summaryStatsTag"
->
"centrifuge_report"
)
)),
Map
())),
List
(
...
...
@@ -121,7 +120,6 @@ object GearsReport extends MultisampleReportBuilder {
val
qiimeClosesOtuTable
=
Await
.
result
(
summary
.
getFile
(
runId
,
"gears"
,
None
,
sName
,
lName
,
key
=
"qiime_closed_otu_table"
),
Duration
.
Inf
)
val
qiimeOpenOtuTable
=
Await
.
result
(
summary
.
getFile
(
runId
,
"gears"
,
None
,
sName
,
lName
,
key
=
"qiime_open_otu_table"
),
Duration
.
Inf
)
ReportPage
(
(
if
(
flexiprepExecuted
)
List
(
"QC"
->
FlexiprepReport
.
flexiprepPage
)
else
Nil
)
:::
(
if
(
centrifugeExecuted
)
List
(
"Centriguge analysis"
->
ReportPage
(
List
(
"Non-unique"
->
ReportPage
(
List
(),
List
(
"All mappings"
->
ReportSection
(
"/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
,
...
...
mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMappingReport.scala
View file @
eb4539c3
...
...
@@ -14,7 +14,7 @@
*/
package
nl.lumc.sasc.biopet.pipelines.mapping
import
nl.lumc.sasc.biopet.core.report.
{
MultisampleReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.core.report.
{
MultisampleReportBuilder
,
ReportBuilderExtension
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import
nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
import
nl.lumc.sasc.biopet.utils.config.Configurable
...
...
shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala
View file @
eb4539c3
...
...
@@ -14,14 +14,14 @@
*/
package
nl.lumc.sasc.biopet.pipelines.shiva
import
java.io.
{
File
,
PrintWriter
}
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.core.report._
import
nl.lumc.sasc.biopet.pipelines.mapping.MultisampleMappingReportTrait
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.utils.rscript.StackedBarPlot
import
nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import
nl.lumc.sasc.biopet.utils.summary.
{
Summary
,
SummaryValue
}
import
nl.lumc.sasc.biopet.utils.summary.
{
Summary
,
SummaryValue
}
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
...
...
@@ -43,9 +43,9 @@ trait ShivaReportTrait extends MultisampleMappingReportTrait {
def
variantcallingExecuted
=
summary
.
getSettingKeys
(
runId
,
Right
(
"shiva"
),
None
,
keyValues
=
Map
(
"multisample_variantcalling"
->
List
(
"multisample_variantcalling"
))).
get
(
"multisample_variantcalling"
)
.
flatten
match
{
case
Some
(
true
)
=>
true
case
_
=>
false
}
case
Some
(
true
)
=>
true
case
_
=>
false
}
override
def
frontSection
=
ReportSection
(
"/nl/lumc/sasc/biopet/pipelines/shiva/shivaFront.ssp"
)
...
...
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