-
Notifications
You must be signed in to change notification settings - Fork 1
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 #49 from TheJacksonLaboratory/enhancement/schema-s…
…earch Enhancement/schema search
- Loading branch information
Showing
39 changed files
with
951 additions
and
124 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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
info = @Info( | ||
title = "ontology-service-${ontology}", | ||
description = "A restful service for the ${ontology} ontology.", | ||
version = "0.5.8", | ||
version = "0.5.9", | ||
contact = @Contact(name = "Michael Gargano", email = "[email protected]") | ||
) | ||
) | ||
|
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
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
59 changes: 59 additions & 0 deletions
59
src/main/java/org/jacksonlaboratory/ingest/OntologyDataResolver.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,59 @@ | ||
package org.jacksonlaboratory.ingest; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* This builds the data directory path and validates required files exist | ||
*/ | ||
public class OntologyDataResolver { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(OntologyDataResolver.class); | ||
|
||
private final Path dataDirectory; | ||
private final String ontology; | ||
|
||
public static OntologyDataResolver of(Path dataDirectory, String ontology) throws RuntimeException { | ||
return new OntologyDataResolver(dataDirectory, ontology); | ||
} | ||
|
||
private OntologyDataResolver(Path dataDirectory, String ontology) throws RuntimeException { | ||
Objects.requireNonNull(dataDirectory, "Data directory must not be null!"); | ||
Objects.requireNonNull(ontology, "Ontology must be defined."); | ||
this.dataDirectory = dataDirectory; | ||
this.ontology = ontology; | ||
validateHpoFiles(); | ||
} | ||
|
||
private void validateHpoFiles() throws RuntimeException { | ||
boolean error = false; | ||
List<Path> requiredFiles = List.of(ontologyJson()); | ||
for (Path file : requiredFiles) { | ||
if (!Files.isRegularFile(file)) { | ||
LOGGER.error("Missing required file `{}` in `{}`.", file.toFile().getName(), dataDirectory.toAbsolutePath()); | ||
error = true; | ||
} | ||
} | ||
if (error) { | ||
throw new RuntimeException("Missing one or more required files in OntologyAnnotationNetwork data directory!"); | ||
} | ||
} | ||
|
||
|
||
public Path dataDirectory() { | ||
return dataDirectory; | ||
} | ||
|
||
public Path ontologyJson(){ | ||
return dataDirectory.resolve(String.format("%s-base.json", ontology)); | ||
} | ||
|
||
public Path babelonFile(){ | ||
return dataDirectory.resolve(String.format("%s-all.babelon.tsv", ontology)); | ||
} | ||
} | ||
|
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
72 changes: 72 additions & 0 deletions
72
src/main/java/org/jacksonlaboratory/model/entity/OntologyTermBuilder.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,72 @@ | ||
package org.jacksonlaboratory.model.entity; | ||
|
||
import org.monarchinitiative.phenol.ontology.data.TermId; | ||
|
||
import java.util.List; | ||
|
||
public class OntologyTermBuilder { | ||
private TermId id; | ||
private String name; | ||
private String definition; | ||
private String comment; | ||
private String synonyms; | ||
private String xrefs; | ||
private int nDescendants; | ||
private List<Translation> translations; | ||
|
||
public OntologyTermBuilder setId(TermId id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setDefinition(String definition) { | ||
this.definition = definition; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setComment(String comment) { | ||
this.comment = comment; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setSynonyms(String synonyms) { | ||
this.synonyms = synonyms; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setXrefs(String xrefs) { | ||
this.xrefs = xrefs; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setDescendantCount(int nDescendants) { | ||
this.nDescendants = nDescendants; | ||
return this; | ||
} | ||
|
||
public OntologyTermBuilder setTranslations(List<Translation> translations) { | ||
this.translations = translations; | ||
return this; | ||
} | ||
|
||
public OntologyTerm createOntologyTerm() { | ||
return new OntologyTerm(id, name, definition, comment, synonyms, xrefs, nDescendants, translations); | ||
} | ||
|
||
public OntologyTermBuilder fromOntologyTerm(OntologyTerm term) { | ||
this.id = term.getTermId(); | ||
this.name = term.getName(); | ||
this.definition = term.getDefinition(); | ||
this.comment = term.getComment(); | ||
this.synonyms = String.join(";", term.getSynonyms()); | ||
this.xrefs = String.join(";", term.getXrefs()); | ||
this.nDescendants = term.getDescendantCount(); | ||
this.translations = term.getTranslations(); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.