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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations