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
648ed1f3
Commit
648ed1f3
authored
Jan 17, 2017
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing vcfstats
parent
4f5b8b61
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
26 deletions
+40
-26
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/vcfstats/VcfStats.scala
...n/scala/nl/lumc/sasc/biopet/tools/vcfstats/VcfStats.scala
+14
-10
biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfStatsTest.scala
...c/test/scala/nl/lumc/sasc/biopet/tools/VcfStatsTest.scala
+15
-15
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/IoUtils.scala
...ls/src/main/scala/nl/lumc/sasc/biopet/utils/IoUtils.scala
+11
-1
No files found.
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/vcfstats/VcfStats.scala
View file @
648ed1f3
...
@@ -14,22 +14,22 @@
...
@@ -14,22 +14,22 @@
*/
*/
package
nl.lumc.sasc.biopet.tools.vcfstats
package
nl.lumc.sasc.biopet.tools.vcfstats
import
java.io.
{
File
,
FileOutputStream
,
PrintWriter
}
import
java.io.
{
File
,
FileOutputStream
,
IOException
,
PrintWriter
}
import
htsjdk.samtools.util.Interval
import
htsjdk.samtools.util.Interval
import
htsjdk.variant.variantcontext.
{
Genotype
,
VariantContext
}
import
htsjdk.variant.variantcontext.
{
Genotype
,
VariantContext
}
import
htsjdk.variant.vcf.VCFFileReader
import
htsjdk.variant.vcf.VCFFileReader
import
nl.lumc.sasc.biopet.utils.intervals.BedRecordList
import
nl.lumc.sasc.biopet.utils.intervals.BedRecordList
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
FastaUtils
,
ToolCommand
,
VcfUtils
}
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
FastaUtils
,
ToolCommand
,
VcfUtils
}
import
scala.collection.JavaConversions._
import
scala.collection.JavaConversions._
import
scala.collection.mutable
import
scala.collection.mutable
import
scala.io.Source
import
scala.io.Source
import
scala.sys.process.
{
Process
,
ProcessLogger
}
import
scala.sys.process.
{
Process
,
ProcessLogger
}
import
scala.util.Random
import
scala.util.Random
import
scala.concurrent.ExecutionContext.Implicits.global
import
scala.concurrent.ExecutionContext.Implicits.global
import
scala.concurrent.duration._
import
scala.concurrent.duration._
import
scala.concurrent.
{
Await
,
Future
}
import
scala.concurrent.
{
Await
,
Future
}
/**
/**
* This tool will generate statistics from a vcf file
* This tool will generate statistics from a vcf file
...
@@ -557,11 +557,15 @@ object VcfStats extends ToolCommand {
...
@@ -557,11 +557,15 @@ object VcfStats extends ToolCommand {
val
command
:
String
=
"Rscript "
+
file
+
" "
+
args
.
mkString
(
" "
)
val
command
:
String
=
"Rscript "
+
file
+
" "
+
args
.
mkString
(
" "
)
logger
.
info
(
"Starting: "
+
command
)
logger
.
info
(
"Starting: "
+
command
)
val
process
=
Process
(
command
).
run
(
ProcessLogger
(
x
=>
logger
.
debug
(
x
),
x
=>
logger
.
debug
(
x
)))
try
{
if
(
process
.
exitValue
()
==
0
)
logger
.
info
(
"Done: "
+
command
)
val
process
=
Process
(
command
).
run
(
ProcessLogger
(
x
=>
logger
.
debug
(
x
),
x
=>
logger
.
debug
(
x
)))
else
{
if
(
process
.
exitValue
()
==
0
)
logger
.
info
(
"Done: "
+
command
)
logger
.
warn
(
"Failed: "
+
command
)
else
{
if
(!
logger
.
isDebugEnabled
)
logger
.
warn
(
"Use -l debug for more info"
)
logger
.
warn
(
"Failed: "
+
command
)
if
(!
logger
.
isDebugEnabled
)
logger
.
warn
(
"Use -l debug for more info"
)
}
}
catch
{
case
e
:
IOException
=>
}
}
}
}
}
}
biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfStatsTest.scala
View file @
648ed1f3
...
@@ -103,7 +103,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -103,7 +103,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testMergeStatsMap
=
{
def
testMergeStatsMap
()
=
{
val
m1
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"a"
->
1
)
val
m1
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"a"
->
1
)
val
m2
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"b"
->
2
)
val
m2
:
mutable.Map
[
Any
,
Int
]
=
mutable
.
Map
(
"b"
->
2
)
...
@@ -124,7 +124,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -124,7 +124,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testMergeNestedStatsMap
=
{
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
)))
mutable
.
Map
(
"nested"
->
mutable
.
Map
(
"a"
->
1
)))
val
m2
:
Map
[
String
,
Map
[
String
,
Map
[
Any
,
Int
]]]
=
Map
(
"test"
->
val
m2
:
Map
[
String
,
Map
[
String
,
Map
[
Any
,
Int
]]]
=
Map
(
"test"
->
...
@@ -152,7 +152,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -152,7 +152,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testValueOfTsv
=
{
def
testValueOfTsv
()
=
{
val
i
=
new
File
(
resourcePath
(
"/sample.tsv"
))
val
i
=
new
File
(
resourcePath
(
"/sample.tsv"
))
valueFromTsv
(
i
,
"Sample_ID_1"
,
"library"
)
should
be
(
Some
(
"Lib_ID_1"
))
valueFromTsv
(
i
,
"Sample_ID_1"
,
"library"
)
should
be
(
Some
(
"Lib_ID_1"
))
...
@@ -163,7 +163,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -163,7 +163,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testMain
=
{
def
testMain
()
=
{
val
tmp
=
Files
.
createTempDirectory
(
"vcfStats"
)
val
tmp
=
Files
.
createTempDirectory
(
"vcfStats"
)
val
vcf
=
resourcePath
(
"/chrQ.vcf.gz"
)
val
vcf
=
resourcePath
(
"/chrQ.vcf.gz"
)
val
ref
=
resourcePath
(
"/fake_chrQ.fa"
)
val
ref
=
resourcePath
(
"/fake_chrQ.fa"
)
...
@@ -229,7 +229,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -229,7 +229,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testSortAnyAny
=
{
def
testSortAnyAny
()
=
{
//stub
//stub
val
one
:
Any
=
1
val
one
:
Any
=
1
val
two
:
Any
=
2
val
two
:
Any
=
2
...
@@ -245,7 +245,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -245,7 +245,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testCheckGeneral
=
{
def
testCheckGeneral
()
=
{
val
record
=
new
VCFFileReader
(
new
File
(
resourcePath
(
"/chrQ.vcf.gz"
))).
iterator
().
next
()
val
record
=
new
VCFFileReader
(
new
File
(
resourcePath
(
"/chrQ.vcf.gz"
))).
iterator
().
next
()
val
blah
=
checkGeneral
(
record
,
List
())
val
blah
=
checkGeneral
(
record
,
List
())
...
@@ -253,7 +253,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -253,7 +253,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
blah
.
get
(
"chrQ"
)
should
not
be
empty
blah
.
get
(
"chrQ"
)
should
not
be
empty
blah
.
get
(
"total"
)
should
not
be
empty
blah
.
get
(
"total"
)
should
not
be
empty
val
chrq
=
blah
.
get
(
"chrQ"
).
get
val
chrq
=
blah
(
"chrQ"
)
chrq
.
get
(
"SampleDistribution-NonInformative"
)
shouldEqual
Some
(
Map
(
0
->
1
))
chrq
.
get
(
"SampleDistribution-NonInformative"
)
shouldEqual
Some
(
Map
(
0
->
1
))
chrq
.
get
(
"SampleDistribution-Called"
)
shouldEqual
Some
(
Map
(
3
->
1
))
chrq
.
get
(
"SampleDistribution-Called"
)
shouldEqual
Some
(
Map
(
3
->
1
))
chrq
.
get
(
"SampleDistribution-Mixed"
)
shouldEqual
Some
(
Map
(
0
->
1
))
chrq
.
get
(
"SampleDistribution-Mixed"
)
shouldEqual
Some
(
Map
(
0
->
1
))
...
@@ -269,7 +269,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -269,7 +269,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
chrq
.
get
(
"SampleDistribution-Variant"
)
shouldEqual
Some
(
Map
(
2
->
1
))
chrq
.
get
(
"SampleDistribution-Variant"
)
shouldEqual
Some
(
Map
(
2
->
1
))
chrq
.
get
(
"general"
)
should
not
be
empty
chrq
.
get
(
"general"
)
should
not
be
empty
val
general
=
chrq
.
get
(
"general"
).
get
val
general
=
chrq
(
"general"
)
general
.
get
(
"PolymorphicInSamples"
)
shouldEqual
Some
(
1
)
general
.
get
(
"PolymorphicInSamples"
)
shouldEqual
Some
(
1
)
general
.
get
(
"ComplexIndel"
)
shouldEqual
Some
(
0
)
general
.
get
(
"ComplexIndel"
)
shouldEqual
Some
(
0
)
...
@@ -291,7 +291,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -291,7 +291,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
general
.
get
(
"Symbolic"
)
shouldEqual
Some
(
0
)
general
.
get
(
"Symbolic"
)
shouldEqual
Some
(
0
)
general
.
get
(
"SimpleInsertion"
)
shouldEqual
Some
(
1
)
general
.
get
(
"SimpleInsertion"
)
shouldEqual
Some
(
1
)
val
total
=
blah
.
get
(
"total"
).
get
val
total
=
blah
(
"total"
)
total
.
get
(
"SampleDistribution-NonInformative"
)
shouldEqual
Some
(
Map
(
0
->
1
))
total
.
get
(
"SampleDistribution-NonInformative"
)
shouldEqual
Some
(
Map
(
0
->
1
))
total
.
get
(
"SampleDistribution-Called"
)
shouldEqual
Some
(
Map
(
3
->
1
))
total
.
get
(
"SampleDistribution-Called"
)
shouldEqual
Some
(
Map
(
3
->
1
))
total
.
get
(
"SampleDistribution-Mixed"
)
shouldEqual
Some
(
Map
(
0
->
1
))
total
.
get
(
"SampleDistribution-Mixed"
)
shouldEqual
Some
(
Map
(
0
->
1
))
...
@@ -307,7 +307,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -307,7 +307,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
total
.
get
(
"SampleDistribution-Variant"
)
shouldEqual
Some
(
Map
(
2
->
1
))
total
.
get
(
"SampleDistribution-Variant"
)
shouldEqual
Some
(
Map
(
2
->
1
))
chrq
.
get
(
"general"
)
should
not
be
empty
chrq
.
get
(
"general"
)
should
not
be
empty
val
totGeneral
=
total
.
get
(
"general"
).
get
val
totGeneral
=
total
(
"general"
)
totGeneral
.
get
(
"PolymorphicInSamples"
)
shouldEqual
Some
(
1
)
totGeneral
.
get
(
"PolymorphicInSamples"
)
shouldEqual
Some
(
1
)
totGeneral
.
get
(
"ComplexIndel"
)
shouldEqual
Some
(
0
)
totGeneral
.
get
(
"ComplexIndel"
)
shouldEqual
Some
(
0
)
...
@@ -331,7 +331,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -331,7 +331,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
}
@Test
@Test
def
testCheckGenotype
=
{
def
testCheckGenotype
()
=
{
val
record
=
new
VCFFileReader
(
new
File
(
resourcePath
(
"/chrQ.vcf.gz"
))).
iterator
().
next
()
val
record
=
new
VCFFileReader
(
new
File
(
resourcePath
(
"/chrQ.vcf.gz"
))).
iterator
().
next
()
val
genotype
=
record
.
getGenotype
(
0
)
val
genotype
=
record
.
getGenotype
(
0
)
...
@@ -341,7 +341,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -341,7 +341,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
blah
.
get
(
"chrQ"
)
should
not
be
empty
blah
.
get
(
"chrQ"
)
should
not
be
empty
blah
.
get
(
"total"
)
should
not
be
empty
blah
.
get
(
"total"
)
should
not
be
empty
val
chrq
=
blah
.
get
(
"chrQ"
).
get
val
chrq
=
blah
(
"chrQ"
)
chrq
.
get
(
"GQ"
)
shouldEqual
Some
(
Map
(
99
->
1
))
chrq
.
get
(
"GQ"
)
shouldEqual
Some
(
Map
(
99
->
1
))
chrq
.
get
(
"AD"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
chrq
.
get
(
"AD"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
chrq
.
get
(
"AD-used"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
chrq
.
get
(
"AD-used"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
...
@@ -350,7 +350,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -350,7 +350,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
chrq
.
get
(
"AD-ref"
)
shouldEqual
Some
(
Map
(
24
->
1
))
chrq
.
get
(
"AD-ref"
)
shouldEqual
Some
(
Map
(
24
->
1
))
chrq
.
get
(
"general"
)
should
not
be
empty
chrq
.
get
(
"general"
)
should
not
be
empty
val
general
=
chrq
.
get
(
"general"
).
get
val
general
=
chrq
(
"general"
)
general
.
get
(
"Hom"
)
shouldEqual
Some
(
0
)
general
.
get
(
"Hom"
)
shouldEqual
Some
(
0
)
general
.
get
(
"NoCall"
)
shouldEqual
Some
(
0
)
general
.
get
(
"NoCall"
)
shouldEqual
Some
(
0
)
general
.
get
(
"Variant"
)
shouldEqual
Some
(
1
)
general
.
get
(
"Variant"
)
shouldEqual
Some
(
1
)
...
@@ -365,7 +365,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -365,7 +365,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
general
.
get
(
"Het"
)
shouldEqual
Some
(
1
)
general
.
get
(
"Het"
)
shouldEqual
Some
(
1
)
general
.
get
(
"HetNonRef"
)
shouldEqual
Some
(
0
)
general
.
get
(
"HetNonRef"
)
shouldEqual
Some
(
0
)
val
total
=
blah
.
get
(
"total"
).
get
val
total
=
blah
(
"total"
)
total
.
get
(
"GQ"
)
shouldEqual
Some
(
Map
(
99
->
1
))
total
.
get
(
"GQ"
)
shouldEqual
Some
(
Map
(
99
->
1
))
total
.
get
(
"AD"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
total
.
get
(
"AD"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
total
.
get
(
"AD-used"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
total
.
get
(
"AD-used"
)
shouldEqual
Some
(
Map
(
24
->
1
,
21
->
1
))
...
@@ -374,7 +374,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
...
@@ -374,7 +374,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
total
.
get
(
"AD-ref"
)
shouldEqual
Some
(
Map
(
24
->
1
))
total
.
get
(
"AD-ref"
)
shouldEqual
Some
(
Map
(
24
->
1
))
total
.
get
(
"general"
)
should
not
be
empty
total
.
get
(
"general"
)
should
not
be
empty
val
totGeneral
=
total
.
get
(
"general"
).
get
val
totGeneral
=
total
(
"general"
)
totGeneral
.
get
(
"Hom"
)
shouldEqual
Some
(
0
)
totGeneral
.
get
(
"Hom"
)
shouldEqual
Some
(
0
)
totGeneral
.
get
(
"NoCall"
)
shouldEqual
Some
(
0
)
totGeneral
.
get
(
"NoCall"
)
shouldEqual
Some
(
0
)
totGeneral
.
get
(
"Variant"
)
shouldEqual
Some
(
1
)
totGeneral
.
get
(
"Variant"
)
shouldEqual
Some
(
1
)
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/IoUtils.scala
View file @
648ed1f3
...
@@ -14,9 +14,10 @@
...
@@ -14,9 +14,10 @@
*/
*/
package
nl.lumc.sasc.biopet.utils
package
nl.lumc.sasc.biopet.utils
import
java.io.
{
File
,
FileInputStream
,
FileOutputStream
,
InputStream
}
import
java.io.
_
import
scala.io.Source
import
scala.io.Source
import
scala.sys.process.Process
/**
/**
* This object contains generic io methods
* This object contains generic io methods
...
@@ -83,4 +84,13 @@ object IoUtils {
...
@@ -83,4 +84,13 @@ object IoUtils {
reader
.
close
()
reader
.
close
()
lines
lines
}
}
def
executableExist
(
exe
:
String
)
:
Boolean
=
{
try
{
val
process
=
Process
(
Seq
(
exe
)).
run
()
true
}
catch
{
case
e
:
IOException
=>
false
}
}
}
}
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