diff --git a/README.md b/README.md index aabca6b..387f35c 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 : Read in a PXF file and output in the specified format. merge ... : Read in multiple PXF files and output as a single merged PXF file in the specified format. ``` diff --git a/build.sbt b/build.sbt index 0947e87..9d52c32 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ organization := "org.phenopackets" name := "pxftools" -version := "0.0.2" +version := "0.0.3" scalaVersion := "2.11.8" diff --git a/src/main/scala/org/phenopackets/pxftools/command/Common.scala b/src/main/scala/org/phenopackets/pxftools/command/Common.scala index 1b7db31..0c4eeed 100644 --- a/src/main/scala/org/phenopackets/pxftools/command/Common.scala +++ b/src/main/scala/org/phenopackets/pxftools/command/Common.scala @@ -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 diff --git a/src/main/scala/org/phenopackets/pxftools/command/SingleInput.scala b/src/main/scala/org/phenopackets/pxftools/command/SingleInput.scala index 37d87e6..4fdf96b 100644 --- a/src/main/scala/org/phenopackets/pxftools/command/SingleInput.scala +++ b/src/main/scala/org/phenopackets/pxftools/command/SingleInput.scala @@ -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 } } \ No newline at end of file diff --git a/src/main/scala/org/phenopackets/pxftools/util/HPOAnnotations.scala b/src/main/scala/org/phenopackets/pxftools/util/HPOAnnotations.scala index 9ec61a6..9d3d928 100644 --- a/src/main/scala/org/phenopackets/pxftools/util/HPOAnnotations.scala +++ b/src/main/scala/org/phenopackets/pxftools/util/HPOAnnotations.scala @@ -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)