From e1f8e234278f88df242248031ca8d2eda66f99fd Mon Sep 17 00:00:00 2001 From: HyeongSik Kim Date: Fri, 9 Feb 2018 12:45:36 -0800 Subject: [PATCH] Add codes that check aspectmap malformed --- .../inference/BasicAnnotationPropagator.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/OWLTools-Annotation/src/main/java/owltools/gaf/inference/BasicAnnotationPropagator.java b/OWLTools-Annotation/src/main/java/owltools/gaf/inference/BasicAnnotationPropagator.java index f73e8d49c..40768b006 100644 --- a/OWLTools-Annotation/src/main/java/owltools/gaf/inference/BasicAnnotationPropagator.java +++ b/OWLTools-Annotation/src/main/java/owltools/gaf/inference/BasicAnnotationPropagator.java @@ -380,20 +380,32 @@ protected Map createDefaultAspectMap(OWLGraphWrapper graph) { OWLClass mf = graph.getOWLClassByIdentifier("GO:0003674"); // molecular_function if (mf != null) { - map.put(getGoSubOntology(mf, graph), "F"); + String mfKey = getGoSubOntology(mf, graph); + if (mfKey == null) + throw new RuntimeException("Could not retrieve sub-ontology for GO:0003674 (molecular_function). The value of the OBO-namespace tag does not exist."); + + map.put(mfKey, "F"); } OWLClass bp = graph.getOWLClassByIdentifier("GO:0008150"); // biological_process if (bp != null) { - map.put(getGoSubOntology(bp, graph), "P"); + String bpKey = getGoSubOntology(bp, graph); + if (bpKey == null) + throw new RuntimeException("Could not retrieve sub-ontology for GO:0008150 (biological_process). The value of the OBO-namespace tag does not exist."); + + map.put(bpKey, "P"); } OWLClass cc = graph.getOWLClassByIdentifier("GO:0005575"); // cellular_component if (cc != null) { - map.put(getGoSubOntology(cc, graph), "C"); + String ccKey = getGoSubOntology(cc, graph); + if (ccKey == null) + throw new RuntimeException("Could not retrieve sub-ontology for GO:0005575 (celluar_component). The value of the OBO-namespace tag does not exist."); + + map.put(ccKey, "C"); } - if (map.isEmpty()) { + if (map.isEmpty() || map.containsKey(null)) { // only fail if there are mappings // the test case uses a custom ontology, which has no cc branch throw new RuntimeException("Could not create any valid aspect mappings. Is the correct ontology (GO) loaded?");