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
069db857
Commit
069db857
authored
Dec 10, 2016
by
Peter van 't Hof
Browse files
Added base version of validate vcf
parent
0b4c76c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
biopet-tools-package/src/main/scala/nl/lumc/sasc/biopet/BiopetToolsExecutable.scala
View file @
069db857
...
...
@@ -45,6 +45,7 @@ object BiopetToolsExecutable extends BiopetExecutable {
nl
.
lumc
.
sasc
.
biopet
.
tools
.
SquishBed
,
nl
.
lumc
.
sasc
.
biopet
.
tools
.
SummaryToTsv
,
nl
.
lumc
.
sasc
.
biopet
.
tools
.
ValidateFastq
,
nl
.
lumc
.
sasc
.
biopet
.
tools
.
ValidateVcf
,
nl
.
lumc
.
sasc
.
biopet
.
tools
.
VcfFilter
,
nl
.
lumc
.
sasc
.
biopet
.
tools
.
VcfStats
,
nl
.
lumc
.
sasc
.
biopet
.
tools
.
VcfToTsv
,
...
...
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/ValidateVcf.scala
0 → 100644
View file @
069db857
package
nl.lumc.sasc.biopet.tools
import
java.io.File
import
htsjdk.variant.vcf.VCFFileReader
import
nl.lumc.sasc.biopet.utils.ToolCommand
import
nl.lumc.sasc.biopet.utils.intervals.
{
BedRecord
,
BedRecordList
}
import
scala.collection.JavaConversions._
/**
* Created by pjvanthof on 10/12/2016.
*/
object
ValidateVcf
extends
ToolCommand
{
case
class
Args
(
inputVcf
:
File
=
null
,
reference
:
File
=
null
,
failOnError
:
Boolean
=
true
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'i'
,
"inputVcf"
)
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
inputVcf
=
x
)
}
text
"Vcf file to check"
opt
[
File
](
'R'
,
"reference"
)
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
reference
=
x
)
}
text
"Reference fasta to check vcf file against"
opt
[
Unit
](
"disableFail"
)
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
failOnError
=
false
)
}
text
"Disable failing, tool still stops at the first error but exitcode 0 is given"
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
logger
.
info
(
"Start"
)
val
argsParser
=
new
OptParser
val
cmdArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
(
throw
new
IllegalArgumentException
)
val
regions
=
BedRecordList
.
fromReference
(
cmdArgs
.
reference
)
val
vcfReader
=
new
VCFFileReader
(
cmdArgs
.
inputVcf
,
true
)
try
{
for
(
record
<-
vcfReader
.
iterator
())
{
val
contig
=
record
.
getContig
require
(
regions
.
chrRecords
.
contains
(
contig
),
s
"contig in vcf file is not on reference: ${contig}"
)
val
start
=
record
.
getStart
val
end
=
record
.
getEnd
require
(
regions
.
chrRecords
(
contig
).
exists
(
_
.
overlapWith
(
BedRecord
(
"contig"
,
start
,
start
))),
s
"Position does not exist on reference: ${contig}:$start"
)
if
(
end
!=
start
)
require
(
regions
.
chrRecords
(
contig
).
exists
(
_
.
overlapWith
(
BedRecord
(
"contig"
,
end
,
end
))),
s
"Position does not exist on reference: ${contig}:$end"
)
require
(
start
<=
end
,
"End is higher then Start, this should not be possible"
)
}
}
catch
{
case
e
:
IllegalArgumentException
=>
if
(
cmdArgs
.
failOnError
)
throw
e
else
logger
.
warn
(
e
.
getMessage
)
}
vcfReader
.
close
()
logger
.
info
(
"No error found"
)
}
}
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