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

Output interacting taxon in correct column. #548

Merged
merged 2 commits into from
Sep 12, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ 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(taxonIRI -> {
if (taxonIRI.toString().startsWith(GPADSPARQLExport.TAXON_NAMESPACE)) {
return taxonIRI.toString().replace(GPADSPARQLExport.TAXON_NAMESPACE, "taxon:");
} else return curieHandler.getCuri(taxonIRI);
}).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_";

protected 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
Loading