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
a32bc102
Commit
a32bc102
authored
Sep 09, 2015
by
Peter van 't Hof
Browse files
Fix ode style
parent
782140f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala
View file @
a32bc102
...
...
@@ -136,12 +136,12 @@ object VcfStats extends ToolCommand {
generalWiggle
:
List
[
String
]
=
Nil
,
genotypeWiggle
:
List
[
String
]
=
Nil
)
extends
AbstractArgs
private
val
generalWiggleOptions
=
List
(
"Total"
,
"Biallelic"
,
"ComplexIndel"
,
"Filtered"
,
"FullyDecoded"
,
"Indel"
,
"Mixed"
,
private
val
generalWiggleOptions
=
List
(
"Total"
,
"Biallelic"
,
"ComplexIndel"
,
"Filtered"
,
"FullyDecoded"
,
"Indel"
,
"Mixed"
,
"MNP"
,
"MonomorphicInSamples"
,
"NotFiltered"
,
"PointEvent"
,
"PolymorphicInSamples"
,
"SimpleDeletion"
,
"SimpleInsertion"
,
"SNP"
,
"StructuralIndel"
,
"Symbolic"
,
"SymbolicOrSV"
,
"Variant"
)
private
val
genotypeWiggleOptions
=
List
(
"Total"
,
"Het"
,
"HetNonRef"
,
"Hom"
,
"HomRef"
,
"HomVar"
,
"Mixed"
,
"NoCall"
,
"NonInformative"
,
private
val
genotypeWiggleOptions
=
List
(
"Total"
,
"Het"
,
"HetNonRef"
,
"Hom"
,
"HomRef"
,
"HomVar"
,
"Mixed"
,
"NoCall"
,
"NonInformative"
,
"Available"
,
"Called"
,
"Filtered"
,
"Variant"
)
/** Parsing commandline arguments */
...
...
@@ -185,8 +185,8 @@ object VcfStats extends ToolCommand {
opt
[
String
](
"generalWiggle"
)
unbounded
()
action
{
(
x
,
c
)
=>
c
.
copy
(
generalWiggle
=
x
::
c
.
generalWiggle
,
writeBinStats
=
true
)
}
validate
{
x
=>
if
(
generalWiggleOptions
.
contains
(
x
))
success
else
failure
(
s
"""Nonexistent field $x"""
)
}
text
x
=>
if
(
generalWiggleOptions
.
contains
(
x
))
success
else
failure
(
s
"""Nonexistent field $x"""
)
}
text
"""
|Create a wiggle track with bin size <binSize> for any of the following statistics:
|Total
...
...
public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VcfStatsTest.scala
View file @
a32bc102
...
...
@@ -16,7 +16,7 @@
package
nl.lumc.sasc.biopet.tools
import
java.io.File
import
java.nio.file.
{
Files
,
Paths
}
import
java.nio.file.
{
Files
,
Paths
}
import
htsjdk.variant.variantcontext.Allele
import
htsjdk.variant.vcf.VCFFileReader
...
...
@@ -37,7 +37,6 @@ class VcfStatsTest extends TestNGSuite with Matchers {
Paths
.
get
(
getClass
.
getResource
(
p
).
toURI
).
toString
}
@Test
def
testSampleToSampleStats
()
:
Unit
=
{
val
s1
=
SampleToSampleStats
()
...
...
@@ -127,62 +126,62 @@ class VcfStatsTest extends TestNGSuite with Matchers {
@Test
def
testMergeStatsMap
=
{
val
m1
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"a"
->
1
)
val
m2
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"b"
->
2
)
val
m1
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"a"
->
1
)
val
m2
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"b"
->
2
)
mergeStatsMap
(
m1
,
m2
)
m1
should
equal
(
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
))
m1
should
equal
(
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
))
val
m3
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
1
->
500
)
val
m4
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
6
->
125
)
val
m3
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
1
->
500
)
val
m4
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
6
->
125
)
mergeStatsMap
(
m3
,
m4
)
m3
should
equal
(
mutable
.
Map
(
1
->
500
,
6
->
125
))
m3
should
equal
(
mutable
.
Map
(
1
->
500
,
6
->
125
))
mergeStatsMap
(
m1
,
m3
)
m1
should
equal
(
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
,
1
->
500
,
6
->
125
))
m1
should
equal
(
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
,
1
->
500
,
6
->
125
))
}
@Test
def
testMergeNestedStatsMap
=
{
val
m1
:
mutable.Map
[
String
,
mutable.Map
[
String
,
mutable.Map
[
Any
,
Int
]]]
=
mutable
.
Map
(
"test"
->
val
m1
:
mutable.Map
[
String
,
mutable.Map
[
String
,
mutable.Map
[
Any
,
Int
]]]
=
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nested"
->
mutable
.
Map
(
"a"
->
1
)))
val
m2
:
Map
[
String
,
Map
[
String
,
Map
[
Any
,
Int
]]]
=
Map
(
"test"
->
Map
(
"nested"
->
Map
(
"b"
->
2
)))
mergeNestedStatsMap
(
m1
,
m2
)
m1
should
equal
(
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nested"
->
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
))))
m1
should
equal
(
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nested"
->
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
))))
val
m3
:
mutable.Map
[
String
,
mutable.Map
[
String
,
mutable.Map
[
Any
,
Int
]]]
=
mutable
.
Map
(
"test"
->
val
m3
:
mutable.Map
[
String
,
mutable.Map
[
String
,
mutable.Map
[
Any
,
Int
]]]
=
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nestedd"
->
mutable
.
Map
(
1
->
500
)))
val
m4
:
Map
[
String
,
Map
[
String
,
Map
[
Any
,
Int
]]]
=
Map
(
"test"
->
Map
(
"nestedd"
->
Map
(
6
->
125
)))
mergeNestedStatsMap
(
m3
,
m4
)
m3
should
equal
(
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nestedd"
->
mutable
.
Map
(
1
->
500
,
6
->
125
))))
m3
should
equal
(
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nestedd"
->
mutable
.
Map
(
1
->
500
,
6
->
125
))))
val
m5
=
m3
.
toMap
.
map
(
x
=>
x
.
_1
->
x
.
_2
.
toMap
.
map
(
y
=>
y
.
_1
->
y
.
_2
.
toMap
))
mergeNestedStatsMap
(
m1
,
m5
)
m1
should
equal
(
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nested"
->
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
),
"nestedd"
->
mutable
.
Map
(
1
->
500
,
6
->
125
))))
m1
should
equal
(
mutable
.
Map
(
"test"
->
mutable
.
Map
(
"nested"
->
mutable
.
Map
(
"a"
->
1
,
"b"
->
2
),
"nestedd"
->
mutable
.
Map
(
1
->
500
,
6
->
125
))))
}
@Test
def
testValueOfTsv
=
{
val
i
=
new
File
(
resourcePath
(
"/sample.tsv"
))
valueFromTsv
(
i
,
"Sample_ID_1"
,
"library"
)
should
be
(
Some
(
"Lib_ID_1"
))
valueFromTsv
(
i
,
"Sample_ID_2"
,
"library"
)
should
be
(
Some
(
"Lib_ID_2"
))
valueFromTsv
(
i
,
"Sample_ID_1"
,
"bam"
)
should
be
(
Some
(
"MyFirst.bam"
))
valueFromTsv
(
i
,
"Sample_ID_2"
,
"bam"
)
should
be
(
Some
(
"MySecond.bam"
))
valueFromTsv
(
i
,
"Sample_ID_3"
,
"bam"
)
should
be
(
empty
)
valueFromTsv
(
i
,
"Sample_ID_1"
,
"library"
)
should
be
(
Some
(
"Lib_ID_1"
))
valueFromTsv
(
i
,
"Sample_ID_2"
,
"library"
)
should
be
(
Some
(
"Lib_ID_2"
))
valueFromTsv
(
i
,
"Sample_ID_1"
,
"bam"
)
should
be
(
Some
(
"MyFirst.bam"
))
valueFromTsv
(
i
,
"Sample_ID_2"
,
"bam"
)
should
be
(
Some
(
"MySecond.bam"
))
valueFromTsv
(
i
,
"Sample_ID_3"
,
"bam"
)
should
be
(
empty
)
}
@Test
...
...
@@ -224,7 +223,6 @@ class VcfStatsTest extends TestNGSuite with Matchers {
"--generalWiggle"
,
x
))
)
// returns null when validation fails
def
validateArgs
(
array
:
Array
[
String
])
:
Option
[
Args
]
=
{
val
argsParser
=
new
OptParser
...
...
@@ -249,7 +247,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
val
one
:
Any
=
1
val
two
:
Any
=
2
val
text
:
Any
=
"hello"
val
text2
:
Any
=
"goodbye"
val
text2
:
Any
=
"goodbye"
sortAnyAny
(
one
,
two
)
shouldBe
true
sortAnyAny
(
two
,
one
)
shouldBe
false
...
...
@@ -306,7 +304,6 @@ class VcfStatsTest extends TestNGSuite with Matchers {
general
.
get
(
"Symbolic"
)
shouldEqual
Some
(
0
)
general
.
get
(
"SimpleInsertion"
)
shouldEqual
Some
(
1
)
val
total
=
blah
.
get
(
"total"
).
get
total
.
get
(
"SampleDistribution-NonInformative"
)
shouldEqual
Some
(
Map
(
0
->
1
))
total
.
get
(
"SampleDistribution-Called"
)
shouldEqual
Some
(
Map
(
3
->
1
))
...
...
@@ -353,10 +350,10 @@ class VcfStatsTest extends TestNGSuite with Matchers {
val
genotype
=
record
.
getGenotype
(
0
)
val
blah
=
checkGenotype
(
record
,
genotype
,
List
())
blah
.
get
(
"chrQ"
)
should
not
be
empty
blah
.
get
(
"total"
)
should
not
be
empty
val
chrq
=
blah
.
get
(
"chrQ"
).
get
chrq
.
get
(
"GQ"
)
shouldEqual
Some
(
Map
(
99
->
1
))
chrq
.
get
(
"AD"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
...
...
@@ -365,7 +362,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
chrq
.
get
(
"AD-alt"
)
shouldEqual
Some
(
Map
(
21
->
1
))
chrq
.
get
(
"AD-ref"
)
shouldEqual
Some
(
Map
(
24
->
1
))
chrq
.
get
(
"general"
)
should
not
be
empty
val
general
=
chrq
.
get
(
"general"
).
get
general
.
get
(
"Hom"
)
shouldEqual
Some
(
0
)
general
.
get
(
"NoCall"
)
shouldEqual
Some
(
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