Skip to content

Commit

Permalink
Restrict instance sharing to SmallMol BioPAX classes for #308
Browse files Browse the repository at this point in the history
  • Loading branch information
dustine32 committed Mar 13, 2024
1 parent f3dbe9c commit ba4f248
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1318,20 +1318,21 @@ else if (entity instanceof Interaction){

if(inputs!=null) {
for(PhysicalEntity input : inputs) {
String entity_ref_id = getEntityReferenceId(input);
IRI i_iri = null;
OWLNamedIndividual input_entity = null;
String input_id = null;
if (entityStrategy.equals(EntityStrategy.REACTO)) {
input_id = getReactomeId(input); // This should be Reactome ID for IRI
}
else {
input_id = getEntityReferenceId(input);
input_id = entity_ref_id;
}
if(input_id==null){ //failed to find a chebi reference
input_id = UUID.randomUUID().toString();
}
String input_location = null;
if (small_mol_do_not_join_ids.contains(input_id) || input.getCellularLocation() == null) {
if (small_mol_do_not_join_ids.contains(entity_ref_id) || input.getCellularLocation() == null || !(input instanceof SmallMolecule)) {
// Gotta make these locations specific to rxn ID for do_not_join classes
input_location = entity_id;
} else {
Expand All @@ -1341,7 +1342,7 @@ else if (entity instanceof Interaction){
}
input_location = String.join("_", in_location_terms);
}
if(!small_mol_do_not_join_ids.contains(input_id)){
if(!small_mol_do_not_join_ids.contains(entity_ref_id) && input instanceof SmallMolecule){
// Try to reuse previous rxn's output instance
for(PathwayStep previous_step : previous_steps) {
BiochemicalReaction reaction = getBiochemicalReaction(previous_step);
Expand All @@ -1367,19 +1368,20 @@ else if (entity instanceof Interaction){
}}
if(outputs!=null) {
for(PhysicalEntity output : outputs) {
String entity_ref_id = getEntityReferenceId(output);
IRI o_iri = null;
String output_id = null;
if (entityStrategy.equals(EntityStrategy.REACTO)) {
output_id = getReactomeId(output); // This should be Reactome ID for IRI
}
else {
output_id = getEntityReferenceId(output);
output_id = entity_ref_id;
}
if(output_id==null) {
output_id = UUID.randomUUID().toString();
}
String output_location = null;
if (small_mol_do_not_join_ids.contains(output_id) || output.getCellularLocation() == null) {
if (small_mol_do_not_join_ids.contains(entity_ref_id) || output.getCellularLocation() == null) {
// Gotta make these locations specific to rxn ID for do_not_join classes
output_location = entity_id;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,55 @@ public final void testInferRegulatesViaOutputEnables() {
System.out.println("Done testing regulates via output enables");
}

//gomodel:R-HSA-4641262/R-HSA-201677 / RO:0002413 / gomodel:R-HSA-4641262/R-HSA-201691
// #inferProvidesInput
/**
* Test method for {@link org.geneontology.gocam.exchange.GoCAM#inferProvidesInput}.
* Use pathway R-HSA-4641262 , reaction1 = R-HSA-201677 reaction2 = R-HSA-201691
* Relation should be RO:0002413 directly positive regulates
* Phosphorylation of LRP5/6 cytoplasmic domain by membrane-associated GSK3beta
* Phosphorylation of LRP5/6 cytoplasmic domain by CSNKI
* https://reactome.org/content/detail/R-HSA-4641262
* Compare to http://noctua-dev.berkeleybop.org/editor/graph/gomodel:R-HSA-4641262
*
* Also an active site detection test
*/
@Test
public final void testInferProvidesInput() {
System.out.println("Testing provides input");
TupleQueryResult result = null;
try {
result = blaze.runSparqlQuery(
"prefix obo: <http://purl.obolibrary.org/obo/> "
+ "select ?pathway " +
"where { " +
"VALUES ?reaction1 { <http://model.geneontology.org/R-HSA-201677> } . "+
"VALUES ?reaction2 { <http://model.geneontology.org/R-HSA-201691> } . "+
" ?reaction1 obo:RO_0002413 ?reaction2 . "
+ "?reaction1 obo:BFO_0000050 ?pathway "+
"}");
int n = 0; String pathway = null;
while (result.hasNext()) {
BindingSet bindingSet = result.next();
pathway = bindingSet.getValue("pathway").stringValue();
n++;
}
assertTrue(n==1);
assertTrue("got "+pathway, pathway.equals("http://model.geneontology.org/R-HSA-4641262/R-HSA-4641262"));
} catch (QueryEvaluationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
result.close();
} catch (QueryEvaluationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println("Done testing regulates via output enables");
}

@Test
public final void testSharedIntermediateInputs() {
System.out.println("Testing provides input");
Expand All @@ -1023,8 +1072,8 @@ public final void testSharedIntermediateInputs() {
"prefix obo: <http://purl.obolibrary.org/obo/> "
+ "select ?pathway " +
"where { " +
"VALUES ?reaction1 { <http://model.geneontology.org/R-HSA-201677> } . "+
"VALUES ?reaction2 { <http://model.geneontology.org/R-HSA-201691> } . "+
"VALUES ?reaction1 { <http://model.geneontology.org/R-HSA-70667> } . "+
"VALUES ?reaction2 { <http://model.geneontology.org/R-HSA-70679> } . "+
" ?reaction1 obo:RO_0002234 ?small_mol . " +
" ?reaction2 obo:RO_0002233 ?small_mol . "
+ "?reaction1 obo:BFO_0000050 ?pathway "+
Expand All @@ -1036,7 +1085,7 @@ public final void testSharedIntermediateInputs() {
n++;
}
assertTrue(n==1);
assertTrue("got "+pathway, pathway.equals("http://model.geneontology.org/R-HSA-4641262/R-HSA-4641262"));
assertTrue("got "+pathway, pathway.equals("http://model.geneontology.org/R-HSA-70688/R-HSA-70688"));
} catch (QueryEvaluationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down

0 comments on commit ba4f248

Please sign in to comment.