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
8d10661f
Commit
8d10661f
authored
Jul 03, 2015
by
Peter van 't Hof
Browse files
Fix code inspection warnings in core
parent
4b14ab55
Changes
8
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/SampleLibraryTag.scala
View file @
8d10661f
...
...
@@ -19,9 +19,9 @@ import nl.lumc.sasc.biopet.core.config.Configurable
import
org.broadinstitute.gatk.utils.commandline.Argument
/**
* Created by pjvan_thof on 2/16/15.
*
* Default implementation for sample and library arguments for pipelines, mainly used for typecasting.
*
* @author Peter van 't Hof
*/
trait
SampleLibraryTag
extends
Configurable
{
@Argument
(
doc
=
"Sample ID"
,
shortName
=
"sample"
,
required
=
false
)
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala
View file @
8d10661f
...
...
@@ -43,7 +43,7 @@ class Config(var map: Map[String, Any],
*/
def
loadConfigEnv
(
valueName
:
String
,
default
:
Boolean
)
{
sys
.
env
.
get
(
valueName
)
match
{
case
Some
(
globalFiles
)
=>
{
case
Some
(
globalFiles
)
=>
for
(
globalFile
<-
globalFiles
.
split
(
":"
))
{
val
file
:
File
=
new
File
(
globalFile
)
if
(
file
.
exists
)
{
...
...
@@ -51,14 +51,13 @@ class Config(var map: Map[String, Any],
loadConfigFile
(
file
,
default
)
}
else
logger
.
warn
(
valueName
+
" value found but file '"
+
file
+
"' does not exist, no global config is loaded"
)
}
}
case
_
=>
logger
.
info
(
valueName
+
" value not found, no global config is loaded"
)
}
}
/** Loading default value for biopet */
def
loadDefaultConfig
()
{
loadConfigEnv
(
"BIOPET_CONFIG"
,
true
)
loadConfigEnv
(
"BIOPET_CONFIG"
,
default
=
true
)
}
/**
...
...
@@ -94,7 +93,7 @@ class Config(var map: Map[String, Any],
protected
[
config
]
var
notFoundCache
:
List
[
ConfigValueIndex
]
=
List
()
protected
[
config
]
var
foundCache
:
Map
[
ConfigValueIndex
,
ConfigValue
]
=
Map
()
protected
[
config
]
var
defaultCache
:
Map
[
ConfigValueIndex
,
ConfigValue
]
=
Map
()
protected
[
config
]
def
clearCache
:
Unit
=
{
protected
[
config
]
def
clearCache
()
:
Unit
=
{
notFoundCache
=
List
()
foundCache
=
Map
()
defaultCache
=
Map
()
...
...
@@ -114,16 +113,16 @@ class Config(var map: Map[String, Any],
* @return True if exist
*/
def
contains
(
requestedIndex
:
ConfigValueIndex
)
:
Boolean
=
if
(
notFoundCache
.
contains
(
requestedIndex
))
return
false
else
if
(
foundCache
.
contains
(
requestedIndex
))
return
true
if
(
notFoundCache
.
contains
(
requestedIndex
))
false
else
if
(
foundCache
.
contains
(
requestedIndex
))
true
else
{
val
value
=
Config
.
getValueFromMap
(
map
,
requestedIndex
)
if
(
value
.
isDefined
&&
value
.
get
.
value
!=
None
)
{
foundCache
+=
(
requestedIndex
->
value
.
get
)
return
true
true
}
else
{
notFoundCache
+:=
requestedIndex
return
false
false
}
}
...
...
@@ -201,7 +200,7 @@ class Config(var map: Map[String, Any],
writeMapToJsonFile
(
fullEffectiveWithNotFound
,
"effective.full.notfound"
)
}
override
def
toString
()
:
String
=
map
.
toString
override
def
toString
:
String
=
map
.
toString
()
}
object
Config
extends
Logging
{
...
...
@@ -210,7 +209,7 @@ object Config extends Logging {
/**
* Merge 2 config objects
* @param config1 prio over config 2
* @param config2
* @param config2
Low prio map
* @return Merged config
*/
def
mergeConfigs
(
config1
:
Config
,
config2
:
Config
)
:
Config
=
new
Config
(
mergeMaps
(
config1
.
map
,
config2
.
map
))
...
...
@@ -234,7 +233,7 @@ object Config extends Logging {
def
tailSearch
(
path
:
List
[
String
])
:
Option
[
ConfigValue
]
=
{
val
p
=
getFromPath
(
path
)
if
(
p
!=
No
ne
)
p
if
(
p
.
isDefi
ne
d
)
p
else
if
(
path
==
Nil
)
None
else
{
val
p
=
initSearch
(
path
)
...
...
@@ -261,6 +260,6 @@ object Config extends Logging {
else
skipNested
(
path
,
tail
.
tail
)
}
return
tailSearch
(
startIndex
.
path
)
tailSearch
(
startIndex
.
path
)
}
}
\ No newline at end of file
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/ConfigValue.scala
View file @
8d10661f
...
...
@@ -56,7 +56,7 @@ class ConfigValue(val requestIndex: ConfigValueIndex, val foundIndex: ConfigValu
else
if
(!
default
)
output
+=
", foundIndex = ("
+
foundIndex
+
")"
else
output
+=
", default value is used"
return
output
output
}
}
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Configurable.scala
View file @
8d10661f
...
...
@@ -45,10 +45,6 @@ trait Configurable extends ImplicitConversions {
/**
* Creates path with a prefix for sample and library
* "samples" -> "sampleID" -> "libraries" -> "libraryID" -> rest of path
* @param sample
* @param library
* @param submodule
* @return
*/
def
getConfigPath
(
sample
:
String
=
null
,
library
:
String
=
null
,
submodule
:
String
=
null
)
=
{
(
if
(
sample
!=
null
)
"samples"
::
sample
::
Nil
else
Nil
)
:::
...
...
@@ -92,9 +88,9 @@ trait Configurable extends ImplicitConversions {
val
s
=
if
(
sample
!=
null
||
defaultSample
.
isEmpty
)
sample
else
defaultSample
.
get
val
l
=
if
(
library
!=
null
||
defaultLibrary
.
isEmpty
)
library
else
defaultLibrary
.
get
val
m
=
if
(
submodule
!=
null
)
submodule
else
configName
val
p
=
(
if
(
path
==
null
)
getConfigPath
(
s
,
l
,
submodule
)
:::
subPath
else
path
)
val
p
=
if
(
path
==
null
)
getConfigPath
(
s
,
l
,
submodule
)
:::
subPath
else
path
val
d
=
{
val
value
=
Config
.
getValueFromMap
(
defaults
.
toMap
,
ConfigValueIndex
(
m
,
p
,
key
,
freeVar
))
val
value
=
Config
.
getValueFromMap
(
defaults
,
ConfigValueIndex
(
m
,
p
,
key
,
freeVar
))
if
(
value
.
isDefined
)
value
.
get
.
value
else
default
}
if
(
d
==
null
)
globalConfig
(
m
,
p
,
key
,
freeVar
=
freeVar
)
...
...
@@ -119,9 +115,9 @@ trait Configurable extends ImplicitConversions {
val
s
=
if
(
sample
!=
null
||
defaultSample
.
isEmpty
)
sample
else
defaultSample
.
get
val
l
=
if
(
library
!=
null
||
defaultLibrary
.
isEmpty
)
library
else
defaultLibrary
.
get
val
m
=
if
(
submodule
!=
null
)
submodule
else
configName
val
p
=
(
if
(
path
==
null
)
getConfigPath
(
s
,
l
,
submodule
)
:::
subPath
else
path
)
val
p
=
if
(
path
==
null
)
getConfigPath
(
s
,
l
,
submodule
)
:::
subPath
else
path
globalConfig
.
contains
(
m
,
p
,
key
,
freeVar
)
||
!(
Config
.
getValueFromMap
(
defaults
.
toMap
,
ConfigValueIndex
(
m
,
p
,
key
,
freeVar
))
==
No
ne
)
globalConfig
.
contains
(
m
,
p
,
key
,
freeVar
)
||
Config
.
getValueFromMap
(
defaults
,
ConfigValueIndex
(
m
,
p
,
key
,
freeVar
))
.
isDefi
ne
d
}
}
}
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/report/MultisampleReportBuilder.scala
View file @
8d10661f
package
nl.lumc.sasc.biopet.core.report
/**
* Created by pjvan_thof on 3/30/15.
* This trait will generate a report with added function to generate sample and library pages for those existing in the summary.
*
* @author pjvan_thof
*/
trait
MultisampleReportBuilder
extends
ReportBuilder
{
...
...
@@ -28,7 +30,7 @@ trait MultisampleReportBuilder extends ReportBuilder {
/** Generate the samples page including a single sample page for each sample in the summary */
def
generateSamplesPage
(
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
samplePages
=
summary
.
samples
.
map
(
sampleId
=>
(
sampleId
->
samplePage
(
sampleId
,
args
++
Map
(
"sampleId"
->
Some
(
sampleId
))))
)
.
map
(
sampleId
=>
sampleId
->
samplePage
(
sampleId
,
args
++
Map
(
"sampleId"
->
Some
(
sampleId
))))
.
toList
ReportPage
(
samplePages
,
samplesSections
,
args
)
}
...
...
@@ -41,7 +43,7 @@ trait MultisampleReportBuilder extends ReportBuilder {
}
val
libPages
=
summary
.
libraries
(
sampleId
)
.
map
(
libId
=>
(
libId
->
libraryPage
(
sampleId
,
libId
,
args
++
Map
(
"libId"
->
Some
(
libId
))))
)
.
map
(
libId
=>
libId
->
libraryPage
(
sampleId
,
libId
,
args
++
Map
(
"libId"
->
Some
(
libId
))))
.
toList
ReportPage
(
libPages
,
libririesSections
,
args
)
}
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala
View file @
8d10661f
...
...
@@ -10,7 +10,9 @@ import org.fusesource.scalate.{ TemplateEngine, TemplateSource }
import
scala.collection.mutable
/**
* Created by pjvan_thof on 3/27/15.
* This trait is meant to make an extension for a report object
*
* @author pjvan_thof
*/
trait
ReportBuilderExtension
extends
ToolCommandFuntion
{
...
...
@@ -28,8 +30,8 @@ trait ReportBuilderExtension extends ToolCommandFuntion {
override
val
defaultCoreMemory
=
3.0
override
def
beforeGraph
:
Unit
=
{
super
.
beforeGraph
override
def
beforeGraph
()
:
Unit
=
{
super
.
beforeGraph
()
jobOutputFile
=
new
File
(
outputDir
,
".report.log.out"
)
javaMainClass
=
builder
.
getClass
.
getName
.
takeWhile
(
_
!=
'$'
)
}
...
...
@@ -87,18 +89,16 @@ trait ReportBuilder extends ToolCommand {
require
(
cmdArgs
.
outputDir
.
isDirectory
,
"Output dir is not a directory"
)
cmdArgs
.
pageArgs
.
get
(
"sampleId"
)
match
{
case
Some
(
s
:
String
)
=>
{
case
Some
(
s
:
String
)
=>
cmdArgs
.
pageArgs
+=
"sampleId"
->
Some
(
s
)
_sampleId
=
Some
(
s
)
}
case
_
=>
}
cmdArgs
.
pageArgs
.
get
(
"libId"
)
match
{
case
Some
(
l
:
String
)
=>
{
case
Some
(
l
:
String
)
=>
cmdArgs
.
pageArgs
+=
"libId"
->
Some
(
l
)
_libId
=
Some
(
l
)
}
case
_
=>
}
...
...
@@ -121,7 +121,7 @@ trait ReportBuilder extends ToolCommand {
)
for
(
resource
<-
extFiles
.
par
)
{
IoUtils
.
copyStreamToFile
(
getClass
.
getResourceAsStream
(
resourceDir
+
resource
),
new
File
(
extOutputDir
,
resource
),
true
)
IoUtils
.
copyStreamToFile
(
getClass
.
getResourceAsStream
(
resourceDir
+
resource
),
new
File
(
extOutputDir
,
resource
),
createDirs
=
true
)
}
logger
.
info
(
"Parsing summary"
)
...
...
@@ -184,7 +184,7 @@ trait ReportBuilder extends ToolCommand {
done
+=
1
if
(
done
%
100
==
0
)
logger
.
info
(
done
+
" Done, "
+
(
done
.
toDouble
/
total
*
100
)
+
"%"
)
jobs
.
fold
(
0
)(
_
+
_
)
+
1
jobs
.
sum
+
1
}
}
...
...
@@ -210,18 +210,13 @@ object ReportBuilder {
def
renderTemplate
(
location
:
String
,
args
:
Map
[
String
,
Any
]
=
Map
())
:
String
=
{
Logging
.
logger
.
info
(
"Rendering: "
+
location
)
if
(
location
==
"/nl/lumc/sasc/biopet/pipelines/carp/carpFront.ssp"
)
{
println
(
"hier dus"
)
}
val
templateFile
:
File
=
templateCache
.
get
(
location
)
match
{
case
Some
(
template
)
=>
template
case
_
=>
{
case
_
=>
val
tempFile
=
File
.
createTempFile
(
"ssp-template"
,
new
File
(
location
).
getName
)
IoUtils
.
copyStreamToFile
(
getClass
.
getResourceAsStream
(
location
),
tempFile
)
templateCache
+=
location
->
tempFile
tempFile
}
}
engine
.
layout
(
TemplateSource
.
fromFile
(
templateFile
),
args
)
}
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala
View file @
8d10661f
...
...
@@ -28,6 +28,8 @@ import scala.collection.mutable
import
scala.io.Source
/**
* This will collect and write the summary
*
* Created by pjvan_thof on 2/14/15.
*/
class
WriteSummary
(
val
root
:
Configurable
)
extends
InProcessFunction
with
Configurable
{
...
...
@@ -71,17 +73,15 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
val
executables
:
Map
[
String
,
Any
]
=
{
(
for
(
f
<-
qscript
.
functions
if
f
.
isInstanceOf
[
BiopetCommandLineFunctionTrait
])
yield
{
f
match
{
case
f
:
BiopetJavaCommandLineFunction
=>
{
case
f
:
BiopetJavaCommandLineFunction
=>
f
.
configName
->
Map
(
"version"
->
f
.
getVersion
.
getOrElse
(
None
),
"java_md5"
->
BiopetCommandLineFunctionTrait
.
executableMd5Cache
.
getOrElse
(
f
.
executable
,
None
),
"java_version"
->
f
.
getJavaVersion
,
"jar_path"
->
f
.
jarFile
)
}
case
f
:
BiopetCommandLineFunction
=>
{
case
f
:
BiopetCommandLineFunction
=>
f
.
configName
->
Map
(
"version"
->
f
.
getVersion
.
getOrElse
(
None
),
"md5"
->
BiopetCommandLineFunctionTrait
.
executableMd5Cache
.
getOrElse
(
f
.
executable
,
None
),
"path"
->
f
.
executable
)
}
case
_
=>
throw
new
IllegalStateException
(
"This should not be possible"
)
}
...
...
@@ -127,42 +127,29 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
def
prefixSampleLibrary
(
map
:
Map
[
String
,
Any
],
sampleId
:
Option
[
String
],
libraryId
:
Option
[
String
])
:
Map
[
String
,
Any
]
=
{
sampleId
match
{
case
Some
(
s
ampleId
)
=>
Map
(
"samples"
->
Map
(
s
ampleId
->
(
libraryId
match
{
case
Some
(
l
ibraryId
)
=>
Map
(
"libraries"
->
Map
(
l
ibraryId
->
map
))
case
_
=>
map
case
Some
(
s
)
=>
Map
(
"samples"
->
Map
(
s
->
(
libraryId
match
{
case
Some
(
l
)
=>
Map
(
"libraries"
->
Map
(
l
->
map
))
case
_
=>
map
})))
case
_
=>
map
}
}
/**
* Convert summarizable to a summary map
* @param summarizable
* @param name
* @return
*/
/** Convert summarizable to a summary map */
def
parseSummarizable
(
summarizable
:
Summarizable
,
name
:
String
)
=
{
val
stats
=
summarizable
.
summaryStats
val
files
=
parseFiles
(
summarizable
.
summaryFiles
)
(
Map
(
"stats"
->
Map
(
name
->
stats
))
)
++
Map
(
"stats"
->
Map
(
name
->
stats
))
++
(
if
(
files
.
isEmpty
)
Map
[
String
,
Any
]()
else
Map
(
"files"
->
Map
(
name
->
files
)))
}
/**
* Parse files map to summary map
* @param files
* @return
*/
/** Parse files map to summary map */
def
parseFiles
(
files
:
Map
[
String
,
File
])
:
Map
[
String
,
Map
[
String
,
Any
]]
=
{
for
((
key
,
file
)
<-
files
)
yield
key
->
parseFile
(
file
)
}
/**
* parse single file summary map
* @param file
* @return
*/
/** arse single file summary map */
def
parseFile
(
file
:
File
)
:
Map
[
String
,
Any
]
=
{
val
map
:
mutable.Map
[
String
,
Any
]
=
mutable
.
Map
()
map
+=
"path"
->
file
.
getAbsolutePath
...
...
@@ -170,11 +157,7 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
map
.
toMap
}
/**
* Retrive checksum from file
* @param checksumFile
* @return
*/
/** Retrive checksum from file */
def
parseChecksum
(
checksumFile
:
File
)
:
String
=
{
Source
.
fromFile
(
checksumFile
).
getLines
().
toList
.
head
.
split
(
" "
)(
0
)
}
...
...
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/workaround/BiopetQCommandLine.scala
View file @
8d10661f
...
...
@@ -46,7 +46,8 @@
package
nl.lumc.sasc.biopet.core.workaround
import
java.io.
{
File
,
FileOutputStream
}
import
java.util.
{
Arrays
,
ResourceBundle
}
import
java.util
import
java.util.ResourceBundle
import
nl.lumc.sasc.biopet.FullVersion
import
nl.lumc.sasc.biopet.core.Logging
...
...
@@ -176,8 +177,8 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
// TODO: Default command plugin argument?
val
remoteFileConverter
=
(
for
(
commandPlugin
<-
allCommandPlugins
if
(
commandPlugin
.
remoteFileConverter
!=
null
)
)
yield
commandPlugin
.
remoteFileConverter
).
headOption
.
getOrElse
(
n
ull
)
for
(
commandPlugin
<-
allCommandPlugins
if
commandPlugin
.
remoteFileConverter
!=
null
)
yield
commandPlugin
.
remoteFileConverter
).
headOption
.
orN
ull
if
(
remoteFileConverter
!=
null
)
loadArgumentsIntoObject
(
remoteFileConverter
)
...
...
@@ -198,7 +199,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
script
.
mkRemoteOutputs
(
remoteFileConverter
)
}
script
.
functions
.
foreach
(
qGraph
.
add
(
_
)
)
script
.
functions
.
foreach
(
qGraph
.
add
)
logger
.
info
(
"Added "
+
script
.
functions
.
size
+
" functions"
)
}
// Execute the job graph
...
...
@@ -281,7 +282,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
* @return a ScalaCompoundArgumentTypeDescriptor
*/
override
def
getArgumentTypeDescriptors
=
Arrays
.
asList
(
new
ScalaCompoundArgumentTypeDescriptor
)
util
.
Arrays
.
asList
(
new
ScalaCompoundArgumentTypeDescriptor
)
override
def
getApplicationDetails
:
ApplicationDetails
=
{
new
ApplicationDetails
(
createQueueHeader
(),
...
...
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