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
138ab51a
Commit
138ab51a
authored
May 09, 2016
by
Peter van 't Hof
Browse files
Fixed summary stats
parent
4c006702
Changes
1
Hide whitespace changes
Inline
Side-by-side
biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/VariantEffectPredictor.scala
View file @
138ab51a
...
...
@@ -292,31 +292,20 @@ class VariantEffectPredictor(val root: Configurable) extends BiopetCommandLineFu
def
parseStatsFile
(
file
:
File
)
:
Map
[
String
,
Any
]
=
{
val
reader
=
Source
.
fromFile
(
file
)
val
contents
=
reader
.
getLines
().
filter
(
_
!=
""
).
to
List
val
contents
=
reader
.
getLines
().
filter
(
_
!=
""
).
to
Array
reader
.
close
()
val
headers
=
contents
.
filter
(
x
=>
x
.
startsWith
(
"["
)
&&
x
.
endsWith
(
"]"
))
.
map
(
_
.
stripPrefix
(
"["
).
stripSuffix
(
"]"
))
headers
.
foldLeft
(
Map
.
empty
[
String
,
Any
])((
acc
,
x
)
=>
acc
+
(
x
.
replace
(
" "
,
"_"
)
->
getBlockFromStatsFile
(
contents
,
x
)))
}
def
isHeader
(
line
:
String
)
=
line
.
startsWith
(
"["
)
&&
line
.
endsWith
(
"]"
)
def
getBlockFromStatsFile
(
contents
:
List
[
String
],
header
:
String
)
:
Map
[
String
,
Any
]
=
{
var
inBlock
=
false
var
theMap
:
Map
[
String
,
Any
]
=
Map
()
for
(
x
<-
contents
)
{
val
stripped
=
x
.
stripPrefix
(
"["
).
stripSuffix
(
"]"
)
if
(
stripped
==
header
)
inBlock
=
true
else
{
if
(
inBlock
)
{
val
key
=
stripped
.
split
(
'\t'
).
head
.
replace
(
" "
,
"_"
)
val
value
=
stripped
.
split
(
'\t'
).
last
theMap
++=
Map
(
key
->
tryToParseNumber
(
value
,
fallBack
=
true
).
getOrElse
(
value
))
}
}
if
(
stripped
==
""
)
inBlock
=
false
}
theMap
.
filter
(
_
.
_1
.
nonEmpty
)
}
val
headers
=
contents
.
zipWithIndex
.
filter
(
x
=>
x
.
_1
.
startsWith
(
"["
)
&&
x
.
_1
.
endsWith
(
"]"
))
(
for
((
header
,
headerIndex
)
<-
headers
)
yield
{
val
name
=
header
.
stripPrefix
(
"["
).
stripSuffix
(
"]"
)
name
->
(
contents
.
drop
(
headerIndex
+
1
).
takeWhile
(!
isHeader
(
_
)).
map
{
line
=>
val
values
=
line
.
split
(
"\t"
,
2
)
values
.
head
->
tryToParseNumber
(
values
.
last
).
getOrElse
(
0
)
}.
toMap
)
}).
toMap
}
}
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