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
f8f8af38
Commit
f8f8af38
authored
Feb 16, 2017
by
Peter van 't Hof
Browse files
Start to convert report class
parent
e371afc7
Changes
15
Hide whitespace changes
Inline
Side-by-side
bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
View file @
f8f8af38
...
...
@@ -63,7 +63,7 @@ class BamMetrics(val parent: Configurable) extends QScript
override
def
reportClass
=
{
val
bammetricsReport
=
new
BammetricsReport
(
this
)
bammetricsReport
.
outputDir
=
new
File
(
outputDir
,
"report"
)
bammetricsReport
.
summaryFile
=
summaryFile
bammetricsReport
.
summary
Db
File
=
summary
Db
File
bammetricsReport
.
args
=
if
(
libId
.
isDefined
)
Map
(
"sampleId"
->
sampleId
.
getOrElse
(
"."
),
"libId"
->
libId
.
getOrElse
(
"."
))
...
...
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/MultisampleReportBuilder.scala
View file @
f8f8af38
...
...
@@ -14,6 +14,9 @@
*/
package
nl.lumc.sasc.biopet.core.report
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
/**
* This trait will generate a report with added function to generate sample and library pages for those existing in the summary.
*
...
...
@@ -22,7 +25,7 @@ package nl.lumc.sasc.biopet.core.report
trait
MultisampleReportBuilder
extends
ReportBuilder
{
/** Method to generate a single sample page */
def
samplePage
(
sampleId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
def
samplePage
(
sampleId
:
Int
,
args
:
Map
[
String
,
Any
])
:
ReportPage
/** Default list of samples, can be override */
def
samplesSections
:
List
[(
String
,
ReportSection
)]
=
{
...
...
@@ -32,7 +35,7 @@ trait MultisampleReportBuilder extends ReportBuilder {
}
/** Method to generate a single library page */
def
libraryPage
(
sampleId
:
String
,
libraryId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
def
libraryPage
(
sampleId
:
Int
,
libraryId
:
Int
,
args
:
Map
[
String
,
Any
])
:
ReportPage
/** Default list of libraries, can be override */
def
librariesSections
:
List
[(
String
,
ReportSection
)]
=
{
...
...
@@ -43,22 +46,25 @@ trait MultisampleReportBuilder extends ReportBuilder {
/** Generate the samples page including a single sample page for each sample in the summary */
def
generateSamplesPage
(
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
samplePages
=
summary
.
samples
val
samples
=
Await
.
result
(
summary
.
getSamples
(
runId
=
Some
(
runId
)),
Duration
.
Inf
)
val
samplePages
=
samples
.
map
(
_
.
id
)
.
map
(
sampleId
=>
sampleId
->
samplePage
(
sampleId
,
args
++
Map
(
"sampleId"
->
Some
(
sampleId
))))
.
toList
ReportPage
(
samplePages
,
samplesSections
,
args
)
ReportPage
(
samplePages
.
map
(
x
=>
samples
.
find
(
_
.
name
==
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
)
=>
x
.
toString
case
Some
(
x
:
Int
)
=>
x
case
None
=>
throw
new
IllegalStateException
(
"Sample not found"
)
}
val
libPages
=
summary
.
libraries
(
sampleId
)
val
libraries
=
Await
.
result
(
summary
.
getLibraries
(
runId
=
Some
(
runId
),
sampleId
=
Some
(
sampleId
)),
Duration
.
Inf
)
val
libPages
=
libraries
.
map
(
_
.
id
)
.
map
(
libId
=>
libId
->
libraryPage
(
sampleId
,
libId
,
args
++
Map
(
"libId"
->
Some
(
libId
))))
.
toList
ReportPage
(
libPages
,
librariesSections
,
args
)
ReportPage
(
libPages
.
map
(
x
=>
libraries
.
find
(
_
.
name
==
x
.
_1
).
get
.
name
->
x
.
_2
)
,
librariesSections
,
args
)
}
}
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala
View file @
f8f8af38
...
...
@@ -17,10 +17,10 @@ package nl.lumc.sasc.biopet.core.report
import
java.io._
import
nl.lumc.sasc.biopet.core.ToolCommandFunction
import
nl.lumc.sasc.biopet.utils.summary.Summary
import
nl.lumc.sasc.biopet.utils.
{
IoUtils
,
Logging
,
ToolCommand
}
import
nl.lumc.sasc.biopet.utils.summary.
db.
Summary
Db
import
nl.lumc.sasc.biopet.utils.
{
IoUtils
,
Logging
,
ToolCommand
}
import
org.broadinstitute.gatk.utils.commandline.Input
import
org.fusesource.scalate.
{
TemplateEngine
,
TemplateSource
}
import
org.fusesource.scalate.
{
TemplateEngine
,
TemplateSource
}
import
scala.collection.mutable
import
scala.language.postfixOps
...
...
@@ -38,7 +38,9 @@ trait ReportBuilderExtension extends ToolCommandFunction {
def
toolObject
=
builder
@Input
(
required
=
true
)
var
summaryFile
:
File
=
_
var
summaryDbFile
:
File
=
_
var
runId
:
Option
[
Int
]
=
None
/** OutputDir for the report */
var
outputDir
:
File
=
_
...
...
@@ -58,7 +60,8 @@ trait ReportBuilderExtension extends ToolCommandFunction {
/** Command to generate the report */
override
def
cmdLine
:
String
=
{
super
.
cmdLine
+
required
(
"--summary"
,
summaryFile
)
+
required
(
"--summaryDb"
,
summaryDbFile
)
+
optional
(
"--runId"
,
runId
)
+
required
(
"--outputDir"
,
outputDir
)
+
args
.
map
(
x
=>
required
(
"-a"
,
x
.
_1
+
"="
+
x
.
_2
)).
mkString
}
...
...
@@ -66,8 +69,9 @@ trait ReportBuilderExtension extends ToolCommandFunction {
trait
ReportBuilder
extends
ToolCommand
{
case
class
Args
(
summary
:
File
=
null
,
case
class
Args
(
summary
DbFile
:
File
=
null
,
outputDir
:
File
=
null
,
runId
:
Int
=
0
,
pageArgs
:
mutable.Map
[
String
,
Any
]
=
mutable
.
Map
())
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
...
...
@@ -78,8 +82,8 @@ trait ReportBuilder extends ToolCommand {
"""
.
stripMargin
)
opt
[
File
](
's'
,
"summary"
)
unbounded
()
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
summary
=
x
)
opt
[
File
](
's'
,
"summary
Db
"
)
unbounded
()
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
summary
DbFile
=
x
)
}
validate
{
x
=>
if
(
x
.
exists
)
success
else
failure
(
"Summary JSON file not found!"
)
}
text
"Biopet summary JSON file"
...
...
@@ -88,17 +92,27 @@ trait ReportBuilder extends ToolCommand {
c
.
copy
(
outputDir
=
x
)
}
text
"Output HTML report files to this directory"
opt
[
Int
](
"runId"
)
unbounded
()
maxOccurs
1
valueName
"<int>"
action
{
(
x
,
c
)
=>
c
.
copy
(
runId
=
x
)
}
opt
[
Map
[
String
,
String
]](
'a'
,
"args"
)
unbounded
()
action
{
(
x
,
c
)
=>
c
.
copy
(
pageArgs
=
c
.
pageArgs
++
x
)
}
}
/** summary object internaly */
private
var
setSummary
:
Summary
=
_
private
var
setSummary
:
Summary
Db
=
_
/** Retrival of summary, read only */
final
def
summary
=
setSummary
/** summary object internaly */
private
var
setRunId
:
Int
=
0
/** Retrival of summary, read only */
final
def
runId
=
setRunId
/** default args that are passed to all page withing the report */
def
pageArgs
:
Map
[
String
,
Any
]
=
Map
()
...
...
@@ -165,7 +179,8 @@ trait ReportBuilder extends ToolCommand {
)
logger
.
info
(
"Parsing summary"
)
setSummary
=
new
Summary
(
cmdArgs
.
summary
)
setSummary
=
SummaryDb
.
openSqliteSummary
(
cmdArgs
.
summaryDbFile
)
setRunId
=
cmdArgs
.
runId
total
=
ReportBuilder
.
countPages
(
indexPage
)
logger
.
info
(
total
+
" pages to be generated"
)
...
...
@@ -175,7 +190,7 @@ trait ReportBuilder extends ToolCommand {
logger
.
info
(
"Generate pages"
)
val
jobs
=
generatePage
(
summary
,
indexPage
,
cmdArgs
.
outputDir
,
args
=
pageArgs
++
cmdArgs
.
pageArgs
.
toMap
++
Map
(
"summary"
->
summary
,
"reportName"
->
reportName
,
"indexPage"
->
indexPage
))
Map
(
"summary"
->
summary
,
"reportName"
->
reportName
,
"indexPage"
->
indexPage
,
"runId"
->
cmdArgs
.
runId
))
logger
.
info
(
jobs
+
" Done"
)
}
...
...
@@ -196,7 +211,7 @@ trait ReportBuilder extends ToolCommand {
* @param args Args to add to this sub page, are args from current page are passed automaticly
* @return Number of pages including all subpages that are rendered
*/
def
generatePage
(
summary
:
Summary
,
def
generatePage
(
summary
:
Summary
Db
,
page
:
ReportPage
,
outputDir
:
File
,
path
:
List
[
String
]
=
Nil
,
...
...
biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/report/MultisampleReportBuilderTest.scala
View file @
f8f8af38
...
...
@@ -36,10 +36,10 @@ class MultisampleReportBuilderTest extends TestNGSuite with Matchers {
def
reportName
:
String
=
"test"
def
indexPage
:
ReportPage
=
ReportPage
(
"Samples"
->
generateSamplesPage
(
Map
())
::
Nil
,
Nil
,
Map
())
def
samplePage
(
sampleId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
def
samplePage
(
sampleId
:
Int
,
args
:
Map
[
String
,
Any
])
:
ReportPage
=
ReportPage
(
"Libraries"
->
generateLibraryPage
(
Map
(
"sampleId"
->
Some
(
sampleId
)))
::
Nil
,
Nil
,
Map
())
def
libraryPage
(
sampleId
:
String
,
libraryId
:
String
,
args
:
Map
[
String
,
Any
])
=
ReportPage
(
Nil
,
Nil
,
Map
())
def
libraryPage
(
sampleId
:
Int
,
libraryId
:
Int
,
args
:
Map
[
String
,
Any
])
=
ReportPage
(
Nil
,
Nil
,
Map
())
}
val
tempDir
=
Files
.
createTempDir
()
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/config/Config.scala
View file @
f8f8af38
...
...
@@ -16,7 +16,7 @@ package nl.lumc.sasc.biopet.utils.config
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
import
nl.lumc.sasc.biopet.utils.ConfigUtils._
import
scala.concurrent.Future
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
View file @
f8f8af38
...
...
@@ -15,7 +15,7 @@ import java.sql.Date
*
* Created by pjvanthof on 05/02/2017.
*/
class
SummaryDb
(
db
:
Database
)
extends
Closeable
{
class
SummaryDb
(
val
db
:
Database
)
extends
Closeable
{
def
close
()
:
Unit
=
db
.
close
()
...
...
@@ -75,6 +75,11 @@ class SummaryDb(db: Database) extends Closeable {
getSamples
(
runId
=
Some
(
runId
),
name
=
Some
(
sampleName
)).
map
(
_
.
headOption
.
map
(
_
.
id
))
}
/** Return samplId of a specific runId + sampleName */
def
getSampleName
(
sampleId
:
Int
)
:
Future
[
Option
[
Int
]]
=
{
getSamples
(
sampleId
=
Some
(
sampleId
)).
map
(
_
.
headOption
.
map
(
_
.
id
))
}
/** Return sample tags of a specific sample as a map */
def
getSampleTags
(
sampleId
:
Int
)
:
Future
[
Option
[
Map
[
String
,
Any
]]]
=
{
db
.
run
(
samples
.
filter
(
_
.
id
===
sampleId
).
map
(
_
.
tags
).
result
)
...
...
@@ -184,7 +189,7 @@ class SummaryDb(db: Database) extends Closeable {
}
/** Return a Query for [[Stats]] */
private
def
statsFilter
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
def
statsFilter
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
)
=
{
var
f
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
]
=
stats
runId
.
foreach
(
r
=>
f
=
f
.
filter
(
_
.
runId
===
r
))
...
...
@@ -215,7 +220,7 @@ class SummaryDb(db: Database) extends Closeable {
}
/** This return a [[Query]] for [[Settings]] */
private
def
settingsFilter
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
def
settingsFilter
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
)
=
{
var
f
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
]
=
settings
runId
.
foreach
(
r
=>
f
=
f
.
filter
(
_
.
runId
===
r
))
...
...
@@ -249,7 +254,7 @@ class SummaryDb(db: Database) extends Closeable {
}
/** Return a [[Query]] for [[Files]] */
private
def
filesFilter
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]],
def
filesFilter
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]],
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
,
key
:
Option
[
String
]
=
None
)
=
{
var
f
:
Query
[
Files
,
Files
#
TableElementType
,
Seq
]
=
files
...
...
@@ -287,7 +292,7 @@ class SummaryDb(db: Database) extends Closeable {
}
/** Returns a [[Query]] for [[Executables]] */
private
def
executablesFilter
(
runId
:
Option
[
Int
],
toolName
:
Option
[
String
])
=
{
def
executablesFilter
(
runId
:
Option
[
Int
],
toolName
:
Option
[
String
])
=
{
var
q
:
Query
[
Executables
,
Executables
#
TableElementType
,
Seq
]
=
executables
runId
.
foreach
(
r
=>
q
=
q
.
filter
(
_
.
runId
===
r
))
toolName
.
foreach
(
r
=>
q
=
q
.
filter
(
_
.
toolName
===
r
))
...
...
carp/src/main/scala/nl/lumc/sasc/biopet/pipelines/carp/Carp.scala
View file @
f8f8af38
...
...
@@ -103,7 +103,7 @@ class Carp(val parent: Configurable) extends QScript with MultisampleMappingTrai
override
def
reportClass
:
Option
[
ReportBuilderExtension
]
=
{
val
carp
=
new
CarpReport
(
this
)
carp
.
outputDir
=
new
File
(
outputDir
,
"report"
)
carp
.
summaryFile
=
summaryFile
carp
.
summary
Db
File
=
summary
Db
File
Some
(
carp
)
}
...
...
flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala
View file @
f8f8af38
...
...
@@ -65,7 +65,7 @@ class Flexiprep(val parent: Configurable) extends QScript with SummaryQScript wi
override
def
reportClass
:
Some
[
FlexiprepReport
]
=
{
val
flexiprepReport
=
new
FlexiprepReport
(
this
)
flexiprepReport
.
outputDir
=
new
File
(
outputDir
,
"report"
)
flexiprepReport
.
summaryFile
=
summaryFile
flexiprepReport
.
summary
Db
File
=
summary
Db
File
flexiprepReport
.
args
=
Map
(
"sampleId"
->
sampleId
.
getOrElse
(
"."
),
"libId"
->
libId
.
getOrElse
(
"."
))
...
...
gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/Gears.scala
View file @
f8f8af38
...
...
@@ -33,7 +33,7 @@ class Gears(val parent: Configurable) extends QScript with MultiSampleQScript {
override
def
reportClass
=
{
val
gearsReport
=
new
GearsReport
(
this
)
gearsReport
.
outputDir
=
new
File
(
outputDir
,
"report"
)
gearsReport
.
summaryFile
=
summaryFile
gearsReport
.
summary
Db
File
=
summary
Db
File
Some
(
gearsReport
)
}
...
...
gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/GearsSingle.scala
View file @
f8f8af38
...
...
@@ -73,7 +73,7 @@ class GearsSingle(val parent: Configurable) extends QScript with SummaryQScript
override
def
reportClass
=
{
val
gears
=
new
GearsSingleReport
(
this
)
gears
.
outputDir
=
new
File
(
outputDir
,
"report"
)
gears
.
summaryFile
=
summaryFile
gears
.
summary
Db
File
=
summary
Db
File
sampleId
.
foreach
(
gears
.
args
+=
"sampleId"
->
_
)
libId
.
foreach
(
gears
.
args
+=
"libId"
->
_
)
Some
(
gears
)
...
...
gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala
View file @
f8f8af38
...
...
@@ -47,7 +47,7 @@ class Gentrap(val parent: Configurable) extends QScript
override
def
reportClass
:
Option
[
ReportBuilderExtension
]
=
{
val
report
=
new
GentrapReport
(
this
)
report
.
outputDir
=
new
File
(
outputDir
,
"report"
)
report
.
summaryFile
=
summaryFile
report
.
summary
Db
File
=
summary
Db
File
Some
(
report
)
}
...
...
mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
View file @
f8f8af38
...
...
@@ -140,7 +140,7 @@ class Mapping(val parent: Configurable) extends QScript with SummaryQScript with
override
def
reportClass
:
Some
[
MappingReport
]
=
{
val
mappingReport
=
new
MappingReport
(
this
)
mappingReport
.
outputDir
=
new
File
(
outputDir
,
"report"
)
mappingReport
.
summaryFile
=
summaryFile
mappingReport
.
summary
Db
File
=
summary
Db
File
mappingReport
.
args
=
Map
(
"sampleId"
->
sampleId
.
getOrElse
(
"."
),
"libId"
->
libId
.
getOrElse
(
"."
))
...
...
mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMapping.scala
View file @
f8f8af38
...
...
@@ -63,7 +63,7 @@ trait MultisampleMappingTrait extends MultiSampleQScript
override
def
reportClass
:
Option
[
ReportBuilderExtension
]
=
{
val
report
=
new
MultisampleMappingReport
(
this
)
report
.
outputDir
=
new
File
(
outputDir
,
"report"
)
report
.
summaryFile
=
summaryFile
report
.
summary
Db
File
=
summary
Db
File
Some
(
report
)
}
...
...
shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/Shiva.scala
View file @
f8f8af38
...
...
@@ -40,7 +40,7 @@ class Shiva(val parent: Configurable) extends QScript with MultisampleMappingTra
override
def
reportClass
:
Option
[
ReportBuilderExtension
]
=
{
val
shiva
=
new
ShivaReport
(
this
)
shiva
.
outputDir
=
new
File
(
outputDir
,
"report"
)
shiva
.
summaryFile
=
summaryFile
shiva
.
summary
Db
File
=
summary
Db
File
Some
(
shiva
)
}
...
...
tinycap/src/main/scala/nl/lumc/sasc/biopet/pipelines/tinycap/TinyCap.scala
View file @
f8f8af38
...
...
@@ -119,7 +119,7 @@ class TinyCap(val parent: Configurable) extends QScript
override
def
reportClass
:
Option
[
ReportBuilderExtension
]
=
{
val
report
=
new
TinyCapReport
(
this
)
report
.
outputDir
=
new
File
(
outputDir
,
"report"
)
report
.
summaryFile
=
summaryFile
report
.
summary
Db
File
=
summary
Db
File
Some
(
report
)
}
...
...
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