Skip to content

Commit

Permalink
Merge pull request #638 from biolink/go-site-2030-gorule-0000015-taxo…
Browse files Browse the repository at this point in the history
…ns-should-be-unique

For geneontology/go-site#2030
  • Loading branch information
mugitty committed Aug 23, 2023
2 parents 81d5157 + 0e9c727 commit c622b0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,16 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
if self.allowed_dual_species_terms is not None:
dual = annotation.interacting_taxon is not None
goterm = str(annotation.object.id)
term_in_allowed_dual_species_terms = goterm in self.allowed_dual_species_terms

# dual species have to be unique for multi-organism interactions
if dual and term_in_allowed_dual_species_terms and annotation.interacting_taxon == annotation.subject.taxon:
return self._result(False)

# We fail if we are a dual taxon and then the term is not in this list
# This is the same as dual -> goterm in list
# Implication rewritten is Not P OR Q
passes = not dual or (goterm in self.allowed_dual_species_terms)
passes = not dual or (term_in_allowed_dual_species_terms)

return self._result(passes)

Expand Down
7 changes: 6 additions & 1 deletion tests/test_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,15 @@ def test_go_rules_15():
assert test_result.result_type == qc.ResultType.PASS

assoc.object.id = Curie.from_str("GO:0044215")
assoc.object.id = Curie.from_str("NCBITaxon:123")
assoc.object.taxon = Curie.from_str("NCBITaxon:123")
assoc.interacting_taxon = None # This is the important part, no interacting taxon
test_result = qc.GoRule15().test(assoc, all_rules_config(ontology=ontology))
assert test_result.result_type == qc.ResultType.PASS

assoc.object.id = Curie.from_str("GO:0044419")
assoc.interacting_taxon = Curie.from_str("NCBITaxon:123") # Taxon and interacting taxon are same
test_result = qc.GoRule15().test(assoc, all_rules_config(ontology=ontology))
assert test_result.result_type == qc.ResultType.WARNING

def test_go_rule_16():
# No GO term w/ID
Expand Down

0 comments on commit c622b0a

Please sign in to comment.