Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Mirrors
biopet.biopet
Commits
4228881c
Commit
4228881c
authored
Feb 10, 2017
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding stats to db
parent
c8a93931
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
...scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
+20
-2
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/SummaryDb.scala
...n/scala/nl/lumc/sasc/biopet/utils/summary/SummaryDb.scala
+15
-4
No files found.
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
View file @
4228881c
...
...
@@ -26,9 +26,9 @@ import org.broadinstitute.gatk.utils.commandline.{Input, Output}
import
scala.collection.mutable
import
scala.io.Source
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
import
scala.concurrent.ExecutionContext.Implicits.global
/**
* This will collect and write the summary
...
...
@@ -87,7 +87,25 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
def
run
()
:
Unit
=
{
val
db
=
SummaryDb
.
openSqliteSummary
(
qscript
.
summaryDbFile
)
//TODO: Add stats
val
pipelineId
=
Await
.
result
(
db
.
getPipelines
(
name
=
Some
(
qscript
.
summaryName
),
runId
=
Some
(
qscript
.
summaryRunId
)).
map
(
_
.
head
.
id
),
Duration
.
Inf
)
for
(((
name
,
sampleName
,
libName
),
summarizables
)
<-
qscript
.
summarizables
)
{
require
(
summarizables
.
nonEmpty
)
val
stats
=
ConfigUtils
.
anyToJson
(
if
(
summarizables
.
size
==
1
)
summarizables
.
head
.
summaryStats
else
{
val
s
=
summarizables
.
map
(
_
.
summaryStats
)
s
.
tail
.
foldLeft
(
Map
(
"stats"
->
s
.
head
))((
a
,
b
)
=>
ConfigUtils
.
mergeMaps
(
a
,
Map
(
"stats"
->
b
),
summarizables
.
head
.
resolveSummaryConflict
))(
"stats"
)
})
val
moduleId
=
db
.
getModules
(
name
=
Some
(
name
),
runId
=
Some
(
qscript
.
summaryRunId
),
pipelineId
=
Some
(
pipelineId
))
.
map
(
_
.
head
.
id
)
val
sampleId
=
sampleName
.
map
(
name
=>
db
.
getSamples
(
runId
=
Some
(
qscript
.
summaryRunId
),
name
=
Some
(
name
)).
map
(
_
.
head
.
id
))
val
libId
=
libName
.
map
(
name
=>
db
.
getLibraries
(
runId
=
Some
(
qscript
.
summaryRunId
),
name
=
Some
(
name
),
sampleId
=
sampleId
.
map
(
Await
.
result
(
_
,
Duration
.
Inf
))).
map
(
_
.
head
.
id
))
db
.
createOrUpdateStat
(
qscript
.
summaryRunId
,
pipelineId
,
Some
(
Await
.
result
(
moduleId
,
Duration
.
Inf
)),
sampleId
.
map
(
Await
.
result
(
_
,
Duration
.
Inf
)),
libId
.
map
(
Await
.
result
(
_
,
Duration
.
Inf
)),
stats
.
nospaces
)
}
//TODO: Add Files
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/SummaryDb.scala
View file @
4228881c
...
...
@@ -145,8 +145,16 @@ class SummaryDb(db: Database) extends Closeable {
db
.
run
(
stats
.
forceInsert
(
Stat
(
runId
,
pipelineId
,
moduleId
,
sampleId
,
libId
,
content
)))
}
def
getStats
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
)
=
{
def
createOrUpdateStat
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
,
content
:
String
)
=
{
val
filter
=
statsFilter
(
Some
(
runId
),
Some
(
pipelineId
),
Some
(
moduleId
),
Some
(
sampleId
),
Some
(
libId
))
val
r
=
Await
.
result
(
db
.
run
(
filter
.
size
.
result
),
Duration
.
Inf
)
if
(
r
==
0
)
createStat
(
runId
,
pipelineId
,
moduleId
,
sampleId
,
libId
,
content
)
else
db
.
run
(
filter
.
map
(
_
.
content
).
update
(
content
))
}
private
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
)
=
{
val
l
:
List
[
Option
[
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
]
=>
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
]]]
=
List
(
runId
.
map
(
x
=>
y
=>
y
.
filter
(
_
.
runId
===
x
)),
pipelineId
.
map
(
x
=>
y
=>
y
.
filter
(
_
.
pipelineId
===
x
)),
...
...
@@ -154,9 +162,12 @@ class SummaryDb(db: Database) extends Closeable {
sampleId
.
map
(
x
=>
y
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
sampleId
===
x
)
else
y
.
filter
(
_
.
sampleId
.
isEmpty
))),
libId
.
map
(
x
=>
y
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
x
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
)))
)
val
q
=
l
.
flatten
.
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
l
.
flatten
.
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
}
db
.
run
(
q
.
result
)
def
getStats
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
)
=
{
db
.
run
(
statsFilter
(
runId
,
pipelineId
,
moduleId
,
sampleId
,
libId
).
result
)
}
def
getStat
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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