def test_merge_copies_property_chain_axioms(): nucleus_ontology = ontol_factory.OntologyFactory().create( "tests/resources/nucleus.json") assert len(nucleus_ontology.all_property_chain_axioms) == 0 goslim_ontology = ontol_factory.OntologyFactory().create( "tests/resources/goslim_generic.json") assert len(goslim_ontology.all_property_chain_axioms) == 2 # Test property chain axiom copy in merge nucleus_ontology.merge([goslim_ontology]) assert len(nucleus_ontology.all_property_chain_axioms) == 2
def test_merge_copies_logical_definitions(): pombe_ontology = ontol_factory.OntologyFactory().create( "tests/resources/goslim_pombe.json") assert len(pombe_ontology.all_logical_definitions) == 0 nucleus_ontology = ontol_factory.OntologyFactory().create( "tests/resources/nucleus.json") assert len(nucleus_ontology.all_logical_definitions) == 2 # Test logical definition copy in merge pombe_ontology.merge([nucleus_ontology]) assert len(pombe_ontology.all_property_chain_axioms) == 2
def test_go_rules_15(): assoc = make_annotation(goid="GO:0044419", taxon="taxon:123|taxon:456").associations[0] ontology = ontol_factory.OntologyFactory().create( "tests/resources/go-interspecies-20210520.json") 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:1234567") test_result = qc.GoRule15().test(assoc, all_rules_config(ontology=ontology)) assert test_result.result_type == qc.ResultType.WARNING assoc.object.id = Curie.from_str("GO:0002812") 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:0044215") assoc.object.id = 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
def test_ontology_synonyms(): ontology = ontol_factory.OntologyFactory().create( "tests/resources/nucleus_new.json") syn = ontology.synonyms("GO:0005634") assert syn[0].__dict__ == ontol.Synonym( "GO:0005634", val="cell nucleus", pred="hasExactSynonym", lextype=None, xrefs=[], ontology=None, confidence=1.0, synonymType="http://purl.obolibrary.org/obo/go-test#systematic_synonym" ).__dict__
def make_ontology(input_ontology): click.echo("Loading ontology...") ontology_factory = ontol_factory.OntologyFactory() return ontology_factory.create(input_ontology)
def make_ontology(input_ontology): ontology_factory = ontol_factory.OntologyFactory() return ontology_factory.create(input_ontology)
import datetime import yaml import json from ontobio.model import association from ontobio.model.association import Curie from ontobio.io import qc from ontobio.io import gaference from ontobio.io import assocparser from ontobio.io import gafparser from ontobio.io import gpadparser from ontobio import ontol, ontol_factory import copy ontology = ontol_factory.OntologyFactory().create( "tests/resources/goslim_generic.json") def make_annotation(db="blah", db_id="blah12345", db_obj_symb="blah", qualifier="", negated=False, goid="GO:1234567", references="BLAH:54321", evidence="IDA", withfrom="BLAH:12345", aspect="C", db_obj_name="", db_obj_syn="", db_obj_type="blah",
def test_missing_node_is_none(): ontology = ontol_factory.OntologyFactory().create( "tests/resources/goslim_generic.json") assert ontology.node("GO:0") == None