Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added codes for generating regulation-only closures #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion OWLTools-Core/src/main/java/owltools/graph/RelationSets.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -27,6 +27,10 @@ public static List<String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ private void add(Bioentity e) {
// added at the end of this section.
Map<String, String> isap_map = new HashMap<String, String>();
Map<String, String> reg_map = new HashMap<String, String>();
Map<String, String> reg_only_map = new HashMap<String, String>();

for (GeneAnnotation a : gafDocument.getGeneAnnotations(e.getId())) {
SolrInputDocument annotation_doc = new SolrInputDocument();

Expand Down Expand Up @@ -438,6 +440,12 @@ private void add(Bioentity e) {
Map<String, String> 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<String> reg_only = RelationSets.getRelationSet(RelationSets.REGULATES_ONLY);
Map<String, String> 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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,9 +37,12 @@ public static void setUpBeforeClass() throws Exception {
@Override
protected void addToServer(Collection<SolrInputDocument> 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"));
Expand Down Expand Up @@ -83,6 +87,6 @@ public void test() throws Exception {
loader.load();

assertTrue(solrCount > 0);
assertTrue(solrCountWithRegulatesOnly > 0);
}

}