
org.monarchinitiative.phenol.annotations.io.hpo.HpoDiseaseLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of phenol-annotations Show documentation
Show all versions of phenol-annotations Show documentation
phenol-annotation contains the annotation functionality for ontologies
package org.monarchinitiative.phenol.annotations.io.hpo;
import org.monarchinitiative.phenol.annotations.formats.hpo.HpoDiseases;
import org.monarchinitiative.phenol.ontology.data.Ontology;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.zip.GZIPInputStream;
public interface HpoDiseaseLoader {
/**
* @deprecated to be removed in v2.0.0, use {@link HpoDiseaseLoaders#defaultLoader(org.monarchinitiative.phenol.ontology.data.MinimalOntology, HpoDiseaseLoaderOptions)} instead.
*/
@Deprecated(forRemoval = true)
static HpoDiseaseLoader of(Ontology hpo) {
return of(hpo, HpoDiseaseLoaderOptions.defaultOptions());
}
/**
* @deprecated to be removed in v2.0.0, use {@link HpoDiseaseLoaders#defaultLoader(org.monarchinitiative.phenol.ontology.data.MinimalOntology, HpoDiseaseLoaderOptions)} instead.
*/
@Deprecated(forRemoval = true)
static HpoDiseaseLoader of(Ontology hpo, HpoDiseaseLoaderOptions options) {
return new HpoDiseaseLoaderDefault(hpo, options);
}
HpoDiseases load(InputStream is) throws IOException;
/**
*
* @param path to HPOA file. The file is assumed to be compressed if the file name ends with *.gz.
* @return diseases
* @throws IOException in case of IO errors
*/
default HpoDiseases load(Path path) throws IOException {
try (InputStream is = openForReading(path)) {
return load(is);
}
}
/**
* Get input stream. The input is assumed to be compressed if the file name ends with *.gz.
*/
private static BufferedInputStream openForReading(Path path) throws IOException {
InputStream is = Files.newInputStream(path);
if (path.toFile().getName().endsWith("gz"))
is = new GZIPInputStream(is);
return new BufferedInputStream(is);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy