Skip to content
GitLab
Menu
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
190b961c
Commit
190b961c
authored
Feb 19, 2015
by
bow
Browse files
Merge branch 'patch-sampletsvtojson' into 'develop'
Patch sampletsvtojson Fix for #117 See merge request !102
parents
ce4d4d49
768b11d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala
View file @
190b961c
...
...
@@ -21,6 +21,9 @@ import scala.io.Source
import
nl.lumc.sasc.biopet.core.config.Config
import
nl.lumc.sasc.biopet.utils.ConfigUtils._
/**
* This tool can convert a tsv to a json file
*/
object
SamplesTsvToJson
extends
ToolCommand
{
case
class
Args
(
inputFiles
:
List
[
File
]
=
Nil
)
extends
AbstractArgs
...
...
@@ -29,13 +32,18 @@ object SamplesTsvToJson extends ToolCommand {
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"
)
}
/**
* Executes SamplesTsvToJson
* @param args
*/
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
argsParser
=
new
OptParser
val
commandArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
sys
.
exit
(
1
)
val
fileMaps
=
for
(
inputFile
<-
commandArgs
.
inputFiles
)
yield
{
val
reader
=
Source
.
fromFile
(
inputFile
)
val
lines
=
reader
.
getLines
.
toList
val
lines
=
reader
.
getLines
.
toList
.
filter
(!
_
.
isEmpty
)
val
header
=
lines
.
head
.
split
(
"\t"
)
val
sampleColumn
=
header
.
indexOf
(
"sample"
)
val
libraryColumn
=
header
.
indexOf
(
"library"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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