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
5153a1fb
Commit
5153a1fb
authored
Apr 06, 2015
by
Peter van 't Hof
Browse files
Added commandline support for config
parent
2d1626f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala
View file @
5153a1fb
...
...
@@ -30,9 +30,12 @@ import scala.collection.mutable.ListBuffer
*/
trait
BiopetQScript
extends
Configurable
with
GatkLogging
{
@Argument
(
doc
=
"JSON config file(s)"
,
fullName
=
"config_file"
,
shortName
=
"config"
,
required
=
false
)
@Argument
(
doc
=
"JSON
/ YAML
config file(s)"
,
fullName
=
"config_file"
,
shortName
=
"config"
,
required
=
false
)
val
configfiles
:
List
[
File
]
=
Nil
@Argument
(
doc
=
"JSON config file(s)"
,
fullName
=
"config_value"
,
shortName
=
"cv"
,
required
=
false
)
val
configValues
:
List
[
String
]
=
Nil
var
outputDir
:
File
=
{
Config
.
getValueFromMap
(
globalConfig
.
map
,
ConfigValueIndex
(
this
.
configName
,
configPath
,
"output_dir"
))
match
{
case
Some
(
value
)
=>
new
File
(
value
.
asString
).
getAbsoluteFile
...
...
@@ -61,7 +64,11 @@ trait BiopetQScript extends Configurable with GatkLogging {
* Script from queue itself, final to force some checks for each pipeline and write report
*/
final
def
script
()
{
outputDir
=
config
(
"output_dir"
).
asFile
.
getAbsoluteFile
if
(
config
.
contains
(
"output_dir"
))
outputDir
=
config
(
"output_dir"
).
asFile
.
getAbsoluteFile
else
{
outputDir
=
new
File
(
"."
).
getAbsoluteFile
BiopetQScript
.
addError
(
"No output_dir defined in config"
)
}
init
biopetScript
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala
View file @
5153a1fb
...
...
@@ -42,6 +42,17 @@ trait PipelineCommand extends MainCommand with GatkLogging {
if
(
t
>=
argsSize
)
throw
new
IllegalStateException
(
"-config needs a value"
)
Config
.
global
.
loadConfigFile
(
new
File
(
args
(
t
+
1
)))
}
if
(
args
(
t
)
==
"-cv"
||
args
(
t
)
==
"--config_value"
)
{
val
v
=
args
(
t
+
1
).
split
(
"="
)
require
(
v
.
size
==
2
,
"Value should be formatted like 'key=value' or 'path:path:key=value'"
)
val
value
=
v
(
1
)
val
p
=
v
(
0
).
split
(
":"
)
val
key
=
p
.
last
val
path
=
p
.
dropRight
(
1
).
toList
Config
.
global
.
addValue
(
key
,
value
,
path
)
}
if
(
args
(
t
)
==
"--logging_level"
||
args
(
t
)
==
"-l"
)
{
args
(
t
+
1
).
toLowerCase
match
{
case
"debug"
=>
Logging
.
logger
.
setLevel
(
org
.
apache
.
log4j
.
Level
.
DEBUG
)
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala
View file @
5153a1fb
...
...
@@ -79,6 +79,19 @@ class Config(var map: Map[String, Any],
}
}
/**
* Add a single vallue to the config
* @param key key of value
* @param value value itself
* @param path Path to value
* @param default if true value is put in default map
*/
def
addValue
(
key
:
String
,
value
:
Any
,
path
:
List
[
String
]
=
Nil
,
default
:
Boolean
=
false
)
:
Unit
=
{
val
valueMap
=
path
.
foldRight
(
Map
(
key
->
value
))((
a
,
b
)
=>
Map
(
a
->
b
))
if
(
default
)
defaults
=
mergeMaps
(
valueMap
,
defaults
)
else
map
=
mergeMaps
(
valueMap
,
map
)
}
protected
[
config
]
var
notFoundCache
:
List
[
ConfigValueIndex
]
=
List
()
protected
[
config
]
var
foundCache
:
Map
[
ConfigValueIndex
,
ConfigValue
]
=
Map
()
protected
[
config
]
var
defaultCache
:
Map
[
ConfigValueIndex
,
ConfigValue
]
=
Map
()
...
...
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