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
6efe0956
Commit
6efe0956
authored
Sep 19, 2016
by
bow
Browse files
Merge branch 'feature-precommands' into 'develop'
Adding precommands See merge request !450
parents
a37fabe7
12d64615
Changes
1
Hide whitespace changes
Inline
Side-by-side
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala
View file @
6efe0956
...
@@ -18,7 +18,7 @@ import java.io.{ File, FileInputStream, PrintWriter }
...
@@ -18,7 +18,7 @@ import java.io.{ File, FileInputStream, PrintWriter }
import
java.security.MessageDigest
import
java.security.MessageDigest
import
nl.lumc.sasc.biopet.utils.Logging
import
nl.lumc.sasc.biopet.utils.Logging
import
org.broadinstitute.gatk.utils.commandline.
{
Gather
,
Input
,
Output
}
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
}
import
org.broadinstitute.gatk.utils.runtime.ProcessSettings
import
org.broadinstitute.gatk.utils.runtime.ProcessSettings
import
org.ggf.drmaa.JobTemplate
import
org.ggf.drmaa.JobTemplate
...
@@ -40,6 +40,8 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
...
@@ -40,6 +40,8 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
def
defaultRemoteCommand
=
"bash"
def
defaultRemoteCommand
=
"bash"
private
val
remoteCommand
:
String
=
config
(
"remote_command"
,
default
=
defaultRemoteCommand
)
private
val
remoteCommand
:
String
=
config
(
"remote_command"
,
default
=
defaultRemoteCommand
)
val
preCommands
:
List
[
String
]
=
config
(
"pre_commands"
,
default
=
Nil
,
freeVar
=
false
)
private
def
changeScript
(
file
:
File
)
:
Unit
=
{
private
def
changeScript
(
file
:
File
)
:
Unit
=
{
val
lines
=
Source
.
fromFile
(
file
).
getLines
().
toList
val
lines
=
Source
.
fromFile
(
file
).
getLines
().
toList
val
writer
=
new
PrintWriter
(
file
)
val
writer
=
new
PrintWriter
(
file
)
...
@@ -111,7 +113,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
...
@@ -111,7 +113,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
* Checks executable. Follow full CanonicalPath, checks if it is existing and do a md5sum on it to store in job report
* 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
()
{
protected
[
core
]
def
preProcessExecutable
()
{
val
exe
=
BiopetCommandLineFunction
.
preProcessExecutable
(
executable
)
val
exe
=
BiopetCommandLineFunction
.
preProcessExecutable
(
executable
,
preCommands
)
exe
.
path
.
foreach
(
executable
=
_
)
exe
.
path
.
foreach
(
executable
=
_
)
addJobReportBinding
(
"md5sum_exe"
,
exe
.
md5
.
getOrElse
(
"N/A"
))
addJobReportBinding
(
"md5sum_exe"
,
exe
.
md5
.
getOrElse
(
"N/A"
))
}
}
...
@@ -219,7 +221,8 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
...
@@ -219,7 +221,8 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
*/
*/
override
final
def
commandLine
:
String
=
{
override
final
def
commandLine
:
String
=
{
preCmdInternal
()
preCmdInternal
()
val
cmd
=
cmdLine
+
val
cmd
=
preCommands
.
mkString
(
"\n"
,
"\n"
,
"\n"
)
+
cmdLine
+
stdinFile
.
map
(
file
=>
" < "
+
required
(
file
.
getAbsoluteFile
)).
getOrElse
(
""
)
+
stdinFile
.
map
(
file
=>
" < "
+
required
(
file
.
getAbsoluteFile
)).
getOrElse
(
""
)
+
stdoutFile
.
map
(
file
=>
" > "
+
required
(
file
.
getAbsoluteFile
)).
getOrElse
(
""
)
stdoutFile
.
map
(
file
=>
" > "
+
required
(
file
.
getAbsoluteFile
)).
getOrElse
(
""
)
addJobReportBinding
(
"command"
,
cmd
)
addJobReportBinding
(
"command"
,
cmd
)
...
@@ -240,13 +243,18 @@ object BiopetCommandLineFunction extends Logging {
...
@@ -240,13 +243,18 @@ object BiopetCommandLineFunction extends Logging {
private
[
core
]
val
executableCache
:
mutable.Map
[
String
,
String
]
=
mutable
.
Map
()
private
[
core
]
val
executableCache
:
mutable.Map
[
String
,
String
]
=
mutable
.
Map
()
case
class
Executable
(
path
:
Option
[
String
],
md5
:
Option
[
String
])
case
class
Executable
(
path
:
Option
[
String
],
md5
:
Option
[
String
])
def
preProcessExecutable
(
executable
:
String
)
:
Executable
=
{
def
preProcessExecutable
(
executable
:
String
,
pre_commands
:
List
[
String
]
=
Nil
)
:
Executable
=
{
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
if
(
executable
!=
null
)
{
if
(
executable
!=
null
)
{
if
(!
BiopetCommandLineFunction
.
executableCache
.
contains
(
executable
))
{
if
(!
BiopetCommandLineFunction
.
executableCache
.
contains
(
executable
))
{
try
{
try
{
val
buffer
=
new
StringBuffer
()
val
buffer
=
new
StringBuffer
()
val
cmd
=
Seq
(
"which"
,
executable
)
val
tempFile
=
File
.
createTempFile
(
"which."
,
".sh"
)
val
writer
=
new
PrintWriter
(
tempFile
)
pre_commands
.
foreach
(
cmd
=>
writer
.
println
(
cmd
+
" > /dev/null 2> /dev/null"
))
writer
.
println
(
s
"which $executable"
)
writer
.
close
()
val
cmd
=
Seq
(
"bash"
,
tempFile
.
getAbsolutePath
)
val
process
=
Process
(
cmd
).
run
(
ProcessLogger
(
buffer
.
append
(
_
)))
val
process
=
Process
(
cmd
).
run
(
ProcessLogger
(
buffer
.
append
(
_
)))
if
(
process
.
exitValue
==
0
)
{
if
(
process
.
exitValue
==
0
)
{
val
file
=
new
File
(
buffer
.
toString
)
val
file
=
new
File
(
buffer
.
toString
)
...
...
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