Skip to content
This repository was archived by the owner on Sep 25, 2018. It is now read-only.

Commit a0bdc74

Browse files
committed
Tweaked command line interface.
1 parent 4220fe4 commit a0bdc74

5 files changed

Lines changed: 27 additions & 18 deletions

File tree

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Development versions of pxftools may depend on the latest snapshot version of th
1414

1515
## Running
1616

17+
You can download a prepackaged [release](https://github.com/phenopackets/pxftools/releases).
18+
1719
To build the command-line executable, run:
1820

1921
`sbt stage`
@@ -34,16 +36,19 @@ Usage
3436
3537
Options
3638
37-
--format=STRING : Output format. Set the output format to one of:
38-
yaml
39-
json
40-
turtle
41-
--out=STRING : Output file. Omit to write to standard out.
39+
--informat=STRING : Input format. By default both yaml and json will be attempted. Set the input format to one of:
40+
yaml
41+
json
42+
hpo-phenote
43+
--out=STRING : Output file. Omit to write to standard out.
44+
--outformat=STRING : Output format. Set the output format to one of:
45+
yaml
46+
json
47+
turtle
4248
4349
Commands
4450
45-
convert [command options] : Read in a PXF file and output in the specified format.
46-
--in=STRING : Input file. Pass '-' or omit to read from standard in.
51+
convert <infile> : Read in a PXF file and output in the specified format.
4752
4853
merge <files> ... : Read in multiple PXF files and output as a single merged PXF file in the specified format.
4954
```

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ organization := "org.phenopackets"
44

55
name := "pxftools"
66

7-
version := "0.0.2"
7+
version := "0.0.3"
88

99
scalaVersion := "2.11.8"
1010

src/main/scala/org/phenopackets/pxftools/command/Common.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ trait Common extends Command {
3030

3131
var out = opt[String](description = "Output file. Omit to write to standard out.", default = "")
3232

33-
var informat = opt[Option[String]](description = "Input format. By default both yaml and json will be attempted. Set the input format to one of:\nyaml\njson\nhpo-phenote")
33+
var informat = opt[String](description = "Input format. By default both yaml and json will be attempted. Set the input format to one of:\nyaml\njson\nhpo-phenote", default = "guess")
3434
var outformat = opt[String](description = "Output format. Set the output format to one of:\nyaml\njson\nturtle", default = "yaml")
3535

36-
def inputReader: Option[PhenoPacketReader] = informat.map(_ match {
37-
case "yaml" => YamlReader.readInputStream
38-
case "json" => JsonReader.readInputStream
39-
case "hpo-phenote" => HPOAnnotations.read
36+
def inputReader: Option[PhenoPacketReader] = informat match {
37+
case "yaml" => Option(YamlReader.readInputStream)
38+
case "json" => Option(JsonReader.readInputStream)
39+
case "hpo-phenote" => Option(HPOAnnotations.read)
40+
case "guess" => None
4041
case _ => throw new ParsingException("Invalid input format.")
41-
})
42+
}
4243

4344
def outputWriter: PhenoPacketWriter = outformat match {
4445
case "yaml" => YamlGenerator.render

src/main/scala/org/phenopackets/pxftools/command/SingleInput.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ import org.phenopackets.api.io.YamlReader
2121

2222
trait SingleInput extends Command {
2323

24-
var in = opt[String](description = "Input file. Pass '-' or omit to read from standard in.", default = "-")
24+
var infile = arg[Option[String]](description = "Input file. Omit to read from standard in.")
2525

26-
def determineInput: InputStream = in match {
27-
case "-" => System.in
28-
case _ => new FileInputStream(new File(in))
26+
def determineInput: InputStream = infile match {
27+
case Some("-") => System.in
28+
case Some(filepath) => new FileInputStream(new File(filepath))
29+
case None => System.in
2930
}
3031

3132
}

src/main/scala/org/phenopackets/pxftools/util/HPOAnnotations.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ object HPOAnnotations extends LazyLogging {
3333
def importFromTable(table: CSVReader): PhenoPacket = {
3434
val packetURI = s"urn:uuid:${UUID.randomUUID.toString}"
3535
val packet = ResourceFactory.createResource(packetURI)
36+
println(packet)
3637
val triples = table.iteratorWithHeaders.flatMap(rowToTriples(_, packet)).toSeq
38+
println(triples)
3739
val model = ModelFactory.createDefaultModel()
3840
model.add(triples.asJava)
3941
RDFReader.readModel(model, packetURI)

0 commit comments

Comments
 (0)