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
38194b88
Commit
38194b88
authored
Feb 16, 2015
by
Peter van 't Hof
Browse files
First version of write function
parent
982c0460
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
View file @
38194b88
package
nl.lumc.sasc.biopet.core.summary
import
java.io.
{
PrintWriter
,
File
}
import
java.io.
{
FileInputStream
,
PrintWriter
,
File
}
import
java.security.MessageDigest
import
nl.lumc.sasc.biopet.core.config.Configurable
import
nl.lumc.sasc.biopet.utils.ConfigUtils
import
org.broadinstitute.gatk.queue.function.
{
QFunction
,
InProcessFunction
}
import
org.broadinstitute.gatk.utils.commandline.
{
Output
,
Input
}
import
scala.collection.mutable
import
scala.io.Source
/**
* Created by pjvan_thof on 2/14/15.
*/
...
...
@@ -37,6 +42,39 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
def
run
()
:
Unit
=
{
val
writer
=
new
PrintWriter
(
out
)
val
bla
=
for
(((
name
,
sampleId
,
libraryId
),
summarizables
)
<-
summaryQScript
.
summarizables
;
summarizable
<-
summarizables
)
yield
{
val
map
=
Map
(
name
->
parseSummarizable
(
summarizable
))
(
sampleId
match
{
case
Some
(
sampleId
)
=>
Map
(
"samples"
->
Map
(
sampleId
->
(
libraryId
match
{
case
Some
(
libraryId
)
=>
Map
(
"libraries"
->
Map
(
libraryId
->
map
))
case
_
=>
map
})))
case
_
=>
map
},
(
v1
:
Any
,
v2
:
Any
,
key
:
String
)
=>
summarizable
.
resolveSummaryConflict
(
v1
,
v2
,
key
))
}
bla
.
foldRight
(
Map
[
String
,
Any
]())((
a
,
b
)
=>
ConfigUtils
.
mergeMaps
(
a
.
_1
,
b
,
a
.
_2
))
//TODO: QScript merging
writer
.
close
()
}
def
parseSummarizable
(
summarizable
:
Summarizable
)
:
Map
[
String
,
Map
[
String
,
Any
]]
=
{
Map
(
"data"
->
summarizable
.
summaryData
,
"files"
->
parseFiles
(
summarizable
.
summaryFiles
))
}
def
parseFiles
(
files
:
Map
[
String
,
File
])
:
Map
[
String
,
Map
[
String
,
Any
]]
=
{
for
((
key
,
file
)
<-
files
)
yield
{
val
map
:
mutable.Map
[
String
,
Any
]
=
mutable
.
Map
()
map
+=
"path"
->
file
.
getAbsolutePath
if
(
md5sum
)
map
+=
"md5"
->
parseChechsum
(
SummaryQScript
.
md5sumCache
(
file
))
key
->
map
.
toMap
}
}
def
parseChechsum
(
checksumFile
:
File
)
:
String
=
{
Source
.
fromFile
(
checksumFile
).
getLines
().
toList
.
head
.
split
(
" "
)(
0
)
}
}
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