Search in sources :

Example 1 with TermId

use of com.github.phenomics.ontolib.ontology.data.TermId in project loinc2hpo by monarch-initiative.

the class FhirObservationAnalyzerTest method testUniversalAnnotation.

@Test
public void testUniversalAnnotation() throws Exception {
    FhirObservationAnalyzer.setObservation(observation);
    Map<LoincId, UniversalLoinc2HPOAnnotation> testmap = new HashMap<>();
    LoincId loincId = new LoincId("15074-8");
    LoincScale loincScale = LoincScale.string2enum("Qn");
    TermId low = hpoTermMap.get("Hypoglycemia").getId();
    TermId normal = hpoTermMap.get("Abnormality of blood glucose concentration").getId();
    TermId hi = hpoTermMap.get("Hyperglycemia").getId();
    Map<String, Code> internalCodes = CodeSystemConvertor.getCodeContainer().getCodeSystemMap().get(Loinc2HPOCodedValue.CODESYSTEM);
    /**
     *        UniversalLoinc2HPOAnnotation glucoseAnnotation = new UniversalLoinc2HPOAnnotation(loincId, loincScale);
     *        glucoseAnnotation.addAnnotation(internalCodes.get("L"), new HpoTermId4LoincTest(low, false))
     *                .addAnnotation(internalCodes.get("N"), new HpoTermId4LoincTest(normal, true))
     *                .addAnnotation(internalCodes.get("A"), new HpoTermId4LoincTest(normal, false))
     *                .addAnnotation(internalCodes.get("H"), new HpoTermId4LoincTest(hi, false));
     */
    UniversalLoinc2HPOAnnotation glucoseAnnotation = new UniversalLoinc2HPOAnnotation.Builder().setLoincId(loincId).setLoincScale(loincScale).setLowValueHpoTerm(hpoTermMap.get("Hypoglycemia")).setIntermediateValueHpoTerm(hpoTermMap.get("Abnormality of blood glucose concentration")).setHighValueHpoTerm(hpoTermMap.get("Hyperglycemia")).setIntermediateNegated(true).build();
    testmap.put(loincId, glucoseAnnotation);
    LabTestResultInHPO result = FhirObservationAnalyzer.getHPOFromInterpretation(FhirObservationAnalyzer.getObservation().getInterpretation(), testmap);
    System.out.println(result);
}
Also used : HashMap(java.util.HashMap) TermId(com.github.phenomics.ontolib.ontology.data.TermId) LabTestResultInHPO(org.monarchinitiative.loinc2hpo.testresult.LabTestResultInHPO) Code(org.monarchinitiative.loinc2hpo.codesystems.Code) Test(org.junit.Test)

Example 2 with TermId

use of com.github.phenomics.ontolib.ontology.data.TermId in project loinc2hpo by monarch-initiative.

the class Loinc2HpoConversionTabController method handleConvertButton.

@FXML
void handleConvertButton(ActionEvent event) {
    String path = model.getPathToJsonFhirFile();
    Observation observation = FhirResourceRetriever.parseJsonFile2Observation(path);
    FhirObservationAnalyzer.setObservation(observation);
    LabTestResultInHPO res = FhirObservationAnalyzer.getHPO4ObservationOutcome(model.getLoincIds(), model.getLoincAnnotationMap());
    ObservableList<String> items = FXCollections.observableArrayList();
    if (res == null) {
        items.add(observation.getId() + ": failed not interpret");
    } else {
        TermId id = res.getTermId();
        String name = model.termId2HpoName(id);
        String display = String.format("%s: %s [%s]", observation.getId(), name, id.getIdWithPrefix());
        if (res.isNegated()) {
            display = String.format("%s: NOT %s [%s]", observation.getId(), name, id.getIdWithPrefix());
        }
        items.add(display);
    }
    patientPhenotypeTableView.setItems(items);
}
Also used : Observation(org.hl7.fhir.dstu3.model.Observation) LabTestResultInHPO(org.monarchinitiative.loinc2hpo.testresult.LabTestResultInHPO) TermId(com.github.phenomics.ontolib.ontology.data.TermId) FXML(javafx.fxml.FXML)

Example 3 with TermId

use of com.github.phenomics.ontolib.ontology.data.TermId in project loinc2hpo by monarch-initiative.

the class FromFile method getHpoTermId.

TermId getHpoTermId(String termString) throws MalformedHpoTermIdException {
    logger.trace("getHpoTermId=" + termString);
    if (termString.equalsIgnoreCase("NA"))
        return null;
    int i = termString.indexOf(":");
    if (i != 2)
        throw new MalformedHpoTermIdException("Malformed HPO String: " + termString);
    TermId id = new ImmutableTermId(HPPREFIX, termString.substring(3));
    if (ontology.getTermMap().containsKey(id))
        return id;
    else
        throw new MalformedHpoTermIdException("Could not find id " + termString);
}
Also used : MalformedHpoTermIdException(org.monarchinitiative.loinc2hpo.exception.MalformedHpoTermIdException) ImmutableTermId(com.github.phenomics.ontolib.ontology.data.ImmutableTermId) TermId(com.github.phenomics.ontolib.ontology.data.TermId) ImmutableTermId(com.github.phenomics.ontolib.ontology.data.ImmutableTermId)

Example 4 with TermId

use of com.github.phenomics.ontolib.ontology.data.TermId in project loinc2hpo by monarch-initiative.

the class FhirObservationAnalyzerTest method getHPOFromInterpretation.

@Test
public void getHPOFromInterpretation() throws Exception {
    FhirObservationAnalyzer.setObservation(observation);
    Map<LoincId, UniversalLoinc2HPOAnnotation> testmap = new HashMap<>();
    LoincId loincId = new LoincId("15074-8");
    LoincScale loincScale = LoincScale.string2enum("Qn");
    TermId low = hpoTermMap.get("Hypoglycemia").getId();
    TermId normal = hpoTermMap.get("Abnormality of blood glucose concentration").getId();
    TermId hi = hpoTermMap.get("Hyperglycemia").getId();
    Loinc2HPOAnnotation test1 = new QnLoinc2HPOAnnotation(loincId, loincScale, low, normal, hi);
// testmap.put(loincId, test1);
// LabTestResultInHPO result = FhirObservationAnalyzer.getHPOFromInterpretation(FhirObservationAnalyzer.getObservation().getInterpretation(), testmap);
// System.out.println(result);
}
Also used : QnLoinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.QnLoinc2HPOAnnotation) Loinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.Loinc2HPOAnnotation) HashMap(java.util.HashMap) TermId(com.github.phenomics.ontolib.ontology.data.TermId) QnLoinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.QnLoinc2HPOAnnotation) Test(org.junit.Test)

Example 5 with TermId

use of com.github.phenomics.ontolib.ontology.data.TermId in project loinc2hpo by monarch-initiative.

the class ObservationAnalysisFromCodedValuesTest method setup.

@BeforeClass
public static void setup() throws MalformedLoincCodeException {
    String path = FhirObservationAnalyzerTest.class.getClassLoader().getResource("json/staphylococcus.fhir").getPath();
    Observation observation1 = FhirResourceRetriever.parseJsonFile2Observation(path);
    path = FhirObservationAnalyzerTest.class.getClassLoader().getResource("json/staphylococcusNoInterpretation.fhir").getPath();
    Observation observation2 = FhirResourceRetriever.parseJsonFile2Observation(path);
    path = FhirObservationAnalyzerTest.class.getClassLoader().getResource("json/ecoliNoInterpretation.fhir").getPath();
    Observation observation3 = FhirResourceRetriever.parseJsonFile2Observation(path);
    path = FhirObservationAnalyzerTest.class.getClassLoader().getResource("json/neisseriaNoInterpretation.fhir").getPath();
    Observation observation4 = FhirResourceRetriever.parseJsonFile2Observation(path);
    observations[0] = observation1;
    observations[1] = observation2;
    observations[2] = observation3;
    observations[3] = observation4;
    String hpo_obo = FhirObservationAnalyzerTest.class.getClassLoader().getResource("obo/hp.obo").getPath();
    HpoOboParser hpoOboParser = new HpoOboParser(new File(hpo_obo));
    HpoOntology hpo = null;
    try {
        hpo = hpoOboParser.parse();
    } catch (IOException e) {
        e.printStackTrace();
    }
    ImmutableMap.Builder<String, HpoTerm> termmap = new ImmutableMap.Builder<>();
    ImmutableMap.Builder<TermId, HpoTerm> termmap2 = new ImmutableMap.Builder<>();
    if (hpo != null) {
        List<HpoTerm> res = hpo.getTermMap().values().stream().distinct().collect(Collectors.toList());
        res.forEach(term -> {
            termmap.put(term.getName(), term);
            termmap2.put(term.getId(), term);
        });
    }
    hpoTermMap = termmap.build();
    hpoTermMap2 = termmap2.build();
    UniversalLoinc2HPOAnnotation.Builder loinc2HpoAnnotationBuilder = new UniversalLoinc2HPOAnnotation.Builder();
    LoincId loincId = new LoincId("15074-8");
    LoincScale loincScale = LoincScale.string2enum("Qn");
    HpoTerm low = hpoTermMap.get("Hypoglycemia");
    HpoTerm normal = hpoTermMap.get("Abnormality of blood glucose concentration");
    HpoTerm hi = hpoTermMap.get("Hyperglycemia");
    loinc2HpoAnnotationBuilder.setLoincId(loincId).setLoincScale(loincScale).setLowValueHpoTerm(low).setIntermediateValueHpoTerm(normal).setIntermediateNegated(true).setHighValueHpoTerm(hi);
    UniversalLoinc2HPOAnnotation annotation15074 = loinc2HpoAnnotationBuilder.build();
    testmap.put(loincId, annotation15074);
    loinc2HpoAnnotationBuilder = new UniversalLoinc2HPOAnnotation.Builder();
    loincId = new LoincId("600-7");
    loincScale = LoincScale.string2enum("Nom");
    HpoTerm forCode1 = hpoTermMap.get("Recurrent E. coli infections");
    HpoTerm forCode2 = hpoTermMap.get("Recurrent Staphylococcus aureus infections");
    HpoTerm positive = hpoTermMap.get("Recurrent bacterial infections");
    Code code1 = Code.getNewCode().setSystem("http://snomed.info/sct").setCode("112283007");
    Code code2 = Code.getNewCode().setSystem("http://snomed.info/sct").setCode("3092008");
    loinc2HpoAnnotationBuilder.setLoincId(loincId).setLoincScale(loincScale).setHighValueHpoTerm(positive).addAdvancedAnnotation(code1, new HpoTermId4LoincTest(forCode1, false)).addAdvancedAnnotation(code2, new HpoTermId4LoincTest(forCode2, false));
    UniversalLoinc2HPOAnnotation annotation600 = loinc2HpoAnnotationBuilder.build();
    testmap.put(loincId, annotation600);
}
Also used : HpoOboParser(com.github.phenomics.ontolib.io.obo.hpo.HpoOboParser) IOException(java.io.IOException) Code(org.monarchinitiative.loinc2hpo.codesystems.Code) ImmutableMap(com.google.common.collect.ImmutableMap) HpoTerm(com.github.phenomics.ontolib.formats.hpo.HpoTerm) Observation(org.hl7.fhir.dstu3.model.Observation) TermId(com.github.phenomics.ontolib.ontology.data.TermId) File(java.io.File) HpoOntology(com.github.phenomics.ontolib.formats.hpo.HpoOntology) BeforeClass(org.junit.BeforeClass)

Aggregations

TermId (com.github.phenomics.ontolib.ontology.data.TermId)10 Code (org.monarchinitiative.loinc2hpo.codesystems.Code)6 HpoOntology (com.github.phenomics.ontolib.formats.hpo.HpoOntology)4 HpoTerm (com.github.phenomics.ontolib.formats.hpo.HpoTerm)4 HpoOboParser (com.github.phenomics.ontolib.io.obo.hpo.HpoOboParser)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 File (java.io.File)4 IOException (java.io.IOException)4 Observation (org.hl7.fhir.dstu3.model.Observation)4 ImmutableTermId (com.github.phenomics.ontolib.ontology.data.ImmutableTermId)3 HashMap (java.util.HashMap)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.Test)3 MalformedLoincCodeException (org.monarchinitiative.loinc2hpo.exception.MalformedLoincCodeException)2 LoincId (org.monarchinitiative.loinc2hpo.loinc.LoincId)2 UniversalLoinc2HPOAnnotation (org.monarchinitiative.loinc2hpo.loinc.UniversalLoinc2HPOAnnotation)2 LabTestResultInHPO (org.monarchinitiative.loinc2hpo.testresult.LabTestResultInHPO)2 LocalDateTime (java.time.LocalDateTime)1 LinkedHashMap (java.util.LinkedHashMap)1 FXML (javafx.fxml.FXML)1