Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve YAML parsing #580

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Prevent NPEs in YAML parsing.
Signed-off-by: Daniel Danis <[email protected]>
ielis committed Jul 14, 2022
commit f96a8db36c69c7d0d55f58633cd20e859b0662b1
13 changes: 13 additions & 0 deletions lirical-cli/src/examples/phenotype-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## LIRICAL Analysis Template.
# Use this as a template for your own set-up.
---
sampleId: Sample ID
hpoIds: ['HP:0002352', 'HP:0002490', 'HP:0001290']
negatedHpoIds: ['HP:0000486']

# Age in ISO8601 notation (e.g. 'P12Y6M5D' to indicate 12 years, 6 months, and 5 days).
#age:
# Choose from {MALE, FEMALE}
#sex:
# Path to a VCF file (optional)
#vcf:
Original file line number Diff line number Diff line change
@@ -58,6 +58,9 @@ public AnalysisData parse(InputStream is) throws LiricalParseException {


private static Sex parseSex(String sex) {
if (sex == null)
return Sex.UNKNOWN;

return switch (sex.toLowerCase()) {
case "male" -> Sex.MALE;
case "female" -> Sex.FEMALE;
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@
*/
public class YamlConfig {

private String sampleId;
private List<String> hpoIds;
private List<String> negatedHpoIds;
private String sampleId = "Sample ID";
private List<String> hpoIds = List.of();
private List<String> negatedHpoIds = List.of();
private String age;
private String sex;
private String sex = "UNKNOWN";
private String vcf;

public void setSampleId(String sampleId) {
@@ -66,7 +66,7 @@ public String vcf() {
}

public Optional<Path> vcfPath() {
return vcf == null ?
return vcf == null || vcf.isBlank() ?
Optional.empty()
: Optional.of(Path.of(vcf));
}