Search in sources :

Example 1 with OLSDataRetriever

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);
}
Also used : OLSDataRetriever(uk.ac.ebi.biosamples.service.OLSDataRetriever) Test(org.junit.Test)

Example 2 with OLSDataRetriever

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;
}
Also used : OLSDataRetriever(uk.ac.ebi.biosamples.service.OLSDataRetriever)

Example 3 with OLSDataRetriever

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;
}
Also used : OLSDataRetriever(uk.ac.ebi.biosamples.service.OLSDataRetriever) Resource(org.phenopackets.schema.v1.core.Resource)

Example 4 with OLSDataRetriever

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);
}
Also used : OLSDataRetriever(uk.ac.ebi.biosamples.service.OLSDataRetriever) Test(org.junit.Test)

Aggregations

OLSDataRetriever (uk.ac.ebi.biosamples.service.OLSDataRetriever)4 Test (org.junit.Test)2 Resource (org.phenopackets.schema.v1.core.Resource)1