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
e09f609a
Commit
e09f609a
authored
Feb 19, 2015
by
Peter van 't Hof
Browse files
Added scala docs
parent
d28ac4f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summarizable.scala
View file @
e09f609a
...
@@ -5,12 +5,22 @@ import java.io.File
...
@@ -5,12 +5,22 @@ import java.io.File
import
nl.lumc.sasc.biopet.core.config.Configurable
import
nl.lumc.sasc.biopet.core.config.Configurable
/**
/**
* Trait for class to let them accept into a Summary
*
* Created by pjvan_thof on 2/14/15.
* Created by pjvan_thof on 2/14/15.
*/
*/
trait
Summarizable
extends
Configurable
{
trait
Summarizable
extends
Configurable
{
/**
* Must return files to store into summary
* @return
*/
def
summaryFiles
:
Map
[
String
,
File
]
def
summaryFiles
:
Map
[
String
,
File
]
/**
* Must returns stats to store into summary
* @return
*/
def
summaryStats
:
Map
[
String
,
Any
]
def
summaryStats
:
Map
[
String
,
Any
]
/**
/**
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala
View file @
e09f609a
...
@@ -14,16 +14,30 @@ trait SummaryQScript extends BiopetQScript {
...
@@ -14,16 +14,30 @@ trait SummaryQScript extends BiopetQScript {
/** Key is sample/library, None is sample or library is not applicable */
/** Key is sample/library, None is sample or library is not applicable */
private
[
summary
]
var
summarizables
:
Map
[(
String
,
Option
[
String
]
,
Option
[
String
])
,
List
[
Summarizable
]]
=
Map
()
private
[
summary
]
var
summarizables
:
Map
[(
String
,
Option
[
String
]
,
Option
[
String
])
,
List
[
Summarizable
]]
=
Map
()
/** Qscripts summaries that need to be merge into this summary */
private
[
summary
]
var
summaryQScripts
:
List
[
SummaryQScript
]
=
Nil
private
[
summary
]
var
summaryQScripts
:
List
[
SummaryQScript
]
=
Nil
/** Name of the pipeline in the summary */
var
summaryName
=
configName
var
summaryName
=
configName
/** Must return a map with used settings for this pipeline */
def
summarySettings
:
Map
[
String
,
Any
]
def
summarySettings
:
Map
[
String
,
Any
]
/** File to put in the summary for thie pipeline */
def
summaryFiles
:
Map
[
String
,
File
]
def
summaryFiles
:
Map
[
String
,
File
]
/** Name of summary output file */
def
summaryFile
:
File
def
summaryFile
:
File
/**
* Add a module to summary for this pipeline
*
* Auto detect sample and library from pipeline
*
* @param summarizable summarizable to add to summary for this pipeline
* @param name Name of module
*/
def
addSummarizable
(
summarizable
:
Summarizable
,
name
:
String
)
:
Unit
=
{
def
addSummarizable
(
summarizable
:
Summarizable
,
name
:
String
)
:
Unit
=
{
this
match
{
this
match
{
case
tag
:
SampleLibraryTag
=>
addSummarizable
(
summarizable
,
name
,
tag
.
sampleId
,
tag
.
libId
)
case
tag
:
SampleLibraryTag
=>
addSummarizable
(
summarizable
,
name
,
tag
.
sampleId
,
tag
.
libId
)
...
@@ -31,19 +45,39 @@ trait SummaryQScript extends BiopetQScript {
...
@@ -31,19 +45,39 @@ trait SummaryQScript extends BiopetQScript {
}
}
}
}
/**
* Add a module to summary for this pipeline
*
* @param summarizable summarizable to add to summary for this pipeline
* @param name Name of module
* @param sampleId
*/
def
addSummarizable
(
summarizable
:
Summarizable
,
name
:
String
,
sampleId
:
Option
[
String
])
:
Unit
=
{
def
addSummarizable
(
summarizable
:
Summarizable
,
name
:
String
,
sampleId
:
Option
[
String
])
:
Unit
=
{
addSummarizable
(
summarizable
,
name
,
sampleId
,
None
)
addSummarizable
(
summarizable
,
name
,
sampleId
,
None
)
}
}
/**
* Add a module to summary for this pipeline
*
* @param summarizable summarizable to add to summary for this pipeline
* @param name Name of module
* @param sampleId
* @param libraryId
*/
def
addSummarizable
(
summarizable
:
Summarizable
,
name
:
String
,
sampleId
:
Option
[
String
],
libraryId
:
Option
[
String
])
:
Unit
=
{
def
addSummarizable
(
summarizable
:
Summarizable
,
name
:
String
,
sampleId
:
Option
[
String
],
libraryId
:
Option
[
String
])
:
Unit
=
{
if
(
libraryId
.
isDefined
)
require
(
sampleId
.
isDefined
)
// Library always require a sample
if
(
libraryId
.
isDefined
)
require
(
sampleId
.
isDefined
)
// Library always require a sample
summarizables
+=
(
name
,
sampleId
,
libraryId
)
->
(
summarizable
::
summarizables
.
getOrElse
((
name
,
sampleId
,
libraryId
),
Nil
))
summarizables
+=
(
name
,
sampleId
,
libraryId
)
->
(
summarizable
::
summarizables
.
getOrElse
((
name
,
sampleId
,
libraryId
),
Nil
))
}
}
/**
* Add an other qscript to merge in output summary
* @param summaryQScript
*/
def
addSummaryQScript
(
summaryQScript
:
SummaryQScript
)
:
Unit
=
{
def
addSummaryQScript
(
summaryQScript
:
SummaryQScript
)
:
Unit
=
{
summaryQScripts
:+=
summaryQScript
summaryQScripts
:+=
summaryQScript
}
}
/** Add jobs to qscript to execute summary, also add checksum jobs */
def
addSummaryJobs
:
Unit
=
{
def
addSummaryJobs
:
Unit
=
{
val
writeSummary
=
new
WriteSummary
(
this
)
val
writeSummary
=
new
WriteSummary
(
this
)
...
@@ -73,11 +107,11 @@ trait SummaryQScript extends BiopetQScript {
...
@@ -73,11 +107,11 @@ trait SummaryQScript extends BiopetQScript {
add
(
writeSummary
)
add
(
writeSummary
)
}
}
protected
[
summary
]
val
executables
:
mutable.Map
[
String
,
(
File
,
String
)]
=
mutable
.
Map
()
}
}
object
SummaryQScript
{
object
SummaryQScript
{
import
scala.collection.mutable.Map
import
scala.collection.mutable.Map
/** Cache to have no duplicate jobs */
protected
[
summary
]
val
md5sumCache
:
Map
[
File
,
File
]
=
Map
()
protected
[
summary
]
val
md5sumCache
:
Map
[
File
,
File
]
=
Map
()
}
}
\ No newline at end of file
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
View file @
e09f609a
...
@@ -20,6 +20,7 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
...
@@ -20,6 +20,7 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
require
(
root
.
isInstanceOf
[
SummaryQScript
],
"root is not a SummaryQScript"
)
require
(
root
.
isInstanceOf
[
SummaryQScript
],
"root is not a SummaryQScript"
)
/** To access qscript for this summary */
val
qscript
=
root
.
asInstanceOf
[
SummaryQScript
]
val
qscript
=
root
.
asInstanceOf
[
SummaryQScript
]
@Input
(
doc
=
"deps"
,
required
=
false
)
@Input
(
doc
=
"deps"
,
required
=
false
)
...
@@ -43,8 +44,8 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
...
@@ -43,8 +44,8 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
super
.
freezeFieldValues
()
super
.
freezeFieldValues
()
}
}
/** Function to create summary */
def
run
()
:
Unit
=
{
def
run
()
:
Unit
=
{
val
pipelineMap
=
{
val
pipelineMap
=
{
val
files
=
parseFiles
(
qscript
.
summaryFiles
)
val
files
=
parseFiles
(
qscript
.
summaryFiles
)
val
settings
=
qscript
.
summarySettings
val
settings
=
qscript
.
summarySettings
...
@@ -100,6 +101,12 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
...
@@ -100,6 +101,12 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
}
}
}
}
/**
* Convert summarizable to a summary map
* @param summarizable
* @param name
* @return
*/
def
parseSummarizable
(
summarizable
:
Summarizable
,
name
:
String
)
=
{
def
parseSummarizable
(
summarizable
:
Summarizable
,
name
:
String
)
=
{
val
data
=
summarizable
.
summaryStats
val
data
=
summarizable
.
summaryStats
val
files
=
parseFiles
(
summarizable
.
summaryFiles
)
val
files
=
parseFiles
(
summarizable
.
summaryFiles
)
...
@@ -108,10 +115,20 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
...
@@ -108,10 +115,20 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
(
if
(
files
.
isEmpty
)
Map
[
String
,
Any
]()
else
Map
(
"files"
->
Map
(
name
->
files
)))
(
if
(
files
.
isEmpty
)
Map
[
String
,
Any
]()
else
Map
(
"files"
->
Map
(
name
->
files
)))
}
}
/**
* Parse files map to summary map
* @param files
* @return
*/
def
parseFiles
(
files
:
Map
[
String
,
File
])
:
Map
[
String
,
Map
[
String
,
Any
]]
=
{
def
parseFiles
(
files
:
Map
[
String
,
File
])
:
Map
[
String
,
Map
[
String
,
Any
]]
=
{
for
((
key
,
file
)
<-
files
)
yield
key
->
parseFile
(
file
)
for
((
key
,
file
)
<-
files
)
yield
key
->
parseFile
(
file
)
}
}
/**
* parse single file summary map
* @param file
* @return
*/
def
parseFile
(
file
:
File
)
:
Map
[
String
,
Any
]
=
{
def
parseFile
(
file
:
File
)
:
Map
[
String
,
Any
]
=
{
val
map
:
mutable.Map
[
String
,
Any
]
=
mutable
.
Map
()
val
map
:
mutable.Map
[
String
,
Any
]
=
mutable
.
Map
()
map
+=
"path"
->
file
.
getAbsolutePath
map
+=
"path"
->
file
.
getAbsolutePath
...
@@ -119,6 +136,11 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
...
@@ -119,6 +136,11 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
map
.
toMap
map
.
toMap
}
}
/**
* Retrive checksum from file
* @param checksumFile
* @return
*/
def
parseChecksum
(
checksumFile
:
File
)
:
String
=
{
def
parseChecksum
(
checksumFile
:
File
)
:
String
=
{
Source
.
fromFile
(
checksumFile
).
getLines
().
toList
.
head
.
split
(
" "
)(
0
)
Source
.
fromFile
(
checksumFile
).
getLines
().
toList
.
head
.
split
(
" "
)(
0
)
}
}
...
...
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