Skip to content

Commit

Permalink
Merge pull request #262 from geneontology/issue-237-delete-non-small-…
Browse files Browse the repository at this point in the history
…mol-regs

Delete non small mol regulator individuals
  • Loading branch information
dustine32 authored May 24, 2023
2 parents 8f533df + 0f9291d commit ef090f7
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions exchange/src/main/java/org/geneontology/gocam/exchange/GoCAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ private RuleResults convertEntityRegulatorsToBindingFunctions(String model_id, R
BP has_part R
* @return
*/
private RuleResults inferSmallMoleculeRegulators(String model_id, RuleResults r, QRunner tbox_qrunner) {
private RuleResults inferSmallMoleculeRegulators(String model_id, RuleResults r, QRunner tbox_qrunner) {
String entity_regulator_rule = "Entity Regulator Rule";
Integer entity_regulator_count = r.checkInitCount(entity_regulator_rule, r);
Set<String> entity_regulator_pathways = r.checkInitPathways(entity_regulator_rule, r);
Expand Down Expand Up @@ -1552,38 +1552,46 @@ private RuleResults inferSmallMoleculeRegulators(String model_id, RuleResults r,
}
//now get the actual regulating entities
Set<String> regulating_entities = new HashSet<String>();
for(InferredRegulator er : reaction_regulators.get(reaction_uri)) {
for(InferredRegulator er : regs) {
OWLClass entity_type_class = this.df.getOWLClass(IRI.create(er.entity_type_uri));
Set<OWLClass> entity_types = tbox_qrunner.getSuperClasses(entity_type_class, false);
//Only do this for chemical entities but not if nucleic acid or descendant
if(!entity_types.contains(chebi_chemical) || entity_types.contains(chebi_nucleic_acid)) {
continue;
}
entity_types.add(entity_type_class); // Some of these are directly chebi_chemical
//catch cases where there may be more than one of the same entity
//avoid making multiple redundant binding functions for the same entity
if(!regulating_entities.add(er.entity_uri)) {
continue;
}
Set<OWLAnnotation> annos = getDefaultAnnotations();
OWLNamedIndividual regulator = makeUnannotatedIndividual(er.entity_uri);

OWLObjectProperty prop_for_deletion = GoCAM.involved_in_negative_regulation_of;
OWLObjectProperty regulator_prop = GoCAM.has_small_molecule_inhibitor;
String explain = "Entity Regulator Rule. The relation was added to account for an assertion about an entity regulating the target reaction.";
if(er.prop_uri.equals("http://purl.obolibrary.org/obo/RO_0002429")) {
//String reg = " is involved in positive regulation of ";
annos.add(df.getOWLAnnotation(rdfs_comment, df.getOWLLiteral(explain)));
prop_for_deletion = GoCAM.involved_in_positive_regulation_of;
regulator_prop = GoCAM.has_small_molecule_activator;
}else {
//String reg = " is involved in negative regulation of ";
annos.add(df.getOWLAnnotation(rdfs_comment, df.getOWLLiteral(explain)));
}
//Connect the regulator to reaction via has_small_molecule_... relation
addRefBackedObjectPropertyAssertion(reaction, regulator_prop, regulator, Collections.singleton(model_id), GoCAM.eco_inferred_auto, default_namespace_prefix, annos, model_id);

//delete the original entity regulates process relation
applyAnnotatedTripleRemover(regulator.getIRI(), prop_for_deletion.getIRI(), reaction.getIRI());
//Only do this for chemical entities but not if nucleic acid or descendant
if(entity_types.contains(chebi_chemical) && !entity_types.contains(chebi_nucleic_acid)) {
OWLObjectProperty prop_for_deletion = GoCAM.involved_in_negative_regulation_of;
OWLObjectProperty regulator_prop = GoCAM.has_small_molecule_inhibitor;
String explain = "Entity Regulator Rule. The relation was added to account for an assertion about an entity regulating the target reaction.";
if(er.prop_uri.equals("http://purl.obolibrary.org/obo/RO_0002429")) {
//String reg = " is involved in positive regulation of ";
annos.add(df.getOWLAnnotation(rdfs_comment, df.getOWLLiteral(explain)));
prop_for_deletion = GoCAM.involved_in_positive_regulation_of;
regulator_prop = GoCAM.has_small_molecule_activator;
}else {
//String reg = " is involved in negative regulation of ";
annos.add(df.getOWLAnnotation(rdfs_comment, df.getOWLLiteral(explain)));
}
//Connect the regulator to reaction via has_small_molecule_... relation
addRefBackedObjectPropertyAssertion(reaction, regulator_prop, regulator, Collections.singleton(model_id), GoCAM.eco_inferred_auto, default_namespace_prefix, annos, model_id);

//delete the original entity regulates process relation
applyAnnotatedTripleRemover(regulator.getIRI(), prop_for_deletion.getIRI(), reaction.getIRI());
} else {
// Delete individuals and log these out
String deleted_regulator_line = entity_type_class.getIRI().toString();
deleted_regulator_line += "\t"+this.getaLabel(entity_type_class);
deleted_regulator_line += "\t"+reaction_uri.toString();
deleted_regulator_line += "\t"+model_id;
System.out.println("DELETING_NON_SMALL_MOL_REGULATOR\t"+deleted_regulator_line);
deleteOwlEntityAndAllReferencesToIt(regulator);
}
}
}
}
Expand Down

0 comments on commit ef090f7

Please sign in to comment.