Skip to content

Commit

Permalink
Output interacting taxon in correct column.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Jul 29, 2024
1 parent be87c34 commit 35b7fe2
Show file tree
Hide file tree
Showing 4 changed files with 8,613 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public String render(GPADData data) {
columns.add(data.getReference());
columns.add(curieHandler.getCuri(data.getEvidence()));
columns.add(data.getWithOrFrom().orElse(""));
columns.add(""); // not using interacting taxon in LEGO models
columns.add(data.getInteractingTaxonID().map(curieHandler::getCuri).orElse(""));
columns.add(formatDate(data.getModificationDate()));
columns.add(data.getAssignedBy());
columns.add(formatAnnotationExtensions(data.getAnnotationExtensions()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ public class GPADSPARQLExport {
private static final String BP = "http://purl.obolibrary.org/obo/GO_0008150";
private static final String CC = "http://purl.obolibrary.org/obo/GO_0005575";
private static final Set<String> rootTerms = new HashSet<>(Arrays.asList(MF, BP, CC));

private static final String HAS_INPUT = "http://purl.obolibrary.org/obo/RO_0002233";
private static final String ENABLES = "http://purl.obolibrary.org/obo/RO_0002327";
private static final String CONTRIBUTES_TO = "http://purl.obolibrary.org/obo/RO_0002326";
private static final Set<String> functionRelations = new HashSet<>(Arrays.asList(ENABLES, CONTRIBUTES_TO));
private static final String EMAPA_NAMESPACE = "http://purl.obolibrary.org/obo/EMAPA_";
private static final String UBERON_NAMESPACE = "http://purl.obolibrary.org/obo/UBERON_";

private static final String TAXON_NAMESPACE = "http://purl.obolibrary.org/obo/NCBITaxon_";
private static final String inconsistentQuery =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
Expand Down Expand Up @@ -167,13 +171,18 @@ public Set<GPADData> getGPAD(WorkingMemory wm, IRI modelIRI) throws Inconsistent
annotationEvidences.forEach(currentEvidence -> {
String reference = currentEvidence.getReference();
Set<ConjunctiveExpression> goodExtensions = new HashSet<>();
Optional<IRI> interactingTaxon = Optional.empty();
for (AnnotationExtension extension : possibleExtensions) {
if (extension.getTriple().getSubject().equals(annotation.getOntologyClassNode()) && !(extension.getTriple().getObject().equals(annotation.getObjectNode()))) {
for (Explanation expl : allExplanations.get(extension.getTriple())) {
boolean allFactsOfExplanationHaveRefMatchingAnnotation = toJava(expl.facts()).stream().map(fact -> allEvidences.getOrDefault(Bridge.jenaFromTriple(fact), Collections.emptySet())).allMatch(evidenceSet ->
evidenceSet.stream().anyMatch(ev -> ev.getReference().equals(reference)));
if (allFactsOfExplanationHaveRefMatchingAnnotation) {
goodExtensions.add(new DefaultConjunctiveExpression(IRI.create(extension.getTriple().getPredicate().getURI()), extension.getValueType()));
if (!interactingTaxon.isPresent() && extension.getTriple().getPredicate().getURI().equals(HAS_INPUT) && extension.getValueType().toString().startsWith(TAXON_NAMESPACE)) {
interactingTaxon = Optional.of(extension.getValueType());
} else {
goodExtensions.add(new DefaultConjunctiveExpression(IRI.create(extension.getTriple().getPredicate().getURI()), extension.getValueType()));
}
}
}
}
Expand All @@ -191,7 +200,7 @@ public Set<GPADData> getGPAD(WorkingMemory wm, IRI modelIRI) throws Inconsistent
final boolean rootMFWithOtherMF = annotation.getOntologyClass().toString().equals(MF) && gpsWithAnyMFNotRootMF.contains(annotation.getObject());
if (!rootViolation && !rootMFWithOtherMF) {
DefaultGPADData defaultGPADData = new DefaultGPADData(annotation.getObject(), annotation.getQualifier(), annotation.getOntologyClass(), goodExtensions,
reference, currentEvidence.getEvidence(), currentEvidence.getWithOrFrom(), Optional.empty(), currentEvidence.getModificationDate(),
reference, currentEvidence.getEvidence(), currentEvidence.getWithOrFrom(), interactingTaxon, currentEvidence.getModificationDate(),
currentEvidence.getAssignedBy(), currentEvidence.getAnnotations());
defaultGPADData.setOperator(annotation.getOperator());
annotations.add(defaultGPADData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,21 @@ public void testFilterAnnotationsToRegulatedProcess() throws Exception {
Assert.assertTrue(annotations.stream().noneMatch(a -> a.getObject().equals(gene) && a.getOntologyClass().equals(regulated)));
}

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

}
Loading

0 comments on commit 35b7fe2

Please sign in to comment.