diff --git a/OWLTools-Core/src/main/java/owltools/graph/RelationSets.java b/OWLTools-Core/src/main/java/owltools/graph/RelationSets.java index 979145fa9..a32964a53 100644 --- a/OWLTools-Core/src/main/java/owltools/graph/RelationSets.java +++ b/OWLTools-Core/src/main/java/owltools/graph/RelationSets.java @@ -7,7 +7,7 @@ public class RelationSets { public static final String ISA_PARTOF = "is_a/part_of"; public static final String REGULATES = "regulates/is_a/part_of"; - + public static final String REGULATES_ONLY = "regulates/part_of"; /* * Should be using this in most cases. */ @@ -27,6 +27,10 @@ public static List getRelationSet(String relset) { rel_ids.add("RO:0002211"); rel_ids.add("RO:0002212"); rel_ids.add("RO:0002213"); + }else if( relset.equals(REGULATES_ONLY) ){ + rel_ids.add("RO:0002211"); + rel_ids.add("RO:0002212"); + rel_ids.add("RO:0002213"); }else if( relset.equals(COMMON) ){ rel_ids.add("BFO:0000050"); rel_ids.add("BFO:0000066"); diff --git a/OWLTools-Solr/src/main/java/owltools/solrj/GafSolrDocumentLoader.java b/OWLTools-Solr/src/main/java/owltools/solrj/GafSolrDocumentLoader.java index 8a8021410..ca664f25a 100644 --- a/OWLTools-Solr/src/main/java/owltools/solrj/GafSolrDocumentLoader.java +++ b/OWLTools-Solr/src/main/java/owltools/solrj/GafSolrDocumentLoader.java @@ -327,6 +327,8 @@ private void add(Bioentity e) { // added at the end of this section. Map isap_map = new HashMap(); Map reg_map = new HashMap(); + Map reg_only_map = new HashMap(); + for (GeneAnnotation a : gafDocument.getGeneAnnotations(e.getId())) { SolrInputDocument annotation_doc = new SolrInputDocument(); @@ -438,6 +440,12 @@ private void add(Bioentity e) { Map curr_reg_map = addClosureToAnnAndBio(reg, "regulates_closure", "regulates_closure_label", "regulates_closure_map", cls, graph, annotation_doc, bioentity_doc, a.isNegated()); reg_map.putAll(curr_reg_map); // add to aggregate map + + // Regulates ONLY closures. + List reg_only = RelationSets.getRelationSet(RelationSets.REGULATES_ONLY); + Map curr_reg_only_map = addClosureToAnnAndBio(reg_only, "regulates_only_closure", "regulates_only_closure_label", "regulates_only_closure_map", + cls, graph, annotation_doc, bioentity_doc, a.isNegated()); + reg_only_map.putAll(curr_reg_only_map); // add to aggregate map } // Let's piggyback on a little of the work above and cache the extra stuff that we'll be adding to the bioenity at the end @@ -544,7 +552,11 @@ private void add(Bioentity e) { String jsonized_cmap = gson.toJson(reg_map); bioentity_doc.addField("regulates_closure_map", jsonized_cmap); } - + if( ! reg_only_map.isEmpty() ){ + String jsonized_cmap = gson.toJson(reg_only_map); + bioentity_doc.addField("regulates_only_closure_map", jsonized_cmap); + } + // Add c5 to bioentity. // Compile closure map to JSON and add to the document. String jsonized_direct_map = null; diff --git a/OWLTools-Solr/src/test/java/owltools/solrj/GafSolrDocumentLoaderTest.java b/OWLTools-Solr/src/test/java/owltools/solrj/GafSolrDocumentLoaderTest.java index 408bf18d7..2cf82a6b9 100644 --- a/OWLTools-Solr/src/test/java/owltools/solrj/GafSolrDocumentLoaderTest.java +++ b/OWLTools-Solr/src/test/java/owltools/solrj/GafSolrDocumentLoaderTest.java @@ -25,6 +25,7 @@ public class GafSolrDocumentLoaderTest { private static int solrCount = 0; + private static int solrCountWithRegulatesOnly = 0; private static OWLGraphWrapper graph; private static TaxonTools taxonTools = null; private static GafSolrDocumentLoader loader; @@ -36,9 +37,12 @@ public static void setUpBeforeClass() throws Exception { @Override protected void addToServer(Collection docs) throws SolrServerException, IOException { + for (SolrInputDocument doc: docs) { + if (doc.toString().contains("regulates_only_closure")) + solrCountWithRegulatesOnly +=1 ; + } solrCount += docs.size(); } - }; ParserWrapper pw = new ParserWrapper(); pw.addIRIMapper(new CatalogXmlIRIMapper("../OWLTools-Annotation/src/test/resources/rules/ontology/extensions/catalog-v001.xml")); @@ -83,6 +87,6 @@ public void test() throws Exception { loader.load(); assertTrue(solrCount > 0); + assertTrue(solrCountWithRegulatesOnly > 0); } - }