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
7d112c68
Commit
7d112c68
authored
Sep 13, 2015
by
Peter van 't Hof
Browse files
Rscript usable without core now
parent
c4c8292b
Changes
18
Hide whitespace changes
Inline
Side-by-side
public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BammetricsReport.scala
View file @
7d112c68
...
...
@@ -20,7 +20,7 @@ import java.io.{ File, PrintWriter }
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core.report.
{
ReportBuilderExtension
,
ReportBuilder
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.core.summary.
{
Summary
,
SummaryValue
}
import
nl.lumc.sasc.biopet.
extension
s.rscript.
{
StackedBarPlot
,
LinePlot
}
import
nl.lumc.sasc.biopet.
util
s.rscript.
{
StackedBarPlot
,
LinePlot
}
class
BammetricsReport
(
val
root
:
Configurable
)
extends
ReportBuilderExtension
{
val
builder
=
BammetricsReport
...
...
public/biopet-core/src/main/resources/nl/lumc/sasc/biopet/
extension
s/rscript/plotScatter.R
→
public/biopet-core/src/main/resources/nl/lumc/sasc/biopet/
util
s/rscript/plotScatter.R
View file @
7d112c68
File moved
public/biopet-core/src/main/resources/nl/lumc/sasc/biopet/
extension
s/rscript/plotXY.R
→
public/biopet-core/src/main/resources/nl/lumc/sasc/biopet/
util
s/rscript/plotXY.R
View file @
7d112c68
File moved
public/biopet-core/src/main/resources/nl/lumc/sasc/biopet/
extension
s/rscript/stackedBar.R
→
public/biopet-core/src/main/resources/nl/lumc/sasc/biopet/
util
s/rscript/stackedBar.R
View file @
7d112c68
File moved
public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/extensions/PythonCommandLineFunction.scala
View file @
7d112c68
...
...
@@ -15,7 +15,7 @@
*/
package
nl.lumc.sasc.biopet.core.extensions
import
java.io.
{
File
,
FileOutputStream
}
import
java.io.
{
File
,
FileOutputStream
}
import
nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import
org.broadinstitute.gatk.utils.commandline.Input
...
...
public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/extensions/RscriptCommandLineFunction.scala
View file @
7d112c68
...
...
@@ -15,9 +15,10 @@
*/
package
nl.lumc.sasc.biopet.core.extensions
import
java.io.
{
File
,
FileOutputStream
}
import
java.io.
{
File
,
FileOutputStream
}
import
nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import
nl.lumc.sasc.biopet.utils.rscript.Rscript
import
scala.sys.process._
...
...
@@ -26,67 +27,13 @@ import scala.sys.process._
*
* Created by wyleung on 17-2-15.
*/
trait
RscriptCommandLineFunction
extends
BiopetCommandLineFunction
{
trait
RscriptCommandLineFunction
extends
BiopetCommandLineFunction
with
Rscript
{
protected
var
script
:
File
executable
=
config
(
"exe"
,
default
=
"Rscript"
,
submodule
=
"Rscript"
)
executable
=
rscriptExecutable
override
def
beforeGraph
()
:
Unit
=
{
checkScript
()
}
/**
* If script not exist in file system it try to copy it from the jar
* @param local if true it use File.createTempFile instead of ".queue/tmp/"
*/
protected
def
checkScript
(
local
:
Boolean
=
false
)
:
Unit
=
{
if
(
script
.
exists
())
{
script
=
script
.
getAbsoluteFile
}
else
{
val
rScript
:
File
=
{
if
(
local
)
File
.
createTempFile
(
script
.
getName
,
".R"
)
else
new
File
(
".queue/tmp/"
+
script
)
}
if
(!
rScript
.
getParentFile
.
exists
)
rScript
.
getParentFile
.
mkdirs
val
is
=
getClass
.
getResourceAsStream
(
script
.
getPath
)
val
os
=
new
FileOutputStream
(
rScript
)
org
.
apache
.
commons
.
io
.
IOUtils
.
copy
(
is
,
os
)
os
.
close
()
script
=
rScript
}
checkScript
(
Some
(
jobTempDir
))
}
/**
* Execute rscript on local system
* @param logger How to handle stdout and stderr
*/
def
runLocal
(
logger
:
ProcessLogger
)
:
Unit
=
{
checkScript
(
local
=
true
)
this
.
logger
.
info
(
cmdLine
)
val
cmd
=
cmdLine
.
stripPrefix
(
" '"
).
stripSuffix
(
"' "
).
split
(
"' *'"
)
this
.
logger
.
info
(
cmd
.
mkString
(
" "
))
val
process
=
Process
(
cmd
.
toSeq
).
run
(
logger
)
this
.
logger
.
info
(
process
.
exitValue
())
}
/**
* Execute rscript on local system
* Stdout and stderr will go to biopet logger
*/
def
runLocal
()
:
Unit
=
{
runLocal
(
ProcessLogger
(
logger
.
info
(
_
)))
}
def
cmdLine
:
String
=
{
required
(
executable
)
+
required
(
script
)
}
def
cmdLine
:
String
=
repeat
(
cmd
)
}
public/biopet-
framework
/src/main/resources/nl/lumc/sasc/biopet/tools/plotHeatmap.R
→
public/biopet-
tools
/src/main/resources/nl/lumc/sasc/biopet/tools/plotHeatmap.R
View file @
7d112c68
File moved
public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/RegionAfCount.scala
View file @
7d112c68
...
...
@@ -19,7 +19,7 @@ import java.io.{ PrintWriter, InputStream, File }
import
java.util
import
htsjdk.variant.vcf.VCFFileReader
import
nl.lumc.sasc.biopet.
extension
s.rscript.ScatterPlot
import
nl.lumc.sasc.biopet.
util
s.rscript.ScatterPlot
import
nl.lumc.sasc.biopet.utils.intervals.
{
BedRecord
,
BedRecordList
}
import
scala.collection.JavaConversions._
...
...
public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SummaryToTsvTest.scala
View file @
7d112c68
...
...
@@ -9,7 +9,7 @@ import org.scalatest.mock.MockitoSugar
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.Test
import
nl.lumc.sasc.biopet.
core
.summary.Summary
import
nl.lumc.sasc.biopet.
utils
.summary.Summary
/**
* Created by ahbbollen on 31-8-15.
...
...
public/biopet-
framework
/src/main/resources/nl/lumc/sasc/biopet/
extension
s/rscript/plotScatter.R
→
public/biopet-
utils
/src/main/resources/nl/lumc/sasc/biopet/
util
s/rscript/plotScatter.R
View file @
7d112c68
File moved
public/biopet-
framework
/src/main/resources/nl/lumc/sasc/biopet/
extension
s/rscript/plotXY.R
→
public/biopet-
utils
/src/main/resources/nl/lumc/sasc/biopet/
util
s/rscript/plotXY.R
View file @
7d112c68
File moved
public/biopet-
framework
/src/main/resources/nl/lumc/sasc/biopet/
extension
s/rscript/stackedBar.R
→
public/biopet-
utils
/src/main/resources/nl/lumc/sasc/biopet/
util
s/rscript/stackedBar.R
View file @
7d112c68
File moved
public/biopet-
core
/src/main/scala/nl/lumc/sasc/biopet/
extension
s/rscript/LinePlot.scala
→
public/biopet-
utils
/src/main/scala/nl/lumc/sasc/biopet/
util
s/rscript/LinePlot.scala
View file @
7d112c68
...
...
@@ -13,26 +13,22 @@
* license; For commercial users or users who do not want to follow the AGPL
* license, please contact us to obtain a separate license.
*/
package
nl.lumc.sasc.biopet.
extension
s.rscript
package
nl.lumc.sasc.biopet.
util
s.rscript
import
java.io.File
import
nl.lumc.sasc.biopet.core.extensions.RscriptCommandLineFunction
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
}
/**
* Extension for en general line plot with R
*
* Created by pjvan_thof on 4/29/15.
*/
class
LinePlot
(
val
root
:
Configurable
)
extends
Rscript
CommandLineFunction
{
class
LinePlot
(
val
root
:
Configurable
)
extends
Rscript
{
protected
var
script
:
File
=
config
(
"script"
,
default
=
"plotXY.R"
)
@Input
var
input
:
File
=
_
@Output
var
output
:
File
=
_
var
width
:
Option
[
Int
]
=
config
(
"width"
)
...
...
@@ -43,14 +39,14 @@ class LinePlot(val root: Configurable) extends RscriptCommandLineFunction {
var
title
:
Option
[
String
]
=
config
(
"title"
)
var
removeZero
:
Boolean
=
config
(
"removeZero"
,
default
=
false
)
override
def
cmd
Line
:
String
=
super
.
cmd
Line
+
r
eq
uired
(
"--input"
,
input
)
+
r
eq
uired
(
"--output"
,
output
)
+
optional
(
"--width"
,
width
)
+
optional
(
"--height"
,
height
)
+
optional
(
"--xlabel"
,
xlabel
)
+
required
(
"--ylabel"
,
ylabel
)
+
optional
(
"--llabel"
,
llabel
)
+
optional
(
"--title"
,
title
)
+
optional
(
"--
removeZero
"
,
removeZero
)
override
def
cmd
=
super
.
cmd
+
+
S
eq
(
"--input"
,
input
.
getAbsolutePath
)
+
+
S
eq
(
"--output"
,
output
.
getAbsolutePath
)
+
+
width
.
map
(
x
=>
Seq
(
"--width"
,
x
.
toString
)).
getOrElse
(
Seq
()
)
+
+
height
.
map
(
x
=>
Seq
(
"--height"
,
x
.
toString
)).
getOrElse
(
Seq
()
)
+
+
xlabel
.
map
(
Seq
(
"--xlabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
ylabel
.
map
(
Seq
(
"--ylabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
llabel
.
map
(
Seq
(
"--llabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
title
.
map
(
Seq
(
"--title"
,
_
)).
getOrElse
(
Seq
()
)
+
+
(
if
(
removeZero
)
Seq
(
"--
removeZero
"
)
else
Seq
()
)
}
public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/rscript/Rscript.scala
0 → 100644
View file @
7d112c68
package
nl.lumc.sasc.biopet.utils.rscript
import
java.io.
{
File
,
FileOutputStream
}
import
nl.lumc.sasc.biopet.utils.Logging
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
scala.sys.process.
{
Process
,
ProcessLogger
}
/**
* Created by pjvanthof on 13/09/15.
*/
trait
Rscript
extends
Configurable
{
protected
var
script
:
File
def
rscriptExecutable
:
String
=
config
(
"exe"
,
default
=
"Rscript"
,
submodule
=
"Rscript"
)
/** This is the defaul implementation, to add arguments override this */
def
cmd
:
Seq
[
String
]
=
Seq
(
rscriptExecutable
,
script
.
getAbsolutePath
)
/**
* If script not exist in file system it try to copy it from the jar
* @param dir Directory to store temp script, if None or not given File.createTempFile is called
*/
protected
def
checkScript
(
dir
:
Option
[
File
]
=
None
)
:
Unit
=
{
if
(
script
.
exists
())
{
script
=
script
.
getAbsoluteFile
}
else
{
val
rScript
:
File
=
dir
match
{
case
Some
(
dir
)
=>
new
File
(
dir
,
script
.
getName
)
case
_
=>
File
.
createTempFile
(
script
.
getName
,
".R"
)
}
if
(!
rScript
.
getParentFile
.
exists
)
rScript
.
getParentFile
.
mkdirs
val
is
=
getClass
.
getResourceAsStream
(
script
.
getPath
)
val
os
=
new
FileOutputStream
(
rScript
)
org
.
apache
.
commons
.
io
.
IOUtils
.
copy
(
is
,
os
)
os
.
close
()
script
=
rScript
}
}
/**
* Execute rscript on local system
* @param logger How to handle stdout and stderr
*/
def
runLocal
(
logger
:
ProcessLogger
)
:
Unit
=
{
checkScript
()
Logging
.
logger
.
info
(
"Running: "
+
cmd
.
mkString
(
" "
))
val
process
=
Process
(
cmd
).
run
(
logger
)
Logging
.
logger
.
info
(
process
.
exitValue
())
}
/**
* Execute rscript on local system
* Stdout and stderr will go to biopet logger
*/
def
runLocal
()
:
Unit
=
{
runLocal
(
ProcessLogger
(
Logging
.
logger
.
info
(
_
)))
}
}
public/biopet-
core
/src/main/scala/nl/lumc/sasc/biopet/
extension
s/rscript/ScatterPlot.scala
→
public/biopet-
utils
/src/main/scala/nl/lumc/sasc/biopet/
util
s/rscript/ScatterPlot.scala
View file @
7d112c68
...
...
@@ -13,26 +13,22 @@
* license; For commercial users or users who do not want to follow the AGPL
* license, please contact us to obtain a separate license.
*/
package
nl.lumc.sasc.biopet.
extension
s.rscript
package
nl.lumc.sasc.biopet.
util
s.rscript
import
java.io.File
import
nl.lumc.sasc.biopet.core.extensions.RscriptCommandLineFunction
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
}
/**
* Extension for en general line plot with R
*
* Created by pjvan_thof on 4/29/15.
*/
class
ScatterPlot
(
val
root
:
Configurable
)
extends
Rscript
CommandLineFunction
{
class
ScatterPlot
(
val
root
:
Configurable
)
extends
Rscript
{
protected
var
script
:
File
=
config
(
"script"
,
default
=
"plotScatter.R"
)
@Input
var
input
:
File
=
_
@Output
var
output
:
File
=
_
var
width
:
Option
[
Int
]
=
config
(
"width"
)
...
...
@@ -43,14 +39,14 @@ class ScatterPlot(val root: Configurable) extends RscriptCommandLineFunction {
var
title
:
Option
[
String
]
=
config
(
"title"
)
var
removeZero
:
Boolean
=
config
(
"removeZero"
,
default
=
false
)
override
def
cmd
Line
:
String
=
super
.
cmd
Line
+
r
eq
uired
(
"--input"
,
input
)
+
r
eq
uired
(
"--output"
,
output
)
+
optional
(
"--width"
,
width
)
+
optional
(
"--height"
,
height
)
+
optional
(
"--xlabel"
,
xlabel
)
+
required
(
"--ylabel"
,
ylabel
)
+
optional
(
"--llabel"
,
llabel
)
+
optional
(
"--title"
,
title
)
+
optional
(
"--
removeZero
"
,
removeZero
)
override
def
cmd
=
super
.
cmd
+
+
S
eq
(
"--input"
,
input
.
getAbsolutePath
)
+
+
S
eq
(
"--output"
,
output
.
getAbsolutePath
)
+
+
width
.
map
(
x
=>
Seq
(
"--width"
,
x
.
toString
)).
getOrElse
(
Seq
()
)
+
+
height
.
map
(
x
=>
Seq
(
"--height"
,
x
.
toString
)).
getOrElse
(
Seq
()
)
+
+
xlabel
.
map
(
Seq
(
"--xlabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
ylabel
.
map
(
Seq
(
"--ylabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
llabel
.
map
(
Seq
(
"--llabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
title
.
map
(
Seq
(
"--title"
,
_
)).
getOrElse
(
Seq
()
)
+
+
(
if
(
removeZero
)
Seq
(
"--
removeZero
"
)
else
Seq
()
)
}
public/biopet-
core
/src/main/scala/nl/lumc/sasc/biopet/
extension
s/rscript/StackedBarPlot.scala
→
public/biopet-
utils
/src/main/scala/nl/lumc/sasc/biopet/
util
s/rscript/StackedBarPlot.scala
View file @
7d112c68
...
...
@@ -13,26 +13,22 @@
* license; For commercial users or users who do not want to follow the AGPL
* license, please contact us to obtain a separate license.
*/
package
nl.lumc.sasc.biopet.
extension
s.rscript
package
nl.lumc.sasc.biopet.
util
s.rscript
import
java.io.File
import
nl.lumc.sasc.biopet.core.extensions.RscriptCommandLineFunction
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
org.broadinstitute.gatk.utils.commandline.
{
Input
,
Output
}
/**
* Extension for en general stackedbar plot with R
*
* Created by pjvan_thof on 4/29/15.
*/
class
StackedBarPlot
(
val
root
:
Configurable
)
extends
Rscript
CommandLineFunction
{
class
StackedBarPlot
(
val
root
:
Configurable
)
extends
Rscript
{
protected
var
script
:
File
=
config
(
"script"
,
default
=
"stackedBar.R"
)
@Input
var
input
:
File
=
_
@Output
var
output
:
File
=
_
var
width
:
Option
[
Int
]
=
config
(
"width"
)
...
...
@@ -42,13 +38,13 @@ class StackedBarPlot(val root: Configurable) extends RscriptCommandLineFunction
var
llabel
:
Option
[
String
]
=
config
(
"llabel"
)
var
title
:
Option
[
String
]
=
config
(
"title"
)
override
def
cmd
Line
:
String
=
super
.
cmd
Line
+
r
eq
uired
(
"--input"
,
input
)
+
r
eq
uired
(
"--output"
,
output
)
+
optional
(
"--width"
,
width
)
+
optional
(
"--height"
,
height
)
+
optional
(
"--xlabel"
,
xlabel
)
+
required
(
"--ylabel"
,
ylabel
)
+
optional
(
"--llabel"
,
llabel
)
+
optional
(
"--title"
,
title
)
override
def
cmd
=
super
.
cmd
+
+
S
eq
(
"--input"
,
input
.
getAbsolutePath
)
+
+
S
eq
(
"--output"
,
output
.
getAbsolutePath
)
+
+
width
.
map
(
x
=>
Seq
(
"--width"
,
x
.
toString
)).
getOrElse
(
Seq
()
)
+
+
height
.
map
(
x
=>
Seq
(
"--height"
,
x
.
toString
)).
getOrElse
(
Seq
()
)
+
+
xlabel
.
map
(
Seq
(
"--xlabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
ylabel
.
map
(
Seq
(
"--ylabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
llabel
.
map
(
Seq
(
"--llabel"
,
_
)).
getOrElse
(
Seq
()
)
+
+
title
.
map
(
Seq
(
"--title"
,
_
)).
getOrElse
(
Seq
()
)
}
public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepReport.scala
View file @
7d112c68
...
...
@@ -20,7 +20,7 @@ import java.io.{ File, PrintWriter }
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core.report.
{
ReportBuilderExtension
,
ReportBuilder
,
ReportPage
,
ReportSection
}
import
nl.lumc.sasc.biopet.core.summary.
{
Summary
,
SummaryValue
}
import
nl.lumc.sasc.biopet.
extension
s.rscript.StackedBarPlot
import
nl.lumc.sasc.biopet.
util
s.rscript.StackedBarPlot
class
FlexiprepReport
(
val
root
:
Configurable
)
extends
ReportBuilderExtension
{
val
builder
=
FlexiprepReport
...
...
public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala
View file @
7d112c68
...
...
@@ -20,7 +20,7 @@ import java.io.{ File, PrintWriter }
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core.report._
import
nl.lumc.sasc.biopet.core.summary.
{
Summary
,
SummaryValue
}
import
nl.lumc.sasc.biopet.
extension
s.rscript.StackedBarPlot
import
nl.lumc.sasc.biopet.
util
s.rscript.StackedBarPlot
import
nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport
import
nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport
...
...
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