Skip to content
GitLab
Menu
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
c549917d
Commit
c549917d
authored
Feb 08, 2017
by
Peter van 't Hof
Browse files
Adding methods for stats and settings
parent
8aad8df1
Changes
2
Hide whitespace changes
Inline
Side-by-side
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SummaryToSqlite.scala
View file @
c549917d
...
...
@@ -66,6 +66,12 @@ object SummaryToSqlite extends ToolCommand {
println
(
Await
.
result
(
summary
.
getPipelines
(),
Duration
.
Inf
))
Await
.
result
(
summary
.
createStat
(
runId
,
pipelineId
,
None
,
None
,
None
,
"""{"bla": "bla"}"""
),
Duration
.
Inf
)
println
(
Await
.
result
(
summary
.
getStats
(
runId
=
Some
(
runId
),
pipelineId
=
Some
(
pipelineId
),
sampleId
=
Option
(
None
)),
Duration
.
Inf
))
println
(
Await
.
result
(
summary
.
getStat
(
0
,
0
),
Duration
.
Inf
))
db
.
close
()
logger
.
info
(
"Done"
)
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/SummaryDb.scala
View file @
c549917d
...
...
@@ -37,7 +37,7 @@ class SummaryDb(db: Database) {
List
(
runId
.
map
(
run
.
id
===
_
),
runName
.
map
(
run
.
runName
===
_
),
outputDir
.
map
(
run
.
outputDir
===
_
)
// not a condition as `criteriaRoast` evaluates to `None`
outputDir
.
map
(
run
.
outputDir
===
_
)
).
collect
({
case
Some
(
criteria
)
=>
criteria
}).
reduceLeftOption
(
_
&&
_
).
getOrElse
(
true
:
Rep
[
Boolean
])
}
db
.
run
(
q
.
result
)
...
...
@@ -53,7 +53,7 @@ class SummaryDb(db: Database) {
List
(
sampleId
.
map
(
sample
.
id
===
_
),
runId
.
map
(
sample
.
runId
===
_
),
name
.
map
(
sample
.
name
===
_
)
// not a condition as `criteriaRoast` evaluates to `None`
name
.
map
(
sample
.
name
===
_
)
).
collect
({
case
Some
(
criteria
)
=>
criteria
}).
reduceLeftOption
(
_
&&
_
).
getOrElse
(
true
:
Rep
[
Boolean
])
}
db
.
run
(
q
.
map
(
x
=>
(
x
.
id
,
x
.
runId
,
x
.
name
)).
result
)
...
...
@@ -96,7 +96,7 @@ class SummaryDb(db: Database) {
List
(
pipelineId
.
map
(
lib
.
id
===
_
),
runId
.
map
(
lib
.
runId
===
_
),
name
.
map
(
lib
.
name
===
_
)
// not a condition as `criteriaRoast` evaluates to `None`
name
.
map
(
lib
.
name
===
_
)
).
collect
({
case
Some
(
criteria
)
=>
criteria
}).
reduceLeftOption
(
_
&&
_
).
getOrElse
(
true
:
Rep
[
Boolean
])
}
db
.
run
(
q
.
map
(
x
=>
(
x
.
id
,
x
.
name
,
x
.
runId
)).
result
)
...
...
@@ -113,10 +113,72 @@ class SummaryDb(db: Database) {
moduleId
.
map
(
lib
.
id
===
_
),
runId
.
map
(
lib
.
runId
===
_
),
pipelineId
.
map
(
lib
.
pipelineId
===
_
),
name
.
map
(
lib
.
name
===
_
)
// not a condition as `criteriaRoast` evaluates to `None`
name
.
map
(
lib
.
name
===
_
)
).
collect
({
case
Some
(
criteria
)
=>
criteria
}).
reduceLeftOption
(
_
&&
_
).
getOrElse
(
true
:
Rep
[
Boolean
])
}
db
.
run
(
q
.
map
(
x
=>
(
x
.
id
,
x
.
name
,
x
.
runId
)).
result
)
}
def
createStat
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
,
content
:
String
)
=
{
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
)
=
{
val
q
=
List
(
runId
.
map
(
x
=>
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
runId
===
x
)),
pipelineId
.
map
(
x
=>
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
pipelineId
===
x
)),
moduleId
.
map
(
x
=>
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
moduleId
===
x
)
else
y
.
filter
(
_
.
moduleId
.
isEmpty
))),
sampleId
.
map
(
x
=>
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
sampleId
===
x
)
else
y
.
filter
(
_
.
sampleId
.
isEmpty
))),
libId
.
map
(
x
=>
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
x
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
)))
).
flatten
.
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
db
.
run
(
q
.
result
)
}
def
getStat
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Future
[
Option
[
Map
[
String
,
Any
]]]
=
{
val
q
=
List
(
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
runId
===
runId
),
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
pipelineId
===
pipelineId
),
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
(
if
(
moduleId
.
isDefined
)
y
.
filter
(
_
.
moduleId
===
moduleId
)
else
y
.
filter
(
_
.
moduleId
.
isEmpty
)),
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
(
if
(
sampleId
.
isDefined
)
y
.
filter
(
_
.
sampleId
===
sampleId
)
else
y
.
filter
(
_
.
sampleId
.
isEmpty
)),
(
y
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
])
=>
(
if
(
libId
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
libId
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
))
).
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
db
.
run
(
q
.
map
(
_
.
content
).
result
).
map
(
_
.
headOption
.
map
(
ConfigUtils
.
jsonTextToMap
))
}
def
createSetting
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
,
content
:
String
)
=
{
db
.
run
(
settings
.
forceInsert
(
Setting
(
runId
,
pipelineId
,
moduleId
,
sampleId
,
libId
,
content
)))
}
def
getSettings
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
)
=
{
val
q
=
List
(
runId
.
map
(
x
=>
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
runId
===
x
)),
pipelineId
.
map
(
x
=>
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
pipelineId
===
x
)),
moduleId
.
map
(
x
=>
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
moduleId
===
x
)
else
y
.
filter
(
_
.
moduleId
.
isEmpty
))),
sampleId
.
map
(
x
=>
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
sampleId
===
x
)
else
y
.
filter
(
_
.
sampleId
.
isEmpty
))),
libId
.
map
(
x
=>
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
(
if
(
x
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
x
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
)))
).
flatten
.
foldLeft
(
settings
.
subquery
)((
a
,
b
)
=>
b
(
a
))
db
.
run
(
q
.
result
)
}
def
getSetting
(
runId
:
Int
,
pipelineId
:
Int
,
moduleId
:
Option
[
Int
]
=
None
,
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Future
[
Option
[
Map
[
String
,
Any
]]]
=
{
val
q
=
List
(
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
runId
===
runId
),
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
y
.
filter
(
_
.
pipelineId
===
pipelineId
),
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
(
if
(
moduleId
.
isDefined
)
y
.
filter
(
_
.
moduleId
===
moduleId
)
else
y
.
filter
(
_
.
moduleId
.
isEmpty
)),
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
(
if
(
sampleId
.
isDefined
)
y
.
filter
(
_
.
sampleId
===
sampleId
)
else
y
.
filter
(
_
.
sampleId
.
isEmpty
)),
(
y
:
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
])
=>
(
if
(
libId
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
libId
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
))
).
foldLeft
(
settings
.
subquery
)((
a
,
b
)
=>
b
(
a
))
db
.
run
(
q
.
map
(
_
.
content
).
result
).
map
(
_
.
headOption
.
map
(
ConfigUtils
.
jsonTextToMap
))
}
}
Write
Preview
Supports
Markdown
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