Skip to content

Commit 7197be2

Browse files
committed
Merge branch 'issue-545' into dev
2 parents 1b7be26 + 35b7fe2 commit 7197be2

File tree

5 files changed

+8617
-3
lines changed

5 files changed

+8617
-3
lines changed

minerva-converter/src/main/java/org/geneontology/minerva/legacy/sparql/GPADRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public String render(GPADData data) {
4646
columns.add(data.getReference());
4747
columns.add(curieHandler.getCuri(data.getEvidence()));
4848
columns.add(data.getWithOrFrom().orElse(""));
49-
columns.add(""); // not using interacting taxon in LEGO models
49+
columns.add(data.getInteractingTaxonID().map(curieHandler::getCuri).orElse(""));
5050
columns.add(formatDate(data.getModificationDate()));
5151
columns.add(data.getAssignedBy());
5252
columns.add(formatAnnotationExtensions(data.getAnnotationExtensions()));

minerva-converter/src/main/java/org/geneontology/minerva/legacy/sparql/GPADSPARQLExport.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ public class GPADSPARQLExport {
4343
private static final String BP = "http://purl.obolibrary.org/obo/GO_0008150";
4444
private static final String CC = "http://purl.obolibrary.org/obo/GO_0005575";
4545
private static final Set<String> rootTerms = new HashSet<>(Arrays.asList(MF, BP, CC));
46+
47+
private static final String HAS_INPUT = "http://purl.obolibrary.org/obo/RO_0002233";
4648
private static final String ENABLES = "http://purl.obolibrary.org/obo/RO_0002327";
4749
private static final String CONTRIBUTES_TO = "http://purl.obolibrary.org/obo/RO_0002326";
4850
private static final Set<String> functionRelations = new HashSet<>(Arrays.asList(ENABLES, CONTRIBUTES_TO));
4951
private static final String EMAPA_NAMESPACE = "http://purl.obolibrary.org/obo/EMAPA_";
5052
private static final String UBERON_NAMESPACE = "http://purl.obolibrary.org/obo/UBERON_";
53+
54+
private static final String TAXON_NAMESPACE = "http://purl.obolibrary.org/obo/NCBITaxon_";
5155
private static final String inconsistentQuery =
5256
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
5357
"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
@@ -167,13 +171,18 @@ public Set<GPADData> getGPAD(WorkingMemory wm, IRI modelIRI) throws Inconsistent
167171
annotationEvidences.forEach(currentEvidence -> {
168172
String reference = currentEvidence.getReference();
169173
Set<ConjunctiveExpression> goodExtensions = new HashSet<>();
174+
Optional<IRI> interactingTaxon = Optional.empty();
170175
for (AnnotationExtension extension : possibleExtensions) {
171176
if (extension.getTriple().getSubject().equals(annotation.getOntologyClassNode()) && !(extension.getTriple().getObject().equals(annotation.getObjectNode()))) {
172177
for (Explanation expl : allExplanations.get(extension.getTriple())) {
173178
boolean allFactsOfExplanationHaveRefMatchingAnnotation = toJava(expl.facts()).stream().map(fact -> allEvidences.getOrDefault(Bridge.jenaFromTriple(fact), Collections.emptySet())).allMatch(evidenceSet ->
174179
evidenceSet.stream().anyMatch(ev -> ev.getReference().equals(reference)));
175180
if (allFactsOfExplanationHaveRefMatchingAnnotation) {
176-
goodExtensions.add(new DefaultConjunctiveExpression(IRI.create(extension.getTriple().getPredicate().getURI()), extension.getValueType()));
181+
if (!interactingTaxon.isPresent() && extension.getTriple().getPredicate().getURI().equals(HAS_INPUT) && extension.getValueType().toString().startsWith(TAXON_NAMESPACE)) {
182+
interactingTaxon = Optional.of(extension.getValueType());
183+
} else {
184+
goodExtensions.add(new DefaultConjunctiveExpression(IRI.create(extension.getTriple().getPredicate().getURI()), extension.getValueType()));
185+
}
177186
}
178187
}
179188
}
@@ -191,7 +200,7 @@ public Set<GPADData> getGPAD(WorkingMemory wm, IRI modelIRI) throws Inconsistent
191200
final boolean rootMFWithOtherMF = annotation.getOntologyClass().toString().equals(MF) && gpsWithAnyMFNotRootMF.contains(annotation.getObject());
192201
if (!rootViolation && !rootMFWithOtherMF) {
193202
DefaultGPADData defaultGPADData = new DefaultGPADData(annotation.getObject(), annotation.getQualifier(), annotation.getOntologyClass(), goodExtensions,
194-
reference, currentEvidence.getEvidence(), currentEvidence.getWithOrFrom(), Optional.empty(), currentEvidence.getModificationDate(),
203+
reference, currentEvidence.getEvidence(), currentEvidence.getWithOrFrom(), interactingTaxon, currentEvidence.getModificationDate(),
195204
currentEvidence.getAssignedBy(), currentEvidence.getAnnotations());
196205
defaultGPADData.setOperator(annotation.getOperator());
197206
annotations.add(defaultGPADData);

minerva-converter/src/main/resources/org/geneontology/minerva/legacy/sparql/gpad-extensions.rq

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ VALUES ?extension_rel {
4141
<http://purl.obolibrary.org/obo/RO_0001025>
4242
<http://purl.obolibrary.org/obo/RO_0002007>
4343
<http://purl.obolibrary.org/obo/RO_0002008>
44+
<http://purl.obolibrary.org/obo/RO_0002011>
4445
<http://purl.obolibrary.org/obo/RO_0002087>
4546
<http://purl.obolibrary.org/obo/RO_0002090>
4647
<http://purl.obolibrary.org/obo/RO_0002092>
@@ -90,11 +91,14 @@ VALUES ?extension_rel {
9091
<http://purl.obolibrary.org/obo/RO_0002429>
9192
<http://purl.obolibrary.org/obo/RO_0002430>
9293
<http://purl.obolibrary.org/obo/RO_0002431>
94+
<http://purl.obolibrary.org/obo/RO_0002491>
9395
<http://purl.obolibrary.org/obo/RO_0002495>
9496
<http://purl.obolibrary.org/obo/RO_0002565>
9597
<http://purl.obolibrary.org/obo/RO_0002578>
9698
<http://purl.obolibrary.org/obo/RO_0002629>
9799
<http://purl.obolibrary.org/obo/RO_0002630>
100+
<http://purl.obolibrary.org/obo/RO_0004008>
101+
<http://purl.obolibrary.org/obo/RO_0004009>
98102
}
99103

100104
?target ?extension_rel ?extension .

minerva-converter/src/test/java/org/geneontology/minerva/legacy/sparql/GPADSPARQLTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,21 @@ public void testFilterAnnotationsToRegulatedProcess() throws Exception {
180180
Assert.assertTrue(annotations.stream().noneMatch(a -> a.getObject().equals(gene) && a.getOntologyClass().equals(regulated)));
181181
}
182182

183+
@Test
184+
public void testInteractingTaxon() {
185+
Model model = ModelFactory.createDefaultModel();
186+
model.read(this.getClass().getResourceAsStream("/MGI_MGI_2429397.ttl"), "", "ttl");
187+
Set<Triple> triples = model.listStatements().toList().stream().map(s -> Bridge.tripleFromJena(s.asTriple())).collect(Collectors.toSet());
188+
WorkingMemory mem = arachne.processTriples(JavaConverters.asScalaSetConverter(triples).asScala());
189+
Set<GPADData> annotations = exporter.getGPAD(mem, IRI.create("http://test.org"));
190+
IRI gene = IRI.create("http://identifiers.org/mgi/MGI:2429397");
191+
IRI interactingTaxon = IRI.create("http://purl.obolibrary.org/obo/NCBITaxon_196620");
192+
Assert.assertTrue(annotations.stream().anyMatch(
193+
a -> a.getObject().equals(gene) &&
194+
a.getInteractingTaxonID().isPresent() &&
195+
a.getInteractingTaxonID().get().equals(interactingTaxon)));
196+
Assert.assertTrue(annotations.stream().noneMatch(a ->
197+
a.getAnnotationExtensions().stream().anyMatch(ce -> ce.getFiller().equals(interactingTaxon))));
198+
}
199+
183200
}

0 commit comments

Comments
 (0)