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
20c25a0b
Commit
20c25a0b
authored
Nov 11, 2014
by
Peter van 't Hof
Browse files
Added checks
parent
0886c76f
Changes
1
Hide whitespace changes
Inline
Side-by-side
biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFasta.scala
View file @
20c25a0b
...
@@ -9,6 +9,7 @@ import nl.lumc.sasc.biopet.core.ToolCommand
...
@@ -9,6 +9,7 @@ import nl.lumc.sasc.biopet.core.ToolCommand
import
nl.lumc.sasc.biopet.core.config.Configurable
import
nl.lumc.sasc.biopet.core.config.Configurable
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
,
Argument
}
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
,
Argument
}
import
scala.collection.JavaConversions._
import
scala.collection.JavaConversions._
import
nl.lumc.sasc.biopet.util.VcfUtils._
class
BastyGenerateFasta
(
val
root
:
Configurable
)
extends
BiopetJavaCommandLineFunction
{
class
BastyGenerateFasta
(
val
root
:
Configurable
)
extends
BiopetJavaCommandLineFunction
{
javaMainClass
=
getClass
.
getName
javaMainClass
=
getClass
.
getName
...
@@ -92,6 +93,8 @@ object BastyGenerateFasta extends ToolCommand {
...
@@ -92,6 +93,8 @@ object BastyGenerateFasta extends ToolCommand {
}
}
def
writeVariantsOnly
()
{
def
writeVariantsOnly
()
{
if
(
commandArgs
.
inputVcf
==
null
)
throw
new
IllegalStateException
(
"To write outputVariants input vcf is required, please use --outputVariants option"
)
if
(!
commandArgs
.
inputVcf
.
exists
)
throw
new
IllegalStateException
(
"File does not exist: "
+
commandArgs
.
inputVcf
)
val
writer
=
new
PrintWriter
(
commandArgs
.
outputVariants
)
val
writer
=
new
PrintWriter
(
commandArgs
.
outputVariants
)
writer
.
println
(
">"
+
commandArgs
.
sampleName
)
writer
.
println
(
">"
+
commandArgs
.
sampleName
)
val
vcfReader
=
new
VCFFileReader
(
commandArgs
.
inputVcf
,
false
)
val
vcfReader
=
new
VCFFileReader
(
commandArgs
.
inputVcf
,
false
)
...
@@ -105,8 +108,7 @@ object BastyGenerateFasta extends ToolCommand {
...
@@ -105,8 +108,7 @@ object BastyGenerateFasta extends ToolCommand {
def
getMaxAllele
(
vcfRecord
:
VariantContext
,
sample
:
String
)
:
String
=
{
def
getMaxAllele
(
vcfRecord
:
VariantContext
,
sample
:
String
)
:
String
=
{
val
genotype
=
vcfRecord
.
getGenotype
(
sample
)
val
genotype
=
vcfRecord
.
getGenotype
(
sample
)
val
longestAlleleID
=
vcfRecord
.
getAlleles
.
map
(
_
.
getBases
.
length
).
zipWithIndex
.
maxBy
(
_
.
_1
).
_2
val
maxSize
=
getLongestAllele
(
vcfRecord
).
getBases
.
length
val
maxSize
=
vcfRecord
.
getAlleles
()(
longestAlleleID
).
getBases
.
length
def
fill
(
bases
:
String
)
=
bases
+
(
Array
.
fill
[
Char
](
maxSize
-
bases
.
size
)(
'N'
)).
mkString
def
fill
(
bases
:
String
)
=
bases
+
(
Array
.
fill
[
Char
](
maxSize
-
bases
.
size
)(
'N'
)).
mkString
if
(
commandArgs
.
reference
)
return
fill
(
vcfRecord
.
getReference
.
getBaseString
)
if
(
commandArgs
.
reference
)
return
fill
(
vcfRecord
.
getReference
.
getBaseString
)
...
...
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