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
b2475ba7
Commit
b2475ba7
authored
Feb 10, 2017
by
Peter van 't Hof
Browse files
Fix format
parent
4228881c
Changes
7
Hide whitespace changes
Inline
Side-by-side
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala
View file @
b2475ba7
...
...
@@ -17,9 +17,9 @@ package nl.lumc.sasc.biopet.core
import
java.io.File
import
nl.lumc.sasc.biopet.core.MultiSampleQScript.Gender
import
nl.lumc.sasc.biopet.core.summary.
{
Summarizable
,
SummaryQScript
}
import
nl.lumc.sasc.biopet.core.summary.
{
Summarizable
,
SummaryQScript
}
import
nl.lumc.sasc.biopet.utils.summary.SummaryDb
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
import
org.broadinstitute.gatk.queue.QScript
import
scala.concurrent.Await
...
...
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/WriteDependencies.scala
View file @
b2475ba7
...
...
@@ -112,9 +112,9 @@ object WriteDependencies extends Logging with Configurable {
case
cmd
:
CommandLineFunction
=>
cmd
.
commandLine
case
_
=>
None
}),
"main_job"
->
(
f
match
{
case
cmd
:
BiopetCommandLineFunction
=>
cmd
.
mainFunction
case
cmd
:
BiopetCommandLineFunction
=>
cmd
.
mainFunction
case
s
:
WriteSummary
if
s.qscript.parent
=
=
null
=>
true
case
_
=>
false
case
_
=>
false
}),
"intermediate"
->
f
.
isIntermediate
,
"depends_on_intermediate"
->
BiopetQScript
.
safeInputs
(
f
).
getOrElse
(
Seq
()).
exists
(
files
(
_
).
isIntermediate
),
"depends_on_jobs"
->
BiopetQScript
.
safeInputs
(
f
).
getOrElse
(
Seq
()).
toList
.
flatMap
(
files
(
_
).
outputJobNames
).
distinct
,
...
...
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala
View file @
b2475ba7
...
...
@@ -14,10 +14,10 @@
*/
package
nl.lumc.sasc.biopet.core.summary
import
java.io.
{
File
,
PrintWriter
}
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.core._
import
nl.lumc.sasc.biopet.core.extensions.
{
CheckChecksum
,
Md5sum
}
import
nl.lumc.sasc.biopet.core.extensions.
{
CheckChecksum
,
Md5sum
}
import
nl.lumc.sasc.biopet.utils.summary.SummaryDb
import
org.broadinstitute.gatk.queue.QScript
...
...
@@ -52,8 +52,8 @@ trait SummaryQScript extends BiopetQScript { qscript: QScript =>
def
summaryFile
:
File
def
summaryDbFile
:
File
=
root
match
{
case
s
:
SummaryQScript
=>
new
File
(
s
.
outputDir
,
s
"${s.summaryName}.summary.db"
)
case
_
=>
throw
new
IllegalStateException
(
"Root should be a SummaryQScript"
)
case
s
:
SummaryQScript
=>
new
File
(
s
.
outputDir
,
s
"${s.summaryName}.summary.db"
)
case
_
=>
throw
new
IllegalStateException
(
"Root should be a SummaryQScript"
)
}
/**
...
...
@@ -113,10 +113,9 @@ trait SummaryQScript extends BiopetQScript { qscript: QScript =>
private
def
runIdFile
=
root
match
{
case
s
:
SummaryQScript
=>
new
File
(
s
.
outputDir
,
s
".log/summary.runid"
)
case
_
=>
throw
new
IllegalStateException
(
"Root should be a SummaryQscript"
)
case
_
=>
throw
new
IllegalStateException
(
"Root should be a SummaryQscript"
)
}
private
def
createRun
()
:
Int
=
{
val
db
=
SummaryDb
.
openSqliteSummary
(
summaryDbFile
)
val
id
=
Await
.
result
(
db
.
createRun
(
summaryName
,
outputDir
),
Duration
.
Inf
)
...
...
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
View file @
b2475ba7
...
...
@@ -14,15 +14,15 @@
*/
package
nl.lumc.sasc.biopet.core.summary
import
java.io.
{
File
,
PrintWriter
}
import
java.io.
{
File
,
PrintWriter
}
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core._
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
nl.lumc.sasc.biopet.LastCommitHash
import
nl.lumc.sasc.biopet.utils.summary.SummaryDb
import
org.broadinstitute.gatk.queue.function.
{
InProcessFunction
,
QFunction
}
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
}
import
org.broadinstitute.gatk.queue.function.
{
InProcessFunction
,
QFunction
}
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
}
import
scala.collection.mutable
import
scala.io.Source
...
...
@@ -59,7 +59,7 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
if
(
qscript
==
root
)
{
// This initialize the database
qscript
match
{
case
s
:
MultiSampleQScript
=>
s
.
initSummaryDb
case
_
=>
qscript
.
summaryRunId
case
_
=>
qscript
.
summaryRunId
}
}
val
db
=
SummaryDb
.
openSqliteSummary
(
qscript
.
summaryDbFile
)
...
...
@@ -89,12 +89,12 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
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
)
{
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
)
=>
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
))
...
...
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SummaryToSqlite.scala
View file @
b2475ba7
...
...
@@ -10,8 +10,8 @@ import scala.concurrent.Await
import
scala.concurrent.duration.Duration
/**
* Created by pjvanthof on 26/01/2017.
*/
* Created by pjvanthof on 26/01/2017.
*/
object
SummaryToSqlite
extends
ToolCommand
{
case
class
Args
(
inputJson
:
File
=
null
,
...
...
@@ -70,7 +70,7 @@ object SummaryToSqlite extends ToolCommand {
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
))
println
(
Await
.
result
(
summary
.
getStat
(
0
,
0
),
Duration
.
Inf
))
db
.
close
()
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/SummaryDb.scala
View file @
b2475ba7
package
nl.lumc.sasc.biopet.utils.summary
import
java.io.
{
Closeable
,
File
}
import
java.io.
{
Closeable
,
File
}
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
slick.driver.H2Driver.api._
import
scala.concurrent.
{
Await
,
Future
}
import
scala.concurrent.
{
Await
,
Future
}
import
scala.concurrent.duration.Duration
import
nl.lumc.sasc.biopet.utils.summary.db.Schema._
import
scala.concurrent.ExecutionContext.Implicits.global
/**
* Created by pjvanthof on 05/02/2017.
*/
* Created by pjvanthof on 05/02/2017.
*/
class
SummaryDb
(
db
:
Database
)
extends
Closeable
{
def
close
()
:
Unit
=
db
.
close
()
...
...
@@ -98,9 +98,10 @@ class SummaryDb(db: Database) extends Closeable {
def
createPipeline
(
name
:
String
,
runId
:
Int
)
:
Future
[
Int
]
=
{
getPipelines
(
name
=
Some
(
name
),
runId
=
Some
(
runId
))
.
flatMap
{
case
m
=>
if
(
m
.
isEmpty
)
forceCreatePipeline
(
name
,
runId
)
else
Future
(
m
.
head
.
id
)
.
flatMap
{
case
m
=>
if
(
m
.
isEmpty
)
forceCreatePipeline
(
name
,
runId
)
else
Future
(
m
.
head
.
id
)
}
}
...
...
@@ -122,9 +123,10 @@ class SummaryDb(db: Database) extends Closeable {
def
createModule
(
name
:
String
,
runId
:
Int
,
pipelineId
:
Int
)
:
Future
[
Int
]
=
{
getModules
(
name
=
Some
(
name
),
runId
=
Some
(
runId
),
pipelineId
=
Some
(
pipelineId
))
.
flatMap
{
case
m
=>
if
(
m
.
isEmpty
)
forceCreateModule
(
name
,
runId
,
pipelineId
)
else
Future
(
m
.
head
.
id
)
.
flatMap
{
case
m
=>
if
(
m
.
isEmpty
)
forceCreateModule
(
name
,
runId
,
pipelineId
)
else
Future
(
m
.
head
.
id
)
}
}
...
...
@@ -154,7 +156,7 @@ class SummaryDb(db: Database) extends Closeable {
}
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
)
=
{
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
)),
...
...
@@ -162,7 +164,7 @@ 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
)))
)
l
.
flatten
.
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
l
.
flatten
.
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
}
def
getStats
(
runId
:
Option
[
Int
]
=
None
,
pipelineId
:
Option
[
Int
]
=
None
,
moduleId
:
Option
[
Option
[
Int
]]
=
None
,
...
...
@@ -179,18 +181,18 @@ class SummaryDb(db: Database) extends Closeable {
y
=>
(
if
(
sampleId
.
isDefined
)
y
.
filter
(
_
.
sampleId
===
sampleId
)
else
y
.
filter
(
_
.
sampleId
.
isEmpty
)),
y
=>
(
if
(
libId
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
libId
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
))
)
val
q
=
l
.
foldLeft
(
stats
.
subquery
)((
a
,
b
)
=>
b
(
a
))
val
q
=
l
.
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
)
=
{
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
)
=
{
sampleId
:
Option
[
Option
[
Int
]]
=
None
,
libId
:
Option
[
Option
[
Int
]]
=
None
)
=
{
val
l
:
List
[
Option
[
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
]
=>
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
]]]
=
List
(
runId
.
map
(
x
=>
y
=>
y
.
filter
(
_
.
runId
===
x
)),
pipelineId
.
map
(
x
=>
y
=>
y
.
filter
(
_
.
pipelineId
===
x
)),
...
...
@@ -198,13 +200,13 @@ 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
(
settings
.
subquery
)((
a
,
b
)
=>
b
(
a
))
val
q
=
l
.
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
]]]
=
{
sampleId
:
Option
[
Int
]
=
None
,
libId
:
Option
[
Int
]
=
None
)
:
Future
[
Option
[
Map
[
String
,
Any
]]]
=
{
val
l
:
List
[
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
]
=>
Query
[
Settings
,
Settings
#
TableElementType
,
Seq
]]
=
List
(
_
.
filter
(
_
.
runId
===
runId
),
_
.
filter
(
_
.
pipelineId
===
pipelineId
),
...
...
@@ -213,7 +215,7 @@ class SummaryDb(db: Database) extends Closeable {
y
=>
(
if
(
libId
.
isDefined
)
y
.
filter
(
_
.
libraryId
===
libId
)
else
y
.
filter
(
_
.
libraryId
.
isEmpty
))
)
val
q
=
l
.
foldLeft
(
settings
.
subquery
)((
a
,
b
)
=>
b
(
a
))
val
q
=
l
.
foldLeft
(
settings
.
subquery
)((
a
,
b
)
=>
b
(
a
))
db
.
run
(
q
.
map
(
_
.
content
).
result
).
map
(
_
.
headOption
.
map
(
ConfigUtils
.
jsonTextToMap
))
}
}
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/Schema.scala
View file @
b2475ba7
...
...
@@ -3,8 +3,8 @@ package nl.lumc.sasc.biopet.utils.summary.db
import
slick.driver.H2Driver.api._
/**
* Created by pjvan_thof on 27-1-17.
*/
* Created by pjvan_thof on 27-1-17.
*/
object
Schema
{
case
class
Run
(
id
:
Int
,
name
:
String
,
outputDir
:
String
)
...
...
@@ -118,7 +118,7 @@ object Schema {
}
val
files
=
TableQuery
[
Files
]
case
class
Executable
(
runId
:
Int
,
toolName
:
String
,
version
:
Option
[
String
],
javaVersion
:
Option
[
String
],
exeMd5
:
Option
[
String
],
javaMd5
:
Option
[
String
])
case
class
Executable
(
runId
:
Int
,
toolName
:
String
,
version
:
Option
[
String
],
javaVersion
:
Option
[
String
],
exeMd5
:
Option
[
String
],
javaMd5
:
Option
[
String
])
class
Executables
(
tag
:
Tag
)
extends
Table
[
Executable
](
tag
,
"Executables"
)
{
def
runId
=
column
[
Int
](
"runId"
)
def
toolName
=
column
[
String
](
"toolName"
)
...
...
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