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
2f0da996
Commit
2f0da996
authored
Dec 17, 2016
by
Peter van 't Hof
Browse files
Added basic trait for basis of all pipeline templates
parent
f8464310
Changes
1
Hide whitespace changes
Inline
Side-by-side
biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/TemplateTool.scala
0 → 100644
View file @
2f0da996
package
nl.lumc.sasc.biopet.core
import
java.io.File
import
nl.lumc.sasc.biopet.utils.
{
Question
,
ToolCommand
}
/**
* Created by pjvanthof on 17/12/2016.
*/
trait
TemplateTool
extends
ToolCommand
{
import
TemplateTool._
case
class
Args
(
expert
:
Boolean
=
false
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
Unit
](
"expert"
)
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
expert
=
true
)
}
text
"Path to input file"
}
/**
* Program will split fastq file in multiple fastq files
*
* @param args the command line arguments
*/
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
argsParser
=
new
OptParser
val
cmdArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
(
throw
new
IllegalArgumentException
)
val
standard
:
Map
[
String
,
Any
]
=
Map
(
"output_dir"
->
Question
.
askValue
(
"Output directory"
,
validation
=
List
(
isAbsolutePath
,
parentIsWritable
)))
pipelineMap
(
standard
,
cmdArgs
.
expert
)
}
def
pipelineMap
(
map
:
Map
[
String
,
Any
],
expert
:
Boolean
)
:
Map
[
String
,
Any
]
}
object
TemplateTool
{
def
isAbsolutePath
(
value
:
String
)
:
Boolean
=
{
if
(
new
File
(
value
).
isAbsolute
)
true
else
{
println
(
s
"'$value' must be a absulute path"
)
false
}
}
def
mustExist
(
value
:
String
)
:
Boolean
=
{
if
(
new
File
(
value
).
exists
())
true
else
{
println
(
s
"'$value' does not exist"
)
false
}
}
def
parentIsWritable
(
value
:
String
)
:
Boolean
=
{
val
parent
=
new
File
(
value
).
getParentFile
if
(!
parent
.
exists
())
{
println
(
s
"$parent does not exist"
)
false
}
else
if
(!
parent
.
canRead
)
{
println
(
s
"No premision to read $parent"
)
false
}
else
if
(!
parent
.
canWrite
)
{
println
(
s
"No premision to write $parent"
)
false
}
else
true
}
}
\ 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