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
03737d70
Commit
03737d70
authored
Nov 17, 2015
by
Peter van 't Hof
Browse files
Added test on pipeline name
parent
343ac6e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala
View file @
03737d70
...
...
@@ -31,9 +31,11 @@ trait PipelineCommand extends MainCommand with GatkLogging with ImplicitConversi
* Gets location of compiled class of pipeline
* @return path from classPath to class file
*/
def
pipeline
=
"/"
+
getClass
.
getName
.
stripSuffix
(
"$"
).
replaceAll
(
"\\."
,
"/"
)
+
".class"
def
pipeline
=
"/"
+
getClass
.
getName
.
takeWhile
(
_
!=
'$'
).
replaceAll
(
"\\."
,
"/"
)
+
".class"
def
pipelineName
=
getClass
.
getSimpleName
.
takeWhile
(
_
!=
'$'
).
toLowerCase
def
pipelineName
=
getClass
.
getName
.
takeWhile
(
_
!=
'$'
).
split
(
"\\."
).
last
.
toLowerCase
protected
val
globalConfig
=
Config
.
global
/** Class can be used directly from java with -cp option */
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
...
...
@@ -41,7 +43,7 @@ trait PipelineCommand extends MainCommand with GatkLogging with ImplicitConversi
for
(
t
<-
0
until
argsSize
)
{
if
(
args
(
t
)
==
"-config"
||
args
(
t
)
==
"--config_file"
)
{
if
(
args
.
length
<=
(
t
+
1
))
throw
new
IllegalStateException
(
"-config needs a value: <file>"
)
Config
.
global
.
loadConfigFile
(
new
File
(
args
(
t
+
1
)))
global
Config
.
loadConfigFile
(
new
File
(
args
(
t
+
1
)))
}
if
(
args
(
t
)
==
"-cv"
||
args
(
t
)
==
"--config_value"
)
{
...
...
@@ -52,7 +54,7 @@ trait PipelineCommand extends MainCommand with GatkLogging with ImplicitConversi
val
p
=
v
(
0
).
split
(
":"
)
val
key
=
p
.
last
val
path
=
p
.
dropRight
(
1
).
toList
Config
.
global
.
addValue
(
key
,
value
,
path
)
global
Config
.
addValue
(
key
,
value
,
path
)
}
if
(
args
(
t
)
==
"--logging_level"
||
args
(
t
)
==
"-l"
)
{
...
...
@@ -74,8 +76,8 @@ trait PipelineCommand extends MainCommand with GatkLogging with ImplicitConversi
val
logFile
=
{
val
pipelineName
=
this
.
getClass
.
getSimpleName
.
toLowerCase
.
split
(
"""\$"""
).
head
val
pipelineConfig
=
Config
.
global
.
map
.
getOrElse
(
pipelineName
,
Map
()).
asInstanceOf
[
Map
[
String
,
Any
]]
val
pipelineOutputDir
=
new
File
(
Config
.
global
.
map
.
getOrElse
(
"output_dir"
,
pipelineConfig
.
getOrElse
(
"output_dir"
,
"./"
)).
toString
)
val
pipelineConfig
=
global
Config
.
map
.
getOrElse
(
pipelineName
,
Map
()).
asInstanceOf
[
Map
[
String
,
Any
]]
val
pipelineOutputDir
=
new
File
(
global
Config
.
map
.
getOrElse
(
"output_dir"
,
pipelineConfig
.
getOrElse
(
"output_dir"
,
"./"
)).
toString
)
val
logDir
:
File
=
new
File
(
pipelineOutputDir
,
".log"
)
logDir
.
mkdirs
()
new
File
(
logDir
,
"biopet."
+
BiopetQCommandLine
.
timestamp
+
".log"
)
...
...
@@ -91,7 +93,7 @@ trait PipelineCommand extends MainCommand with GatkLogging with ImplicitConversi
argv
++=
List
(
"--log_to_file"
,
new
File
(
logFile
.
getParentFile
,
"queue."
+
BiopetQCommandLine
.
timestamp
+
".log"
).
getAbsolutePath
)
}
if
(!
args
.
contains
(
"-retry"
)
&&
!
args
.
contains
(
"--retry_failed"
))
{
val
retry
:
Int
=
Config
.
global
(
pipelineName
,
Nil
,
"retry"
,
default
=
5
)
val
retry
:
Int
=
global
Config
(
pipelineName
,
Nil
,
"retry"
,
default
=
5
)
logger
.
info
(
"No retry flag found, "
)
argv
++=
List
(
"-retry"
,
retry
.
toString
)
}
...
...
public/biopet-core/src/test/scala/nl/lumc/sasc/biopet/core/PipelineCommandTest.scala
0 → 100644
View file @
03737d70
package
nl.lumc.sasc.biopet.core
import
nl.lumc.sasc.biopet.utils.config.Config
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.Test
/**
* Created by pjvanthof on 17/11/15.
*/
class
PipelineCommandTest
extends
TestNGSuite
with
Matchers
{
@Test
def
testPipelineCommand
:
Unit
=
{
val
pipeline
=
new
PipelineCommand
{
override
val
globalConfig
=
new
Config
(
Map
())
def
getConfig
=
globalConfig
}
pipeline
.
pipelineName
shouldBe
this
.
getClass
.
getSimpleName
.
toLowerCase
pipeline
.
pipeline
shouldBe
s
"/${this.getClass.getName.stripSuffix("
$
").replaceAll("
\\.
", "
/
")}.class"
// Config should be emty if the main method is not yet touched
pipeline
.
getConfig
.
map
shouldBe
empty
//TODO: Main method testing
}
}
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