-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding data resolver with tests, renaming package from jacksonlaborat…
…ory to jax
- Loading branch information
Showing
34 changed files
with
333 additions
and
80 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
9 changes: 0 additions & 9 deletions
9
oan-etl/src/main/java/org/jacksonlaboratory/ontology/GraphLoader.java
This file was deleted.
Oops, something went wrong.
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
4 changes: 2 additions & 2 deletions
4
...g/jacksonlaboratory/graph/Operations.java → ...in/java/org/jax/oan/graph/Operations.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
10 changes: 10 additions & 0 deletions
10
oan-etl/src/main/java/org/jax/oan/ontology/GraphLoader.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,10 @@ | ||
package org.jax.oan.ontology; | ||
|
||
import org.jax.oan.exception.OntologyAnnotationNetworkException; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
public interface GraphLoader { | ||
void load(Path dataDirectory) throws IOException, OntologyAnnotationNetworkException; | ||
} |
70 changes: 70 additions & 0 deletions
70
oan-etl/src/main/java/org/jax/oan/ontology/HpoDataResolver.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,70 @@ | ||
package org.jax.oan.ontology; | ||
|
||
import org.jax.oan.exception.OntologyAnnotationNetworkDataException; | ||
import org.jax.oan.exception.OntologyAnnotationNetworkException; | ||
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; | ||
|
||
public class HpoDataResolver { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(HpoDataResolver.class); | ||
|
||
private final Path dataDirectory; | ||
public static HpoDataResolver of(Path dataDirectory) throws OntologyAnnotationNetworkException { | ||
return new HpoDataResolver(dataDirectory); | ||
} | ||
|
||
private HpoDataResolver(Path dataDirectory) throws OntologyAnnotationNetworkException { | ||
Objects.requireNonNull(dataDirectory, "Data directory must not be null!"); | ||
this.dataDirectory = dataDirectory; | ||
validateHpoFiles(); | ||
} | ||
|
||
private void validateHpoFiles() throws OntologyAnnotationNetworkException { | ||
boolean error = false; | ||
List<Path> requiredFiles = List.of(hpJson(), hgncCompleteSet(), mim2geneMedgen(), phenotypeAnnotations(), | ||
orpha2Gene(), loinc()); | ||
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 OntologyAnnotationNetworkDataException("Missing one or more required files in OntologyAnnotationNetwork data directory!"); | ||
} | ||
} | ||
|
||
|
||
public Path dataDirectory() { | ||
return dataDirectory; | ||
} | ||
|
||
public Path hpJson(){ | ||
return dataDirectory.resolve("hp-simple-non-classified.json"); | ||
} | ||
|
||
public Path hgncCompleteSet() { | ||
return dataDirectory.resolve("hgnc_complete_set.txt"); | ||
} | ||
|
||
public Path mim2geneMedgen() { | ||
return dataDirectory.resolve("mim2gene_medgen"); | ||
} | ||
|
||
public Path phenotypeAnnotations() { | ||
return dataDirectory.resolve("phenotype.hpoa"); | ||
} | ||
|
||
public Path orpha2Gene(){ | ||
return dataDirectory.resolve("en_product6.xml"); | ||
} | ||
|
||
public Path loinc(){ | ||
return dataDirectory.resolve("loinc2hpo-annotations-merged.tsv"); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...cksonlaboratory/graph/OperationsTest.java → ...ava/org/jax/oan/graph/OperationsTest.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
29 changes: 29 additions & 0 deletions
29
oan-etl/src/test/java/org/jax/oan/ontology/HpoDataResolverTest.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,29 @@ | ||
package org.jax.oan.ontology; | ||
|
||
import org.jax.oan.exception.OntologyAnnotationNetworkDataException; | ||
import org.jax.oan.exception.OntologyAnnotationNetworkException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class HpoDataResolverTest { | ||
|
||
@Test | ||
void of() throws OntologyAnnotationNetworkException { | ||
Path dataDirectory = Path.of("src/test/resources"); | ||
HpoDataResolver dataResolver = HpoDataResolver.of(dataDirectory); | ||
assertEquals(dataResolver.hpJson(), dataDirectory.resolve("hp-simple-non-classified.json")); | ||
assertEquals(dataResolver.mim2geneMedgen(), dataDirectory.resolve("mim2gene_medgen")); | ||
assertEquals(dataResolver.hgncCompleteSet(), dataDirectory.resolve("hgnc_complete_set.txt")); | ||
assertEquals(dataResolver.phenotypeAnnotations(), dataDirectory.resolve("phenotype.hpoa")); | ||
assertEquals(dataResolver.loinc(), dataDirectory.resolve("loinc2hpo-annotations-merged.tsv")); | ||
assertEquals(dataDirectory, dataResolver.dataDirectory()); | ||
} | ||
|
||
@Test | ||
void error() { | ||
assertThrows(OntologyAnnotationNetworkDataException.class, () -> HpoDataResolver.of(Path.of("src/main/resources"))); | ||
} | ||
} |
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
Oops, something went wrong.