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
4f941fd2
Commit
4f941fd2
authored
Feb 21, 2017
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more testing and fixed a bug in join queries
parent
9817ac95
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
...cala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
+3
-3
biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDbTest.scala
.../nl/lumc/sasc/biopet/utils/summary/db/SummaryDbTest.scala
+16
-4
No files found.
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
View file @
4f941fd2
...
...
@@ -206,7 +206,7 @@ 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
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
lib
rary
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
mustHaveSample
:
Boolean
=
false
,
mustHaveLibrary
:
Boolean
=
false
)
=
{
var
f
:
Query
[
Stats
,
Stats
#
TableElementType
,
Seq
]
=
stats
runId
.
foreach
(
r
=>
f
=
f
.
filter
(
_
.
runId
===
r
))
...
...
@@ -227,7 +227,7 @@ class SummaryDb(val db: Database) extends Closeable {
case
Some
(
None
)
=>
f
.
filter
(
_
.
sampleId
.
isEmpty
)
case
_
=>
f
}
f
=
module
match
{
f
=
library
match
{
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
)
...
...
@@ -317,7 +317,7 @@ class SummaryDb(val db: Database) extends Closeable {
case
Some
(
None
)
=>
f
.
filter
(
_
.
sampleId
.
isEmpty
)
case
_
=>
f
}
f
=
module
match
{
f
=
library
match
{
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
)
...
...
biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDbTest.scala
View file @
4f941fd2
package
nl.lumc.sasc.biopet.utils.summary.db
import
java.io.File
import
java.sql.Date
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
...
...
@@ -36,10 +37,21 @@ class SummaryDbTest extends TestNGSuite with Matchers {
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
Await
.
result
(
db
.
createOrUpdateStat
(
0
,
0
,
None
,
None
,
None
,
"""{"content": "test" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
0
,
Left
(
0
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test"
))
Await
.
result
(
db
.
createOrUpdateStat
(
0
,
0
,
None
,
None
,
None
,
"""{"content": "test2" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
0
,
Left
(
0
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test2"
))
val
runId
=
Await
.
result
(
db
.
createRun
(
"test"
,
""
,
""
,
""
,
new
Date
(
System
.
currentTimeMillis
())),
Duration
.
Inf
)
val
pipelineId
=
Await
.
result
(
db
.
createPipeline
(
"test_pipeline"
,
runId
),
Duration
.
Inf
)
val
moduleId
=
Await
.
result
(
db
.
createModule
(
"test_module"
,
runId
,
pipelineId
),
Duration
.
Inf
)
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
runId
),
Duration
.
Inf
)
val
libraryId
=
Await
.
result
(
db
.
createLibrary
(
"test_library"
,
runId
,
sampleId
),
Duration
.
Inf
)
Await
.
result
(
db
.
createOrUpdateStat
(
runId
,
pipelineId
,
None
,
None
,
None
,
"""{"content": "test" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
runId
,
Left
(
pipelineId
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test"
))
Await
.
result
(
db
.
createOrUpdateStat
(
runId
,
pipelineId
,
None
,
None
,
None
,
"""{"content": "test2" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
runId
,
Left
(
pipelineId
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test2"
))
// Test join queries
Await
.
result
(
db
.
createOrUpdateStat
(
runId
,
pipelineId
,
Some
(
moduleId
),
Some
(
sampleId
),
Some
(
libraryId
),
"""{"content": "test3" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
runId
,
Right
(
"test_pipeline"
),
Some
(
Right
(
"test_module"
)),
Some
(
Right
(
"test_sample"
)),
Some
(
Right
(
"test_library"
))),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test3"
))
db
.
close
()
}
...
...
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