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
6f58b7e2
Commit
6f58b7e2
authored
Oct 02, 2015
by
Wai Yi Leung
Browse files
Adding krakenreport2json to gears pipeline
parent
45b54bc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/KrakenReportToJson.scala
View file @
6f58b7e2
...
...
@@ -85,8 +85,7 @@ object KrakenReportToJson extends ToolCommand {
.
parse
(
args
,
Args
())
.
getOrElse
(
sys
.
exit
(
1
))
def
parseLine
(
krakenRawHit
:
String
)
:
Map
[
Long
,
KrakenHit
]
=
{
def
parseLine
(
krakenRawHit
:
String
)
:
Map
[
Long
,
KrakenHit
]
=
{
val
values
:
Array
[
String
]
=
krakenRawHit
.
stripLineEnd
.
split
(
"\t"
)
val
scientificName
:
String
=
values
(
5
)
val
cladeLevel
=
spacePattern
.
findFirstIn
(
scientificName
).
getOrElse
(
""
).
length
/
2
...
...
@@ -111,7 +110,7 @@ object KrakenReportToJson extends ToolCommand {
def
reportToJson
(
reportRaw
:
File
)
:
String
=
{
val
reader
=
Source
.
fromFile
(
reportRaw
)
// val lines = reader.getLines().toList.filter(!_.isEmpty)
// val lines = reader.getLines().toList.filter(!_.isEmpty)
/*
* http://ccb.jhu.edu/software/kraken/MANUAL.html
...
...
@@ -125,11 +124,11 @@ object KrakenReportToJson extends ToolCommand {
* */
val
lines
=
reader
.
getLines
()
.
map
(
line
=>
parseLine
(
line
))
.
filter
(
p
=>
p
.
head
.
_2
.
cladeSize
>
0
)
.
foldLeft
(
Map
.
empty
[
Long
,
KrakenHit
])(
(
a
,
b
)
=>
{
a
+
b
.
head
}
)
.
map
(
line
=>
parseLine
(
line
))
.
filter
(
p
=>
p
.
head
.
_2
.
cladeSize
>
0
)
.
foldLeft
(
Map
.
empty
[
Long
,
KrakenHit
])((
a
,
b
)
=>
{
a
+
b
.
head
}
)
lines
.
keys
.
foreach
(
k
=>
{
// append itself to the children attribute of the parent
...
...
public/gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/Gears.scala
View file @
6f58b7e2
...
...
@@ -22,6 +22,7 @@ import nl.lumc.sasc.biopet.extensions.picard.SamToFastq
import
nl.lumc.sasc.biopet.extensions.sambamba.SambambaView
import
nl.lumc.sasc.biopet.extensions.tools.FastqSync
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.tools.KrakenReportToJson
import
org.broadinstitute.gatk.queue.QScript
/**
...
...
@@ -113,6 +114,11 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript { qscrip
krakenReport
.
output
=
new
File
(
outputDir
,
s
"$outputName.krkn.full"
)
add
(
krakenReport
)
val
krakenReportJSON
=
new
KrakenReportToJson
(
qscript
)
krakenReportJSON
.
input
=
krakenReport
.
output
krakenReportJSON
.
output
=
new
File
(
outputDir
,
s
"$outputName.krkn.json"
)
add
(
krakenReportJSON
)
addSummaryJobs
()
}
...
...
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