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
311e596b
Commit
311e596b
authored
Oct 26, 2015
by
Peter van 't Hof
Browse files
Move Executable function outside of class
parent
595e482d
Changes
2
Hide whitespace changes
Inline
Side-by-side
protected/biopet-gatk-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/gatk/broad/GatkGeneral.scala
View file @
311e596b
...
...
@@ -5,13 +5,15 @@
*/
package
nl.lumc.sasc.biopet.extensions.gatk.broad
import
nl.lumc.sasc.biopet.core.
{
Version
,
CommandLineResources
,
Reference
,
BiopetJavaCommandLineFunction
}
import
nl.lumc.sasc.biopet.core.
_
import
org.broadinstitute.gatk.engine.phonehome.GATKRunReport
import
org.broadinstitute.gatk.queue.extensions.gatk.CommandLineGATK
trait
GatkGeneral
extends
CommandLineGATK
with
CommandLineResources
with
Reference
with
Version
{
memoryLimit
=
Option
(
3
)
var
executable
:
String
=
config
(
"java"
,
default
=
"java"
,
submodule
=
"java"
,
freeVar
=
false
)
override
def
subPath
=
"gatk"
::
super
.
subPath
jarFile
=
config
(
"gatk_jar"
)
...
...
@@ -20,6 +22,7 @@ trait GatkGeneral extends CommandLineGATK with CommandLineResources with Referen
override
def
defaultCoreMemory
=
4.0
override
def
faiRequired
=
true
override
def
dictRequired
=
true
if
(
config
.
contains
(
"intervals"
))
intervals
=
config
(
"intervals"
).
asFileList
if
(
config
.
contains
(
"exclude_intervals"
))
excludeIntervals
=
config
(
"exclude_intervals"
).
asFileList
...
...
@@ -39,5 +42,8 @@ trait GatkGeneral extends CommandLineGATK with CommandLineResources with Referen
override
def
versionExitcode
=
List
(
0
,
1
)
def
versionCommand
=
"java"
+
" -jar "
+
jarFile
+
" -version"
override
def
getVersion
=
super
.
getVersion
.
collect
{
case
v
=>
"Gatk "
+
v
}
override
def
getVersion
=
{
executable
=
BiopetCommandLineFunction
.
preProcessExecutable
(
executable
).
path
super
.
getVersion
.
collect
{
case
v
=>
"Gatk "
+
v
}
}
}
public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala
View file @
311e596b
...
...
@@ -91,50 +91,19 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
}
/** can override this value is executable may not be converted to CanonicalPath */
/**
* Can override this value is executable may not be converted to CanonicalPath
* @deprecated
*/
val
executableToCanonicalPath
=
true
/**
* Checks executable. Follow full CanonicalPath, checks if it is existing and do a md5sum on it to store in job report
*/
protected
[
core
]
def
preProcessExecutable
()
{
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
if
(
executable
!=
null
)
{
if
(!
BiopetCommandLineFunction
.
executableCache
.
contains
(
executable
))
{
try
{
val
oldExecutable
=
executable
val
buffer
=
new
StringBuffer
()
val
cmd
=
Seq
(
"which"
,
executable
)
val
process
=
Process
(
cmd
).
run
(
ProcessLogger
(
buffer
.
append
(
_
)))
if
(
process
.
exitValue
==
0
)
{
executable
=
buffer
.
toString
val
file
=
new
File
(
executable
)
if
(
executableToCanonicalPath
)
executable
=
file
.
getCanonicalPath
else
executable
=
file
.
getAbsolutePath
}
else
Logging
.
addError
(
"executable: '"
+
executable
+
"' not found, please check config"
)
BiopetCommandLineFunction
.
executableCache
+=
oldExecutable
->
executable
BiopetCommandLineFunction
.
executableCache
+=
executable
->
executable
}
catch
{
case
ioe
:
java.io.IOException
=>
logger
.
warn
(
s
"Could not use 'which' on '$executable', check on executable skipped: "
+
ioe
)
}
}
else
executable
=
BiopetCommandLineFunction
.
executableCache
(
executable
)
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
if
(
new
File
(
executable
).
exists
())
{
val
is
=
new
FileInputStream
(
executable
)
val
cnt
=
is
.
available
val
bytes
=
Array
.
ofDim
[
Byte
](
cnt
)
is
.
read
(
bytes
)
is
.
close
()
val
temp
=
MessageDigest
.
getInstance
(
"MD5"
).
digest
(
bytes
).
map
(
"%02X"
.
format
(
_
)).
mkString
.
toLowerCase
BiopetCommandLineFunction
.
executableMd5Cache
+=
executable
->
temp
}
else
BiopetCommandLineFunction
.
executableMd5Cache
+=
executable
->
"file_does_not_exist"
}
}
}
val
md5
=
BiopetCommandLineFunction
.
executableMd5Cache
.
get
(
executable
)
addJobReportBinding
(
"md5sum_exe"
,
md5
.
getOrElse
(
"None"
))
val
exe
=
BiopetCommandLineFunction
.
preProcessExecutable
(
executable
)
executable
=
exe
.
path
addJobReportBinding
(
"md5sum_exe"
,
exe
.
md5
.
getOrElse
(
"N/A"
))
}
/** executes checkExecutable method and fill job report */
...
...
@@ -230,7 +199,49 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
}
/** stores global caches */
object
BiopetCommandLineFunction
{
object
BiopetCommandLineFunction
extends
Logging
{
private
[
core
]
val
executableMd5Cache
:
mutable.Map
[
String
,
String
]
=
mutable
.
Map
()
private
[
core
]
val
executableCache
:
mutable.Map
[
String
,
String
]
=
mutable
.
Map
()
private
case
class
Executable
(
path
:
String
,
md5
:
Option
[
String
])
def
preProcessExecutable
(
executable
:
String
)
:
Executable
=
{
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
if
(
executable
!=
null
)
{
if
(!
BiopetCommandLineFunction
.
executableCache
.
contains
(
executable
))
{
try
{
val
oldExecutable
=
executable
val
buffer
=
new
StringBuffer
()
val
cmd
=
Seq
(
"which"
,
executable
)
val
process
=
Process
(
cmd
).
run
(
ProcessLogger
(
buffer
.
append
(
_
)))
if
(
process
.
exitValue
==
0
)
{
val
file
=
new
File
(
buffer
.
toString
)
BiopetCommandLineFunction
.
executableCache
+=
executable
->
file
.
getAbsolutePath
}
else
{
Logging
.
addError
(
"executable: '"
+
executable
+
"' not found, please check config"
)
BiopetCommandLineFunction
.
executableCache
+=
executable
->
executable
}
}
catch
{
case
ioe
:
java.io.IOException
=>
logger
.
warn
(
s
"Could not use 'which' on '$executable', check on executable skipped: "
+
ioe
)
BiopetCommandLineFunction
.
executableCache
+=
executable
->
executable
}
}
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
val
newExe
=
BiopetCommandLineFunction
.
executableCache
(
executable
)
if
(
new
File
(
newExe
).
exists
())
{
val
is
=
new
FileInputStream
(
executable
)
val
cnt
=
is
.
available
val
bytes
=
Array
.
ofDim
[
Byte
](
cnt
)
is
.
read
(
bytes
)
is
.
close
()
val
temp
=
MessageDigest
.
getInstance
(
"MD5"
).
digest
(
bytes
).
map
(
"%02X"
.
format
(
_
)).
mkString
.
toLowerCase
BiopetCommandLineFunction
.
executableMd5Cache
+=
newExe
->
temp
}
else
BiopetCommandLineFunction
.
executableMd5Cache
+=
newExe
->
"file_does_not_exist"
}
}
}
Executable
(
BiopetCommandLineFunction
.
executableCache
(
executable
),
BiopetCommandLineFunction
.
executableMd5Cache
.
get
(
executable
))
}
}
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