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
3265843e
Commit
3265843e
authored
Sep 09, 2015
by
Peter van 't Hof
Browse files
Add output arg to sampletsvtojson
parent
6a83d167
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala
View file @
3265843e
...
...
@@ -15,7 +15,7 @@
*/
package
nl.lumc.sasc.biopet.tools
import
java.io.File
import
java.io.
{
PrintWriter
,
File
}
import
nl.lumc.sasc.biopet.core.ToolCommand
import
nl.lumc.sasc.biopet.utils.ConfigUtils._
...
...
@@ -27,12 +27,15 @@ import scala.io.Source
* This tool can convert a tsv to a json file
*/
object
SamplesTsvToJson
extends
ToolCommand
{
case
class
Args
(
inputFiles
:
List
[
File
]
=
Nil
)
extends
AbstractArgs
case
class
Args
(
inputFiles
:
List
[
File
]
=
Nil
,
outputFile
:
Option
[
File
]
=
None
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'i'
,
"inputFiles"
)
required
()
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
opt
[
File
](
'i'
,
"inputFiles"
)
required
()
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
inputFiles
=
x
::
c
.
inputFiles
)
}
text
"Input must be a tsv file, first line is seen as header and must at least have a 'sample' column, 'library' column is optional, multiple files allowed"
opt
[
File
](
'o'
,
"outputFile"
)
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
outputFile
=
Some
(
x
))
}
}
/** Executes SamplesTsvToJson */
...
...
@@ -41,7 +44,14 @@ object SamplesTsvToJson extends ToolCommand {
val
commandArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
sys
.
exit
(
1
)
val
jsonString
=
stringFromInputs
(
commandArgs
.
inputFiles
)
println
(
jsonString
)
commandArgs
.
outputFile
match
{
case
Some
(
file
)
=>
{
val
writer
=
new
PrintWriter
(
file
)
writer
.
println
(
jsonString
)
writer
.
close
()
}
case
_
=>
println
(
jsonString
)
}
}
def
mapFromFile
(
inputFile
:
File
)
:
Map
[
String
,
Any
]
=
{
...
...
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