Search in sources :

Example 6 with HPO_Class_Found

use of org.monarchinitiative.loinc2hpo.util.HPO_Class_Found in project loinc2hpo by monarch-initiative.

the class SparqlQueryTest method testQueryWithOneKey.

@Test
public void testQueryWithOneKey() {
    String key = "Testosterone";
    String looseQueryString = SparqlQuery.buildLooseQueryWithSingleKey(key);
    String standardQueryString = SparqlQuery.buildStandardQueryWithSingleKey(key);
    // System.out.println("loose query:\n" + looseQueryString);
    // System.out.println("\n\nstandard query:\n" + standardQueryString);
    Query looseQuery = QueryFactory.create(looseQueryString);
    Query standardQuery = QueryFactory.create(standardQueryString);
    assertNotNull(model);
    List<HPO_Class_Found> results_loose = SparqlQuery.query(looseQuery, model, null);
    List<HPO_Class_Found> results_standard = SparqlQuery.query(standardQuery, model, null);
    /**
     *        System.out.println(results_loose.size() + " HPO terms are found!");
     *        for(HPO_Class_Found hpo : results_loose) {
     *            System.out.println(hpo.getLabel() + "\t" + hpo.getId() + "\n" + hpo.getDefinition());
     *        }
     */
    // interesting that this program identifies 16 classes;
    assertEquals(14, results_loose.size());
    // while the same query finds 14 in command line
    // reason: command line uses hp.owl; this program builds a model from hp.owl(?)
    // reason: more likely has something to do with what kind of model is generated from hp.owl
    // System.out.println(results_standard.size()+ " HPO terms are found!");
    assertEquals(9, results_standard.size());
}
Also used : HPO_Class_Found(org.monarchinitiative.loinc2hpo.util.HPO_Class_Found) Query(org.apache.jena.query.Query) SparqlQuery(org.monarchinitiative.loinc2hpo.util.SparqlQuery) Test(org.junit.Test)

Example 7 with HPO_Class_Found

use of org.monarchinitiative.loinc2hpo.util.HPO_Class_Found in project loinc2hpo by monarch-initiative.

the class AnnotateTabController method handleCandidateHPODoubleClick.

@FXML
private void handleCandidateHPODoubleClick(MouseEvent e) {
    if (e.getClickCount() == 2 && hpoListView.getSelectionModel().getSelectedItem() != null && hpoListView.getSelectionModel().getSelectedItem() instanceof HPO_Class_Found) {
        HPO_Class_Found hpo_class_found = (HPO_Class_Found) hpoListView.getSelectionModel().getSelectedItem();
        List<HPO_Class_Found> parents = SparqlQuery.getParents(hpo_class_found.getId());
        List<HPO_Class_Found> children = SparqlQuery.getChildren(hpo_class_found.getId());
        // dummy root node
        TreeItem<HPO_TreeView> rootItem = new TreeItem<>(new HPO_TreeView());
        rootItem.setExpanded(true);
        TreeItem<HPO_TreeView> current = new TreeItem<>(new HPO_TreeView(hpo_class_found));
        // add parent terms to root; add current to each parent term
        parents.stream().map(p -> new TreeItem<>(new HPO_TreeView(p))).forEach(p -> {
            rootItem.getChildren().add(p);
            p.getChildren().add(current);
            p.setExpanded(true);
        });
        current.setExpanded(true);
        // add child terms to current
        children.stream().map(p -> new TreeItem<>(new HPO_TreeView(p))).forEach(current.getChildren()::add);
        this.treeView.setRoot(rootItem);
    }
    e.consume();
}
Also used : HPO_Class_Found(org.monarchinitiative.loinc2hpo.util.HPO_Class_Found) PopUps(org.monarchinitiative.loinc2hpo.gui.PopUps) WriteToFile(org.monarchinitiative.loinc2hpo.io.WriteToFile) javafx.scene.control(javafx.scene.control) Inject(com.google.inject.Inject) Parent(javafx.scene.Parent) Task(javafx.concurrent.Task) ListChangeListener(javafx.collections.ListChangeListener) MalformedLoincCodeException(org.monarchinitiative.loinc2hpo.exception.MalformedLoincCodeException) HpoTerm(com.github.phenomics.ontolib.formats.hpo.HpoTerm) GitHubPopup(org.monarchinitiative.loinc2hpo.gui.GitHubPopup) Circle(javafx.scene.shape.Circle) ImmutableMap(com.google.common.collect.ImmutableMap) LoincLongNameParser(org.monarchinitiative.loinc2hpo.util.LoincLongNameParser) Event(javafx.event.Event) javafx.stage(javafx.stage) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Logger(org.apache.logging.log4j.Logger) Code(org.monarchinitiative.loinc2hpo.codesystems.Code) HPO_Class_Found(org.monarchinitiative.loinc2hpo.util.HPO_Class_Found) ObservableList(javafx.collections.ObservableList) org.monarchinitiative.loinc2hpo.loinc(org.monarchinitiative.loinc2hpo.loinc) LoincCodeNotFoundException(org.monarchinitiative.loinc2hpo.exception.LoincCodeNotFoundException) NetPostException(org.monarchinitiative.loinc2hpo.exception.NetPostException) Singleton(com.google.inject.Singleton) Scene(javafx.scene.Scene) Main(org.monarchinitiative.loinc2hpo.gui.Main) java.util(java.util) Loinc2HPOCodedValue(org.monarchinitiative.loinc2hpo.codesystems.Loinc2HPOCodedValue) LocalDateTime(java.time.LocalDateTime) FXCollections(javafx.collections.FXCollections) GitHubLabelRetriever(org.monarchinitiative.loinc2hpo.github.GitHubLabelRetriever) GitHubPoster(org.monarchinitiative.loinc2hpo.github.GitHubPoster) CodeSystemConvertor(org.monarchinitiative.loinc2hpo.codesystems.CodeSystemConvertor) FXMLLoader(javafx.fxml.FXMLLoader) Annotation(org.monarchinitiative.loinc2hpo.model.Annotation) SparqlQuery(org.monarchinitiative.loinc2hpo.util.SparqlQuery) Callback(javafx.util.Callback) Color(javafx.scene.paint.Color) OntologyModelBuilderForJena(org.monarchinitiative.loinc2hpo.io.OntologyModelBuilderForJena) javafx.scene.input(javafx.scene.input) Model(org.monarchinitiative.loinc2hpo.model.Model) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) LoincOfInterest(org.monarchinitiative.loinc2hpo.io.LoincOfInterest) Injector(com.google.inject.Injector) ActionEvent(javafx.event.ActionEvent) java.io(java.io) LoincCodeClass(org.monarchinitiative.loinc2hpo.util.LoincCodeClass) LogManager(org.apache.logging.log4j.LogManager) FXML(javafx.fxml.FXML)

Example 8 with HPO_Class_Found

use of org.monarchinitiative.loinc2hpo.util.HPO_Class_Found in project loinc2hpo by monarch-initiative.

the class SparqlQueryTest method testQueryWithMultiKeys.

@Test
public void testQueryWithMultiKeys() {
    String[] keys = new String[] { "chronic", "kidney", "disease" };
    String looseQueryString = SparqlQuery.buildLooseQueryWithMultiKeys(Arrays.asList(keys));
    String standardQueryString = SparqlQuery.buildStandardQueryWithMultiKeys(Arrays.asList(keys));
    Query looseQuery = QueryFactory.create(looseQueryString);
    Query standardQuery = QueryFactory.create(standardQueryString);
    List<HPO_Class_Found> itr_loose = SparqlQuery.query(looseQuery, model, null);
    List<HPO_Class_Found> itr_standard = SparqlQuery.query(standardQuery, model, null);
    // System.out.println(itr_loose.size() + " HPO terms are found!");
    assertEquals(7, itr_loose.size());
    // System.out.println(itr_standard.size() + " HPO terms are found!");
    assertEquals(5, itr_standard.size());
}
Also used : HPO_Class_Found(org.monarchinitiative.loinc2hpo.util.HPO_Class_Found) Query(org.apache.jena.query.Query) SparqlQuery(org.monarchinitiative.loinc2hpo.util.SparqlQuery) Test(org.junit.Test)

Aggregations

HPO_Class_Found (org.monarchinitiative.loinc2hpo.util.HPO_Class_Found)8 FXML (javafx.fxml.FXML)4 SparqlQuery (org.monarchinitiative.loinc2hpo.util.SparqlQuery)4 HpoTerm (com.github.phenomics.ontolib.formats.hpo.HpoTerm)3 Test (org.junit.Test)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Inject (com.google.inject.Inject)2 Injector (com.google.inject.Injector)2 Singleton (com.google.inject.Singleton)2 java.io (java.io)2 LocalDateTime (java.time.LocalDateTime)2 java.util (java.util)2 Platform (javafx.application.Platform)2 ReadOnlyStringWrapper (javafx.beans.property.ReadOnlyStringWrapper)2 FXCollections (javafx.collections.FXCollections)2 ListChangeListener (javafx.collections.ListChangeListener)2 ObservableList (javafx.collections.ObservableList)2 Task (javafx.concurrent.Task)2 ActionEvent (javafx.event.ActionEvent)2 Event (javafx.event.Event)2