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

Commit

Permalink
Tweaked command line interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Jul 7, 2016
1 parent 4220fe4 commit a0bdc74
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Development versions of pxftools may depend on the latest snapshot version of th

## Running

You can download a prepackaged [release](https://github.com/phenopackets/pxftools/releases).

To build the command-line executable, run:

`sbt stage`
Expand All @@ -34,16 +36,19 @@ Usage
Options
--format=STRING : Output format. Set the output format to one of:
yaml
json
turtle
--out=STRING : Output file. Omit to write to standard out.
--informat=STRING : Input format. By default both yaml and json will be attempted. Set the input format to one of:
yaml
json
hpo-phenote
--out=STRING : Output file. Omit to write to standard out.
--outformat=STRING : Output format. Set the output format to one of:
yaml
json
turtle
Commands
convert [command options] : Read in a PXF file and output in the specified format.
--in=STRING : Input file. Pass '-' or omit to read from standard in.
convert <infile> : Read in a PXF file and output in the specified format.
merge <files> ... : Read in multiple PXF files and output as a single merged PXF file in the specified format.
```
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ organization := "org.phenopackets"

name := "pxftools"

version := "0.0.2"
version := "0.0.3"

scalaVersion := "2.11.8"

Expand Down
13 changes: 7 additions & 6 deletions src/main/scala/org/phenopackets/pxftools/command/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ trait Common extends Command {

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

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")
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")
var outformat = opt[String](description = "Output format. Set the output format to one of:\nyaml\njson\nturtle", default = "yaml")

def inputReader: Option[PhenoPacketReader] = informat.map(_ match {
case "yaml" => YamlReader.readInputStream
case "json" => JsonReader.readInputStream
case "hpo-phenote" => HPOAnnotations.read
def inputReader: Option[PhenoPacketReader] = informat match {
case "yaml" => Option(YamlReader.readInputStream)
case "json" => Option(JsonReader.readInputStream)
case "hpo-phenote" => Option(HPOAnnotations.read)
case "guess" => None
case _ => throw new ParsingException("Invalid input format.")
})
}

def outputWriter: PhenoPacketWriter = outformat match {
case "yaml" => YamlGenerator.render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import org.phenopackets.api.io.YamlReader

trait SingleInput extends Command {

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

def determineInput: InputStream = in match {
case "-" => System.in
case _ => new FileInputStream(new File(in))
def determineInput: InputStream = infile match {
case Some("-") => System.in
case Some(filepath) => new FileInputStream(new File(filepath))
case None => System.in
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ object HPOAnnotations extends LazyLogging {
def importFromTable(table: CSVReader): PhenoPacket = {
val packetURI = s"urn:uuid:${UUID.randomUUID.toString}"
val packet = ResourceFactory.createResource(packetURI)
println(packet)
val triples = table.iteratorWithHeaders.flatMap(rowToTriples(_, packet)).toSeq
println(triples)
val model = ModelFactory.createDefaultModel()
model.add(triples.asJava)
RDFReader.readModel(model, packetURI)
Expand Down

0 comments on commit a0bdc74

Please sign in to comment.