-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from monarch-initiative/update_docs
Fixes #29
- Loading branch information
Showing
7 changed files
with
117 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/PromptCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.monarchinitiative.phenopacket2prompt.cmd; | ||
|
||
|
||
import org.monarchinitiative.phenol.base.PhenolRuntimeException; | ||
import org.monarchinitiative.phenol.io.OntologyLoader; | ||
import org.monarchinitiative.phenol.ontology.data.Ontology; | ||
import org.monarchinitiative.phenopacket2prompt.model.PpktIndividual; | ||
import org.monarchinitiative.phenopacket2prompt.output.PromptGenerator; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import picocli.CommandLine; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.Callable; | ||
|
||
@CommandLine.Command(name = "prompt", aliases = {"P"}, | ||
mixinStandardHelpOptions = true, | ||
description = "Create a prompt from one phenopacket") | ||
public class PromptCommand implements Callable<Integer> { | ||
private final static Logger LOGGER = LoggerFactory.getLogger(PromptCommand.class); | ||
|
||
|
||
@CommandLine.Option(names = {"--hp"}, | ||
description = "path to HP json file") | ||
private String hpoJsonPath = "data/hp.json"; | ||
|
||
|
||
@CommandLine.Option(names = {"-p", "--ppkt"}, description = "Path to JSON phenopacket file", required = true) | ||
private String ppkt; | ||
|
||
@CommandLine.Option(names = {"-o", "--out"}, description = "Name of output prompt file") | ||
private String outfile = null; | ||
|
||
|
||
|
||
@Override | ||
public Integer call() throws Exception { | ||
File hpJsonFile = new File(hpoJsonPath); | ||
if (! hpJsonFile.isFile()) { | ||
throw new PhenolRuntimeException("Could not find hp.json at " + hpJsonFile.getAbsolutePath()); | ||
} | ||
Ontology hpo = OntologyLoader.loadOntology(hpJsonFile); | ||
LOGGER.info("HPO version {}", hpo.version().orElse("n/a")); | ||
PromptGenerator generator = PromptGenerator.english(); | ||
PpktIndividual individual = PpktIndividual.fromFile(new File(ppkt)); | ||
String prompt = generator.createPrompt(individual); | ||
System.out.println(prompt); | ||
if (outfile != null) { | ||
LOGGER.trace("Writing prompt to {}", outfile); | ||
Path path = Path.of(outfile); | ||
Files.writeString(path, prompt); | ||
} | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters