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
cb103a38
Commit
cb103a38
authored
Jan 04, 2017
by
Peter van 't Hof
Browse files
Added gentrap template
parent
921de0c8
Changes
6
Hide whitespace changes
Inline
Side-by-side
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/package.scala
View file @
cb103a38
...
...
@@ -100,4 +100,28 @@ package object utils {
case
_
=>
None
}
}
/** Converts string with underscores into camel-case strings */
def
camelize
(
ustring
:
String
)
:
String
=
ustring
.
split
(
"_"
)
.
map
(
_
.
toLowerCase
.
capitalize
)
.
mkString
(
""
)
/** Split camelcase to separated words */
def
camelizeToWords
(
string
:
String
,
current
:
List
[
String
]
=
Nil
)
:
List
[
String
]
=
{
if
(
string
.
nonEmpty
)
{
val
char
=
string
.
tail
.
find
(!
_
.
isLower
)
char
match
{
case
Some
(
c
)
=>
val
index
=
string
.
indexOf
(
c
,
1
)
camelizeToWords
(
string
.
drop
(
index
),
current
:::
List
(
string
.
take
(
index
)))
case
_
=>
current
:::
List
(
string
)
}
}
else
current
}
/** Convert camelcase to underscores */
def
unCamelize
(
string
:
String
)
:
String
=
{
camelizeToWords
(
string
).
map
(
_
.
toLowerCase
).
mkString
(
"_"
)
}
}
gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala
View file @
cb103a38
...
...
@@ -24,6 +24,7 @@ import nl.lumc.sasc.biopet.pipelines.mapping.MultisampleMappingTrait
import
nl.lumc.sasc.biopet.pipelines.shiva.ShivaVariantcalling
import
nl.lumc.sasc.biopet.utils.
{
LazyCheck
,
Logging
}
import
nl.lumc.sasc.biopet.utils.config._
import
nl.lumc.sasc.biopet.utils.camelize
import
org.broadinstitute.gatk.queue.QScript
import
picard.analysis.directed.RnaSeqMetricsCollector.StrandSpecificity
import
java.io.File
...
...
@@ -54,7 +55,7 @@ class Gentrap(val root: Configurable) extends QScript
// see the enumeration below for valid modes
lazy
val
expMeasures
=
new
LazyCheck
({
config
(
"expression_measures"
,
default
=
Nil
).
asStringList
.
map
(
value
=>
ExpMeasures
.
values
.
find
(
_
.
toString
==
Gentrap
.
camelize
(
value
))
match
{
ExpMeasures
.
values
.
find
(
_
.
toString
==
camelize
(
value
))
match
{
case
Some
(
v
)
=>
v
case
_
=>
throw
new
IllegalArgumentException
(
s
"'$value' is not a valid Expression measurement"
)
}
...
...
@@ -64,7 +65,7 @@ class Gentrap(val root: Configurable) extends QScript
/** Strandedness modes */
lazy
val
strandProtocol
=
new
LazyCheck
({
val
value
:
String
=
config
(
"strand_protocol"
)
StrandProtocol
.
values
.
find
(
_
.
toString
==
Gentrap
.
camelize
(
value
))
match
{
StrandProtocol
.
values
.
find
(
_
.
toString
==
camelize
(
value
))
match
{
case
Some
(
v
)
=>
v
case
other
=>
Logging
.
addError
(
s
"'$other' is no strand_protocol or strand_protocol is not given"
)
...
...
@@ -240,7 +241,7 @@ object Gentrap extends PipelineCommand {
/** Enumeration of available expression measures */
object
ExpMeasures
extends
Enumeration
{
val
FragmentsPerGene
,
FragmentsPerExon
,
BaseCounts
,
CufflinksStrict
,
CufflinksGuided
,
CufflinksBlind
=
Value
val
FragmentsPerGene
,
BaseCounts
,
CufflinksStrict
,
CufflinksGuided
,
CufflinksBlind
=
Value
}
/** Enumeration of available strandedness */
...
...
@@ -248,10 +249,4 @@ object Gentrap extends PipelineCommand {
// for now, only non-strand specific and dUTP stranded protocol is supported
val
NonSpecific
,
Dutp
=
Value
}
/** Converts string with underscores into camel-case strings */
private
[
gentrap
]
def
camelize
(
ustring
:
String
)
:
String
=
ustring
.
split
(
"_"
)
.
map
(
_
.
toLowerCase
.
capitalize
)
.
mkString
(
""
)
}
gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/template/Gentrap.scala
0 → 100644
View file @
cb103a38
package
nl.lumc.sasc.biopet.pipelines.gentrap.template
import
java.io.File
import
nl.lumc.sasc.biopet.core.TemplateTool
import
nl.lumc.sasc.biopet.pipelines.gentrap.Gentrap.
{
ExpMeasures
,
StrandProtocol
}
import
nl.lumc.sasc.biopet.pipelines.mapping.template.MultiSampleMapping
import
nl.lumc.sasc.biopet.pipelines.shiva.template.Shiva
import
nl.lumc.sasc.biopet.utils._
/**
* Created by pjvanthof on 17/12/2016.
*/
object
Gentrap
extends
TemplateTool
{
override
lazy
val
sampleConfigs
:
List
[
File
]
=
TemplateTool
.
askSampleConfigs
()
def
pipelineMap
(
map
:
Map
[
String
,
Any
],
expert
:
Boolean
)
:
Map
[
String
,
Any
]
=
{
val
aligner
=
Question
.
string
(
"Aligner"
,
posibleValues
=
MultiSampleMapping
.
possibleAligners
,
default
=
Some
(
"gsnap"
))
val
mappingConfig
=
MultiSampleMapping
.
pipelineMap
(
map
++
Map
(
"aligner"
->
aligner
),
expert
)
val
expressionMeasures
=
Question
.
list
(
"ExpressionMeasures"
,
posibleValues
=
ExpMeasures
.
values
.
map
(
x
=>
unCamelize
(
x
.
toString
)).
toList
)
val
strandProtocol
=
Question
.
list
(
"StrandProtocol"
,
posibleValues
=
StrandProtocol
.
values
.
map
(
x
=>
unCamelize
(
x
.
toString
)).
toList
)
val
annotationRefFlat
=
Question
.
string
(
"annotationRefFlat"
,
validation
=
List
(
TemplateTool
.
isAbsolutePath
,
TemplateTool
.
mustExist
))
val
annotationGtf
=
if
(
expressionMeasures
.
contains
(
unCamelize
(
ExpMeasures
.
FragmentsPerGene
.
toString
))
||
expressionMeasures
.
exists
(
_
.
startsWith
(
"cufflinks"
)))
Some
(
Question
.
string
(
"annotationGtf"
,
validation
=
List
(
TemplateTool
.
isAbsolutePath
,
TemplateTool
.
mustExist
)))
else
None
mappingConfig
++
annotationGtf
.
map
(
"annotation_gtf"
->
_
)
++
Map
(
"expression_measures"
->
expressionMeasures
,
"strand_protocol"
->
strandProtocol
,
"annotation_refflat"
->
annotationRefFlat
)
++
(
if
(
Question
.
boolean
(
"Call variants"
))
{
val
variantCallers
=
Question
.
list
(
"Variantcallers"
,
posibleValues
=
Shiva
.
possibleVariantcallers
,
default
=
Some
(
List
(
"varscan_cns_singlesample"
)))
Map
(
"call_variants"
->
true
,
"variantcallers"
->
variantCallers
)
}
else
Map
(
"call_variants"
->
false
))
}
}
gentrap/src/test/scala/nl/lumc/sasc/biopet/pipelines/gentrap/GentrapTest.scala
View file @
cb103a38
...
...
@@ -24,6 +24,7 @@ import nl.lumc.sasc.biopet.extensions.hisat.Hisat2
import
nl.lumc.sasc.biopet.extensions.tools.
{
BaseCounter
,
WipeReads
}
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
Logging
}
import
nl.lumc.sasc.biopet.utils.config.Config
import
nl.lumc.sasc.biopet.utils.camelize
import
org.broadinstitute.gatk.queue.QSettings
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
...
...
@@ -97,10 +98,10 @@ abstract class GentrapTestAbstract(val expressionMeasures: List[String]) extends
gentrap
.
shivaVariantcalling
.
isDefined
shouldBe
callVariants
.
getOrElse
(
false
)
gentrap
.
summarySettings
.
getOrElse
(
"expression_measures"
,
List
()).
asInstanceOf
[
List
[
String
]].
sorted
shouldBe
expressionMeasures
.
map
(
Gentrap
.
camelize
(
_
)).
sorted
expressionMeasures
.
map
(
camelize
(
_
)).
sorted
gentrap
.
summarySettings
.
get
(
"call_variants"
)
shouldBe
Some
(
callVariants
.
getOrElse
(
false
))
gentrap
.
summarySettings
.
get
(
"remove_ribosomal_reads"
)
shouldBe
Some
(
removeRiboReads
.
getOrElse
(
false
))
gentrap
.
summarySettings
.
get
(
"strand_protocol"
)
shouldBe
Some
(
Gentrap
.
camelize
(
strandProtocol
))
gentrap
.
summarySettings
.
get
(
"strand_protocol"
)
shouldBe
Some
(
camelize
(
strandProtocol
))
if
(
expressionMeasures
.
contains
(
"fragments_per_gene"
))
assert
(
gentrap
.
functions
.
exists
(
_
.
isInstanceOf
[
HtseqCount
]))
...
...
mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/template/MultiSampleMapping.scala
View file @
cb103a38
...
...
@@ -20,7 +20,7 @@ object MultiSampleMapping extends TemplateTool {
val
aligner
=
if
(
map
.
contains
(
"aligner"
))
map
(
"aligner"
).
toString
else
Question
.
string
(
"Aligner"
,
posibleValues
=
possibleAligners
,
default
=
Some
(
"bwa-mem"
))
val
mappingToGears
=
Question
.
string
(
"
Aligner
"
,
posibleValues
=
List
(
"none"
,
"all"
,
"unmapped"
),
default
=
Some
(
"none"
))
val
mappingToGears
=
Question
.
string
(
"
Reads to process in metagenomics pipeline
"
,
posibleValues
=
List
(
"none"
,
"all"
,
"unmapped"
),
default
=
Some
(
"none"
))
referenceConfig
++
Map
(
"aligner"
->
aligner
,
...
...
shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcalling.scala
View file @
cb103a38
...
...
@@ -179,7 +179,7 @@ class ShivaVariantcalling(val root: Configurable) extends QScript
object
ShivaVariantcalling
extends
PipelineCommand
{
/** Will generate all available variantcallers */
protected
[
shiva
]
def
callersList
(
root
:
Configurable
)
:
List
[
Variantcaller
]
=
protected
[
pipelines
]
def
callersList
(
root
:
Configurable
)
:
List
[
Variantcaller
]
=
new
HaplotypeCallerGvcf
(
root
)
::
new
HaplotypeCallerAllele
(
root
)
::
new
UnifiedGenotyperAllele
(
root
)
::
...
...
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