use of uk.ac.ebi.biosamples.service.OLSDataRetriever in project biosamples-v4 by EBIBioSamples.
the class OLSDataRetrieverTest method label_retreiving_test.
@Test
public void label_retreiving_test() {
OLSDataRetriever retriever = new OLSDataRetriever();
retriever.readOntologyJsonFromUrl("http://purl.obolibrary.org/obo/NCBITaxon_9606");
String expected_label = "Homo sapiens";
String actual_label = retriever.getOntologyTermLabel();
assertEquals(actual_label, expected_label);
}
use of uk.ac.ebi.biosamples.service.OLSDataRetriever in project biosamples-v4 by EBIBioSamples.
the class PhenopacketConversionHelper method convertAttribute.
public Optional<PhenopacketAttribute> convertAttribute(String type, Attribute attribute) {
Optional<PhenopacketAttribute> optionalPhenopacketAttribute = Optional.empty();
if (!attribute.getIri().isEmpty()) {
try {
OLSDataRetriever retriever = new OLSDataRetriever();
String firstIri = attribute.getIri().first();
retriever.readOntologyJsonFromUrl(firstIri);
optionalPhenopacketAttribute = Optional.of(PhenopacketAttribute.build(type, attribute.getValue(), retriever.getOntologyTermId(), retriever.getOntologyTermLabel()));
} catch (Exception e) {
LOG.warn("Failed to get IRI from OLS, possibly a wrong IRI format: {}", attribute.getIri().first(), e);
}
} else {
optionalPhenopacketAttribute = Optional.of(PhenopacketAttribute.build(type, attribute.getValue(), null, null));
}
return optionalPhenopacketAttribute;
}
use of uk.ac.ebi.biosamples.service.OLSDataRetriever in project biosamples-v4 by EBIBioSamples.
the class PhenopacketConversionHelper method getResource.
public Optional<Resource> getResource(PhenopacketAttribute attribute) {
Optional<Resource> optionalResource = Optional.empty();
if (attribute.getOntologyId() != null) {
String ontology = attribute.getOntologyId().split(":")[0];
OLSDataRetriever retriever = new OLSDataRetriever();
retriever.readResourceInfoFromUrl(ontology);
optionalResource = Optional.of(Resource.newBuilder().setId(retriever.getResourceId()).setName(retriever.getResourceName()).setUrl(retriever.getResourceUrl()).setNamespacePrefix(retriever.getResourcePrefix()).setVersion(retriever.getResourceVersion()).build());
}
return optionalResource;
}
use of uk.ac.ebi.biosamples.service.OLSDataRetriever in project biosamples-v4 by EBIBioSamples.
the class OLSDataRetrieverTest method id_retrieving_test.
@Test
public void id_retrieving_test() {
OLSDataRetriever retriever = new OLSDataRetriever();
retriever.readOntologyJsonFromUrl("http://purl.obolibrary.org/obo/NCBITaxon_9606");
String expected_id = "NCBITaxon:9606";
String actual_id = retriever.getOntologyTermId();
assertEquals(actual_id, expected_id);
}
Aggregations