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
667373b2
Commit
667373b2
authored
Feb 05, 2015
by
Peter van 't Hof
Browse files
Added some scala docs
parent
1a870a62
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala
View file @
667373b2
...
...
@@ -15,8 +15,21 @@
*/
package
nl.lumc.sasc.biopet.core
/**
* This class is for commandline programs where the executable is a non JVM based program
*/
abstract
class
BiopetCommandLineFunction
extends
BiopetCommandLineFunctionTrait
{
/**
* This function needs to be implemented to define the command that is executed
* @return Command to run
*/
protected
def
cmdLine
:
String
/**
* implementing a final version of the commandLine from org.broadinstitute.gatk.queue.function.CommandLineFunction
* User needs to implement cmdLine instead
* @return Command to run
*/
final
def
commandLine
:
String
=
{
preCmdInternal
val
cmd
=
cmdLine
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala
View file @
667373b2
...
...
@@ -27,29 +27,38 @@ import scala.util.matching.Regex
import
java.io.FileInputStream
import
java.security.MessageDigest
/**
* Biopet command line trait to auto check executable and cluster values
*/
trait
BiopetCommandLineFunctionTrait
extends
CommandLineFunction
with
Configurable
{
analysisName
=
configName
@Input
(
doc
=
"deps"
,
required
=
false
)
var
deps
:
List
[
File
]
=
Nil
@Argument
(
doc
=
"Threads"
,
required
=
false
)
var
threads
=
0
val
defaultThreads
=
1
@Argument
(
doc
=
"Vmem"
,
required
=
false
)
var
vmem
:
Option
[
String
]
=
None
val
defaultVmem
:
String
=
""
@Argument
(
doc
=
"Executable"
,
required
=
false
)
var
executable
:
String
=
_
protected
[
core
]
def
beforeCmd
{
}
protected
[
core
]
def
afterGraph
{
}
/**
* Can override this method. This is executed just before the job is ready to run.
* Can check on run time files from pipeline here
*/
protected
[
core
]
def
beforeCmd
{
}
/**
* Can override this method. This is executed after the script is done en queue starts to generate the graph
*/
protected
[
core
]
def
afterGraph
{
}
//TODO: function need rename to beforeGraph
/**
* Set default output file, threads and vmem for current job
*/
override
def
freezeFieldValues
()
{
checkExecutable
afterGraph
...
...
@@ -68,6 +77,9 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
super
.
freezeFieldValues
()
}
/**
* Checks executable. Follow full CanonicalPath, checks if it is existing and do a md5sum on it to store in job report
*/
protected
def
checkExecutable
{
if
(!
BiopetCommandLineFunctionTrait
.
executableMd5Cache
.
contains
(
executable
))
{
try
if
(
executable
!=
null
)
{
...
...
@@ -108,6 +120,9 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
else
addJobReportBinding
(
"md5sum_exe"
,
"None"
)
}
/**
* executes checkExecutable method and fill job report
*/
final
protected
def
preCmdInternal
{
checkExecutable
...
...
@@ -117,9 +132,19 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
addJobReportBinding
(
"version"
,
getVersion
)
}
/**
* Command to get version of executable
* @return
*/
protected
def
versionCommand
:
String
=
null
/** Regex to get version from version command output */
protected
val
versionRegex
:
Regex
=
null
protected
val
versionExitcode
=
List
(
0
)
// Can select multiple
/** Allowed exit codes for the version command */
protected
val
versionExitcode
=
List
(
0
)
/** Executes the version command */
private
def
getVersionInternal
:
String
=
{
if
(
versionCommand
==
null
||
versionRegex
==
null
)
return
"N/A"
val
stdout
=
new
StringBuffer
()
...
...
@@ -142,12 +167,18 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
return
"N/A"
}
/** Get version from cache otherwise execute the version command */
def
getVersion
:
String
=
{
if
(!
BiopetCommandLineFunctionTrait
.
versionCache
.
contains
(
executable
))
BiopetCommandLineFunctionTrait
.
versionCache
+=
executable
->
getVersionInternal
return
BiopetCommandLineFunctionTrait
.
versionCache
(
executable
)
}
/**
* Get threads from config
* @param default default when not found in config
* @return number of threads
*/
def
getThreads
(
default
:
Int
)
:
Int
=
{
val
maxThreads
:
Int
=
config
(
"maxthreads"
,
default
=
8
)
val
threads
:
Int
=
config
(
"threads"
,
default
=
default
)
...
...
@@ -155,6 +186,12 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
else
return
maxThreads
}
/**
* Get threads from config
* @param default default when not found in config
* @param module Module when this is difrent from default
* @return number of threads
*/
def
getThreads
(
default
:
Int
,
module
:
String
)
:
Int
=
{
val
maxThreads
:
Int
=
config
(
"maxthreads"
,
default
=
8
,
submodule
=
module
)
val
threads
:
Int
=
config
(
"threads"
,
default
=
default
,
submodule
=
module
)
...
...
@@ -163,6 +200,9 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
}
}
/**
* stores global caches
*/
object
BiopetCommandLineFunctionTrait
{
import
scala.collection.mutable.Map
private
val
versionCache
:
Map
[
String
,
String
]
=
Map
()
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/Logging.scala
View file @
667373b2
...
...
@@ -17,10 +17,20 @@ package nl.lumc.sasc.biopet.core
import
org.apache.log4j.Logger
/**
* Trait to implement logger function on local class/object
*/
trait
Logging
{
/**
*
* @return Global biopet logger
*/
def
logger
=
Logging
.
logger
}
/**
* Logger object, has a global logger
*/
object
Logging
{
val
logger
=
Logger
.
getRootLogger
}
\ No newline at end of file
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