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
d81585ca
Commit
d81585ca
authored
Mar 07, 2015
by
Peter van 't Hof
Browse files
Adding scala docs
parent
7908eb1d
Changes
5
Hide whitespace changes
Inline
Side-by-side
protected/biopet-gatk-pipelines/src/main/scala/nl/lumc/sasc/biopet/pipelines/gatk/Shiva.scala
View file @
d81585ca
...
...
@@ -13,6 +13,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
qscript
=>
def
this
()
=
this
(
null
)
/** Make variantcalling submodule, this with the gatk modes in there */
override
def
makeVariantcalling
(
multisample
:
Boolean
=
false
)
:
ShivaVariantcallingTrait
=
{
if
(
multisample
)
new
ShivaVariantcalling
(
qscript
)
{
override
def
namePrefix
=
"multisample"
...
...
@@ -24,10 +25,18 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
}
}
/** Makes a sample */
override
def
makeSample
(
id
:
String
)
=
new
this
.
Sample
(
id
)
/** Class will generate sample jobs */
class
Sample
(
sampleId
:
String
)
extends
super
.
Sample
(
sampleId
)
{
/** Makes a library */
override
def
makeLibrary
(
id
:
String
)
=
new
this
.
Library
(
id
)
/** Class will generate library jobs */
class
Library
(
libId
:
String
)
extends
super
.
Library
(
libId
)
{
/** This will adds preprocess steps, gatk indel realignment and base recalibration is included here */
override
def
preProcess
(
input
:
File
)
:
Option
[
File
]
=
{
val
useIndelRealigner
:
Boolean
=
config
(
"use_indel_realign"
,
default
=
true
)
val
useBaseRecalibration
:
Boolean
=
config
(
"use_base_recalibration"
,
default
=
true
)
...
...
@@ -47,6 +56,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
}
}
/** This methods will add double preprocess steps, with GATK indel realignment */
override
protected
def
addDoublePreProcess
(
input
:
List
[
File
],
isIntermediate
:
Boolean
=
false
)
:
Option
[
File
]
=
{
if
(
input
.
size
<=
1
)
super
.
addDoublePreProcess
(
input
)
else
super
.
addDoublePreProcess
(
input
,
true
).
collect
{
...
...
@@ -60,6 +70,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
}
}
/** Adds indel realignment jobs */
def
addIndelRealign
(
inputBam
:
File
,
dir
:
File
,
isIntermediate
:
Boolean
)
:
File
=
{
val
realignerTargetCreator
=
RealignerTargetCreator
(
this
,
inputBam
,
dir
)
realignerTargetCreator
.
isIntermediate
=
true
...
...
@@ -72,6 +83,7 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
return
indelRealigner
.
o
}
/** Adds base recalibration jobs */
def
addBaseRecalibrator
(
inputBam
:
File
,
dir
:
File
,
isIntermediate
:
Boolean
)
:
File
=
{
val
baseRecalibrator
=
BaseRecalibrator
(
this
,
inputBam
,
swapExt
(
dir
,
inputBam
,
".bam"
,
".baserecal"
))
...
...
@@ -98,4 +110,5 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
}
}
/** This object give a default main methods for this pipeline */
object
Shiva
extends
PipelineCommand
\ No newline at end of file
protected/biopet-gatk-pipelines/src/main/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcalling.scala
View file @
d81585ca
...
...
@@ -13,6 +13,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
qscript
=>
def
this
()
=
this
(
null
)
/** Will generate all available variantcallers */
override
def
callersList
=
{
new
HaplotypeCallerGvcf
::
new
HaplotypeCallerAllele
::
...
...
@@ -22,6 +23,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
super
.
callersList
}
/** Default mode for the haplotypecaller */
class
HaplotypeCaller
extends
Variantcaller
{
val
name
=
"haplotypecaller"
protected
val
defaultPrio
=
1
...
...
@@ -36,6 +38,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
}
}
/** Default mode for UnifiedGenotyper */
class
UnifiedGenotyper
extends
Variantcaller
{
val
name
=
"unifiedgenotyper"
protected
val
defaultPrio
=
20
...
...
@@ -50,6 +53,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
}
}
/** Allele mode for Haplotypecaller */
class
HaplotypeCallerAllele
extends
Variantcaller
{
val
name
=
"haplotypecaller_allele"
protected
val
defaultPrio
=
5
...
...
@@ -66,6 +70,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
}
}
/** Allele mode for GenotyperAllele */
class
UnifiedGenotyperAllele
extends
Variantcaller
{
val
name
=
"unifiedgenotyper_allele"
protected
val
defaultPrio
=
9
...
...
@@ -82,6 +87,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
}
}
/** Gvcf mode for haplotypecaller */
class
HaplotypeCallerGvcf
extends
Variantcaller
{
val
name
=
"haplotypecaller_gvcf"
protected
val
defaultPrio
=
5
...
...
@@ -104,4 +110,5 @@ class ShivaVariantcalling(val root: Configurable) extends QScript with ShivaVari
}
}
/** object to add default main method to pipeline */
object
ShivaVariantcalling
extends
PipelineCommand
\ No newline at end of file
public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/Shiva.scala
View file @
d81585ca
...
...
@@ -11,4 +11,5 @@ class Shiva(val root: Configurable) extends QScript with ShivaTrait {
def
this
()
=
this
(
null
)
}
/** This object give a default main method to the pipelines */
object
Shiva
extends
PipelineCommand
\ No newline at end of file
public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTrait.scala
View file @
d81585ca
...
...
@@ -12,21 +12,25 @@ import nl.lumc.sasc.biopet.pipelines.mapping.Mapping
import
scala.collection.JavaConversions._
/**
* This is a trait for the Shiva pipeline
*
* Created by pjvan_thof on 2/26/15.
*/
trait
ShivaTrait
extends
MultiSampleQScript
with
SummaryQScript
{
qscript
=>
/** Executed before running the script */
def
init
:
Unit
=
{
}
/** Method to add jobs */
def
biopetScript
:
Unit
=
{
addSamplesJobs
()
addSummaryJobs
}
/** Method to make the variantcalling submodule of shiva */
def
makeVariantcalling
(
multisample
:
Boolean
=
false
)
:
ShivaVariantcallingTrait
=
{
if
(
multisample
)
new
ShivaVariantcalling
(
qscript
)
{
override
def
namePrefix
=
"multisample"
...
...
@@ -38,27 +42,43 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
}
}
/** Method to make a sample */
def
makeSample
(
id
:
String
)
=
new
Sample
(
id
)
class
Sample
(
sampleId
:
String
)
extends
AbstractSample
(
sampleId
)
{
//TODO: Add summary
def
summaryFiles
:
Map
[
String
,
File
]
=
Map
()
/** Class that will generate jobs for a sample */
class
Sample
(
sampleId
:
String
)
extends
AbstractSample
(
sampleId
)
{
/** Sample specific files to add to summary */
def
summaryFiles
:
Map
[
String
,
File
]
=
{
preProcessBam
match
{
case
Some
(
preProcessBam
)
=>
Map
(
"bamFile"
->
preProcessBam
)
case
_
=>
Map
()
}
}
/
/TODO: Add
summary
/
** Sample specific stats to add to
summary
*/
def
summaryStats
:
Map
[
String
,
Any
]
=
Map
()
/** Method to make a library */
def
makeLibrary
(
id
:
String
)
=
new
Library
(
id
)
/** Class to generate jobs for a library */
class
Library
(
libId
:
String
)
extends
AbstractLibrary
(
libId
)
{
/** Library specific files to add to the summary */
def
summaryFiles
:
Map
[
String
,
File
]
=
{
(
bamFile
,
preProcessBam
)
match
{
case
(
Some
(
bamFile
),
Some
(
preProcessBam
))
=>
Map
(
"bamFile"
->
bamFile
,
"preProcessBam"
->
preProcessBam
)
case
(
Some
(
bamFile
),
_
)
=>
Map
(
"bamFile"
->
bamFile
)
case
_
=>
Map
()
}
}
//TODO: Add summary
def
summaryFiles
:
Map
[
String
,
File
]
=
Map
()
//TODO: Add summary
/** Library specific stats to add to summary */
def
summaryStats
:
Map
[
String
,
Any
]
=
Map
()
/** Method to execute library preprocess */
def
preProcess
(
input
:
File
)
:
Option
[
File
]
=
None
/** Method to make the mapping submodule */
def
makeMapping
=
{
val
mapping
=
new
Mapping
(
qscript
)
mapping
.
sampleId
=
Some
(
sampleId
)
...
...
@@ -87,6 +107,7 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
Some
(
makeVariantcalling
(
multisample
=
false
))
}
else
None
/** This will add jobs for this library */
def
addJobs
()
:
Unit
=
{
(
config
.
contains
(
"R1"
),
config
.
contains
(
"bam"
))
match
{
case
(
true
,
_
)
=>
mapping
.
foreach
(
mapping
=>
{
...
...
@@ -165,6 +186,7 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
}
}
/** This will add jobs for the double preprocessing */
protected
def
addDoublePreProcess
(
input
:
List
[
File
],
isIntermediate
:
Boolean
=
false
)
:
Option
[
File
]
=
{
if
(
input
==
Nil
)
None
else
if
(
input
.
tail
==
Nil
)
{
...
...
@@ -202,6 +224,7 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
Some
(
makeVariantcalling
(
multisample
=
true
))
}
else
None
/** This will add sample jobs */
def
addJobs
()
:
Unit
=
{
addPerLibJobs
()
...
...
@@ -232,6 +255,7 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
Some
(
makeVariantcalling
(
multisample
=
true
))
}
else
None
/** This will add the mutisample variantcalling */
def
addMultiSampleJobs
()
:
Unit
=
{
variantcalling
.
foreach
(
vc
=>
{
vc
.
outputDir
=
new
File
(
outputDir
,
"variantcalling"
)
...
...
@@ -243,9 +267,12 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript {
})
}
/** Location of summary file */
def
summaryFile
=
new
File
(
outputDir
,
"Shiva.summary.json"
)
/** Settings of pipeline for summary */
def
summarySettings
=
Map
()
/** Files for the summary */
def
summaryFiles
=
Map
()
}
public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTrait.scala
View file @
d81585ca
...
...
@@ -24,6 +24,7 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
@Input
(
doc
=
"Bam files (should be deduped bams)"
,
shortName
=
"BAM"
,
required
=
true
)
var
inputBams
:
List
[
File
]
=
Nil
/** Name prefix, can override this methods if neeeded */
def
namePrefix
:
String
=
{
(
sampleId
,
libId
)
match
{
case
(
Some
(
sampleId
),
Some
(
libId
))
=>
sampleId
+
"-"
+
libId
...
...
@@ -32,14 +33,18 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
}
}
/** Executed before script */
def
init
:
Unit
=
{
}
/** Final merged output files of all variantcaller modes */
def
finalFile
=
new
File
(
outputDir
,
namePrefix
+
".final.vcf.gz"
)
def
biopetScript
:
Unit
=
{
val
configCallers
:
Set
[
String
]
=
config
(
"variantcallers"
)
/** Variantcallers requested by the config */
protected
val
configCallers
:
Set
[
String
]
=
config
(
"variantcallers"
)
/** This will add jobs for this pipeline */
def
biopetScript
:
Unit
=
{
for
(
cal
<-
configCallers
)
{
if
(!
callersList
.
exists
(
_
.
name
==
cal
))
BiopetQScript
.
addError
(
"variantcaller '"
+
cal
+
"' does not exist, possible to use: "
+
callersList
.
map
(
_
.
name
).
mkString
(
", "
))
...
...
@@ -77,21 +82,36 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
addSummaryJobs
}
/** Will generate all available variantcallers */
protected
def
callersList
:
List
[
Variantcaller
]
=
List
(
new
Freebayes
,
new
RawVcf
,
new
Bcftools
)
/** General trait for a variantcaller mode */
trait
Variantcaller
{
/** Name of mode, this should also be used in the config */
val
name
:
String
/** Output dir for this mode */
def
outputDir
=
new
File
(
qscript
.
outputDir
,
name
)
/** Prio in merging in the final file */
protected
val
defaultPrio
:
Int
/** Prio from the config */
lazy
val
prio
:
Int
=
config
(
"prio_"
+
name
,
default
=
defaultPrio
)
/** This should add the variantcaller jobs */
def
addJobs
()
/** Final output file of this mode */
def
outputFile
:
File
}
/** default mode of freebayes */
class
Freebayes
extends
Variantcaller
{
val
name
=
"freebayes"
protected
val
defaultPrio
=
7
/** Final output file of this mode */
def
outputFile
=
new
File
(
outputDir
,
namePrefix
+
".freebayes.vcf.gz"
)
def
addJobs
()
{
...
...
@@ -101,7 +121,7 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
fb
.
isIntermediate
=
true
add
(
fb
)
//TODO: need piping for this
//TODO: need piping for this
, see also issue #114
val
bz
=
new
Bgzip
(
qscript
)
bz
.
input
=
List
(
fb
.
outputVcf
)
bz
.
output
=
outputFile
...
...
@@ -114,10 +134,12 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
}
}
/** default mode of bcftools */
class
Bcftools
extends
Variantcaller
{
val
name
=
"bcftools"
protected
val
defaultPrio
=
8
/** Final output file of this mode */
def
outputFile
=
new
File
(
outputDir
,
namePrefix
+
".bcftools.vcf.gz"
)
def
addJobs
()
{
...
...
@@ -143,10 +165,12 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
}
}
/** Makes a vcf file from a mpileup without statistics */
class
RawVcf
extends
Variantcaller
{
val
name
=
"raw"
protected
val
defaultPrio
=
999
/** Final output file of this mode */
def
outputFile
=
new
File
(
outputDir
,
namePrefix
+
".raw.vcf.gz"
)
def
addJobs
()
{
...
...
@@ -179,10 +203,13 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
}
}
/** Location of summary file */
def
summaryFile
=
new
File
(
outputDir
,
"ShivaVariantcalling.summary.json"
)
def
summarySettings
=
Map
()
/** Settings for the summary */
def
summarySettings
=
Map
(
"variantcallers"
->
configCallers
.
toList
)
/** Files for the summary */
def
summaryFiles
:
Map
[
String
,
File
]
=
{
val
callers
:
Set
[
String
]
=
config
(
"variantcallers"
)
callersList
.
filter
(
x
=>
callers
.
contains
(
x
.
name
)).
map
(
x
=>
(
x
.
name
->
x
.
outputFile
)).
toMap
+
(
"final"
->
finalFile
)
...
...
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