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
3113399f
Commit
3113399f
authored
Oct 05, 2014
by
bow
Browse files
Initial complete main WipeReads function implementation
parent
cb1f06d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/apps/WipeReads.scala
View file @
3113399f
...
...
@@ -205,22 +205,21 @@ object WipeReads {
=>
parseOption
(
opts
++
Map
(
"targetRegions"
->
checkInputFile
(
new
File
(
value
))),
tail
)
case
(
"--outputBAM"
|
"-o"
)
::
value
::
tail
if
!
opts
.
contains
(
"outputBAM"
)
=>
parseOption
(
opts
++
Map
(
"outputBAM"
->
new
File
(
value
)),
tail
)
// TODO: implementation
case
(
"--minOverlapFraction"
|
"-f"
)
::
value
::
tail
if
!
opts
.
contains
(
"minOverlapFraction"
)
=>
parseOption
(
opts
++
Map
(
"minOverlapFraction"
->
value
.
toDouble
),
tail
)
case
(
"--minMapQ"
|
"-Q"
)
::
value
::
tail
if
!
opts
.
contains
(
"minMapQ"
)
=>
parseOption
(
opts
++
Map
(
"minMapQ"
->
value
.
toInt
),
tail
)
// TODO: implementation
case
(
"--strand"
|
"-s"
)
::
(
value
@
(
"identical"
|
"opposite"
|
"both"
))
::
tail
if
!
opts
.
contains
(
"strand"
)
=>
parseOption
(
opts
++
Map
(
"strand"
->
Strand
.
withName
(
value
.
capitalize
)),
tail
)
// TODO: implementation
case
(
"--makeIndex"
)
::
tail
=>
parseOption
(
opts
++
Map
(
"makeIndex"
->
true
),
tail
)
case
(
"--limitToRegion"
|
"-limit"
)
::
tail
=>
parseOption
(
opts
++
Map
(
"limitToRegion"
->
true
),
tail
)
// TODO: better way to parse multiple flag values?
case
(
"--readGroup"
|
"-RG"
)
::
value
::
tail
if
!
opts
.
contains
(
"readGroup"
)
=>
parseOption
(
opts
++
Map
(
"readGroup"
->
value
.
split
(
","
).
toVector
),
tail
)
=>
parseOption
(
opts
++
Map
(
"readGroup"
->
value
.
split
(
","
).
toSet
),
tail
)
case
(
"--noMakeIndex"
)
::
tail
=>
parseOption
(
opts
++
Map
(
"noMakeIndex"
->
true
),
tail
)
case
(
"--limitToRegion"
|
"-limit"
)
::
tail
=>
parseOption
(
opts
++
Map
(
"limitToRegion"
->
true
),
tail
)
// TODO: implementation
case
(
"--minOverlapFraction"
|
"-f"
)
::
value
::
tail
if
!
opts
.
contains
(
"minOverlapFraction"
)
=>
parseOption
(
opts
++
Map
(
"minOverlapFraction"
->
value
.
toDouble
),
tail
)
// TODO: implementation
case
(
"--strand"
|
"-s"
)
::
(
value
@
(
"identical"
|
"opposite"
|
"both"
))
::
tail
if
!
opts
.
contains
(
"strand"
)
=>
parseOption
(
opts
++
Map
(
"strand"
->
Strand
.
withName
(
value
.
capitalize
)),
tail
)
case
option
::
tail
=>
throw
new
IllegalArgumentException
(
"Unexpected or duplicate option flag: "
+
option
)
}
...
...
@@ -255,13 +254,28 @@ object WipeReads {
}
val
options
=
parseOption
(
Map
(),
args
.
toList
)
validateOption
(
options
)
val
inputBAM
=
options
(
"inputBAM"
).
asInstanceOf
[
File
]
val
outputBAM
=
options
(
"outputBAM"
).
asInstanceOf
[
File
]
val
iv
=
makeRawIntervalFromFile
(
options
(
"targetRegions"
).
asInstanceOf
[
File
])
// limiting bloomSize to 70M and bloomFp to 4e-7 due to Int size limitation set in algebird
val
filterFunc
=
makeFilterOutFunction
(
iv
=
iv
,
inBAM
=
inputBAM
,
filterOutMulti
=
!
options
.
getOrElse
(
"limitToRegion"
,
false
).
asInstanceOf
[
Boolean
],
minMapQ
=
options
.
getOrElse
(
"minMapQ"
,
0
).
asInstanceOf
[
Int
],
readGroupIDs
=
options
.
getOrElse
(
"readGroupIDs"
,
Set
()).
asInstanceOf
[
Set
[
String
]],
bloomSize
=
70000000
,
bloomFp
=
4
e
-
7
)
writeFilteredBAM
(
filterFunc
,
inputBAM
,
outputBAM
,
writeIndex
=
!
options
.
getOrElse
(
"noMakeIndex"
,
false
).
asInstanceOf
[
Boolean
])
}
val
usage
:
String
=
"""
|usage: java -cp BiopetFramework.jar nl.lumc.sasc.biopet
-
core.apps.WipeReads [options] -I input -l regions -o output
|usage: java -cp BiopetFramework.jar nl.lumc.sasc.biopet
.
core.apps.WipeReads [options] -I input -l regions -o output
|
|WipeReads - Tool for reads removal from an indexed BAM file
.
|WipeReads - Tool for reads removal from an indexed BAM file
|
|positional arguments:
| -I,--inputBAM Input BAM file, must be indexed with '.bam.bai' or 'bai' extension
...
...
@@ -269,8 +283,12 @@ object WipeReads {
| -o,--outputBAM Output BAM file
|
|optional arguments:
| -RG,--readGroup Read groups to remove (default: all)
| -Q,--minMapQ Minimum MAPQ value of reads in target region (default: 0)
| -RG,--readGroup Read groups to remove; set multiple read groups using commas
| (default: all)
| -Q,--minMapQ Minimum MAPQ value of reads in target region
| (default: 0)
| --makeIndex Write BAM output file index
| (default: true)
| --limitToRegion Whether to remove only reads in the target regions and and
| keep the same reads if they map to other regions
| (default: not set)
...
...
@@ -279,4 +297,4 @@ object WipeReads {
|By default, if the removed reads are also mapped to other regions outside
|the given ones, they will also be removed.
"""
.
stripMargin
}
}
\ No newline at end of file
biopet-framework/src/test/scala/nl/lumc/sasc/biopet/core/apps/WipeReadsUnitTest.scala
View file @
3113399f
...
...
@@ -313,9 +313,9 @@ class WipeReadsUnitTest extends Assertions {
}
@Test
def
testOptMakeIndex
()
=
{
val
argList
=
List
(
"--
m
akeIndex"
)
:::
minArgList
val
argList
=
List
(
"--
noM
akeIndex"
)
:::
minArgList
val
opts
=
parseOption
(
Map
(),
argList
)
assert
(
opts
(
"
m
akeIndex"
)
==
true
)
// why can't we evaluate directly??
assert
(
opts
(
"
noM
akeIndex"
)
==
true
)
// why can't we evaluate directly??
}
@Test
def
testOptLimitToRegion
()
=
{
...
...
@@ -327,12 +327,12 @@ class WipeReadsUnitTest extends Assertions {
@Test
def
testOptSingleReadGroup
()
=
{
val
argList
=
List
(
"--readGroup"
,
"g1"
)
:::
minArgList
val
opts
=
parseOption
(
Map
(),
argList
)
assert
(
opts
(
"readGroup"
)
==
Vector
(
"g1"
))
assert
(
opts
(
"readGroup"
)
==
Set
(
"g1"
))
}
@Test
def
testOptMultipleReadGroup
()
=
{
val
argList
=
List
(
"--readGroup"
,
"g1,g2"
)
:::
minArgList
val
opts
=
parseOption
(
Map
(),
argList
)
assert
(
opts
(
"readGroup"
)
==
Vector
(
"g1"
,
"g2"
))
assert
(
opts
(
"readGroup"
)
==
Set
(
"g1"
,
"g2"
))
}
}
}
\ No newline at end of file
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