Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
biopet.biopet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Mirrors
biopet.biopet
Commits
a592e31b
Commit
a592e31b
authored
Nov 22, 2016
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added common functions
parent
b576d9da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BammetricsReport.scala
...c/sasc/biopet/pipelines/bammetrics/BammetricsReport.scala
+35
-3
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/Summary.scala
...ain/scala/nl/lumc/sasc/biopet/utils/summary/Summary.scala
+5
-0
No files found.
bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BammetricsReport.scala
View file @
a592e31b
...
...
@@ -237,7 +237,7 @@ object BammetricsReport extends ReportBuilder {
tsvWriter
.
close
()
LinePlot
(
tsvFile
,
new
File
(
outputDir
,
"insertsize.png"
)
,
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Insert size"
),
ylabel
=
Some
(
"Reads"
),
title
=
Some
(
"Insert size"
),
...
...
@@ -324,7 +324,7 @@ object BammetricsReport extends ReportBuilder {
tsvWriter
.
close
()
LinePlot
(
tsvFile
,
new
File
(
outputDir
,
"wgs.png"
)
,
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Coverage"
),
ylabel
=
Some
(
"Bases"
),
title
=
Some
(
"Whole genome coverage"
),
...
...
@@ -411,10 +411,42 @@ object BammetricsReport extends ReportBuilder {
tsvWriter
.
close
()
LinePlot
(
tsvFile
,
new
File
(
outputDir
,
"rna.png"
)
,
LinePlot
(
tsvFile
,
pngFile
,
xlabel
=
Some
(
"Relative position"
),
ylabel
=
Some
(
"Coverage"
),
title
=
Some
(
"Rna coverage"
),
removeZero
=
true
).
runLocal
()
}
def
getTableFromSummary
(
summary
:
Summary
,
paths
:
Map
[
String
,
List
[
String
]],
sampleId
:
Option
[
String
]
=
None
,
libId
:
Option
[
String
]
=
None
)
:
Map
[
String
,
Array
[
Any
]]
=
{
val
pathValues
:
Map
[
String
,
Array
[
Any
]]
=
paths
.
map
{
case
(
key
,
path
)
=>
val
value
=
summary
.
getValueAsArray
(
sampleId
,
libId
,
path
:_
*
)
require
(
value
.
isDefined
,
s
"Sample: $sampleId, library: $libId on path: '${path.mkString("
,
")}' does not exist in summary"
)
key
->
value
.
get
}
require
(
pathValues
.
map
(
_
.
_2
.
size
).
toList
.
distinct
==
1
,
s
"Arrays in summary does not have the same number of values, $paths"
)
pathValues
}
def
mergeTables
(
tables
:
List
[
Map
[
String
,
Array
[
Any
]]],
mergeColumn
:
String
,
defaultValue
:
Any
=
0
)
:
Map
[
String
,
List
[
Any
]]
=
{
val
keys
=
tables
.
flatMap
(
x
=>
x
(
mergeColumn
)).
distinct
(
for
(
table
<-
tables
;
(
columnKey
,
columnValues
)
<-
table
if
columnKey
!=
mergeColumn
)
yield
{
columnKey
->
keys
.
map
(
x
=>
table
(
mergeColumn
).
zip
(
columnValues
).
toMap
.
getOrElse
(
x
,
defaultValue
))
}).
toMap
+
(
mergeColumn
->
keys
)
}
def
writeTableToTsv
(
tsvFile
:
File
,
table
:
Map
[
String
,
Array
[
Any
]],
firstColumn
:
String
)
:
Unit
=
{
require
(
table
.
map
(
_
.
_2
.
size
).
toList
.
distinct
==
1
,
"Not all values has the same number or rows"
)
val
keys
=
table
.
keys
.
filterNot
(
_
==
firstColumn
).
toList
.
sorted
val
writer
=
new
PrintWriter
(
tsvFile
)
writer
.
println
((
firstColumn
::
keys
).
mkString
(
"\t"
))
table
(
firstColumn
).
zipWithIndex
.
foreach
{
case
(
c
,
i
)
=>
writer
.
println
((
c
::
keys
.
map
(
x
=>
table
(
x
)(
i
))).
mkString
(
"\t"
))
}
writer
.
close
()
}
}
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/Summary.scala
View file @
a592e31b
...
...
@@ -78,6 +78,11 @@ class Summary(file: File) {
}
}
/** Get value on nested path with prefix depending is sampleId and/or libId is None or not */
def
getValueAsArray
(
sampleId
:
Option
[
String
],
libId
:
Option
[
String
],
path
:
String*
)
:
Option
[
Array
[
Any
]]
=
{
this
.
getValue
(
sampleId
,
libId
,
path
:_
*
).
map
(
ConfigUtils
.
any2list
(
_
).
toArray
)
}
/**
* Get values for all libraries on a given path
* @param path path to of value
...
...
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