Пример #1
0
def test_upgrade_qualifiers_for_cell_component():
    line = [
        "SGD", "S000000819", "AFG3", "", "GO:0008372",
        "PMID:8681382|SGD_REF:S000055187", "IMP", "", "P",
        "Mitochondrial inner membrane m-AAA protease component",
        "YER017C|AAA family ATPase AFG3|YTA10", "gene", "taxon:559292",
        "20170428", "SGD"
    ]
    ontology = OntologyFactory().create("tests/resources/goslim_generic.json")
    p = GafParser(config=assocparser.AssocParserConfig(ontology=ontology))
    p.make_internal_cell_component_closure()

    parsed = gafparser.to_association(line)
    assoc = p.upgrade_empty_qualifier(parsed.associations[0])
    assert assoc.qualifiers[0] == association.Curie(namespace="RO",
                                                    identity="0002432")
Пример #2
0
def test_gorule58():
    a = ["blah"] * 16

    a[0] = "HELLO"
    a[1] = "123"
    a[3] = ""
    a[4] = "GO:0003674"
    a[6] = "IBA"
    a[5] = "PMID:21873635"
    a[8] = "P"
    a[9] = "MGI"
    a[10] = ""
    a[11] = ""
    a[14] = "GO_Central"
    a[15] = "has_input(GO:0003674),occurs_in(CL:123456)"

    with open("tests/resources/extensions-constraints.yaml") as exs_cons:
        config = assocparser.AssocParserConfig(
            ontology=ontology,
            extensions_constraints=yaml.load(exs_cons, Loader=yaml.FullLoader))

    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule58().test(assoc, config)
    assert test_result.result_type == qc.ResultType.PASS

    # Fails because `not_relation` is not an allowed relation
    a[15] = "not_relation(GO:987),occurs_in(CL:1234567)|occurs_in(CL:12345)"
    assoc = gafparser.to_association(a).associations[0]
    test_result = qc.GoRule58().test(assoc, config)
    a[15] = "occurs_in(CL:12345)"
    expected_repair = gafparser.to_association(a).associations[0]
    expected_repair.source_line = assoc.source_line  # Make sure original line is the same as test case
    assert test_result.result_type == qc.ResultType.WARNING
    assert test_result.result == expected_repair

    # Fails because `FOO` is not a real namespace for any `has_input` constraint
    a[15] = "has_input(FOO:1234566),occurs_in(CL:1234567)"
    assoc = gafparser.to_association(a).associations[0]
    test_result = qc.GoRule58().test(assoc, config)
    assert test_result.result_type == qc.ResultType.WARNING

    # Fails because this GO term is not in the constraint term children
    a[4] = "GO:0005575"
    a[15] = "occurs_in(EMAPA:123),has_input(CL:1234567)"
    assoc = gafparser.to_association(a).associations[0]
    test_result = qc.GoRule58().test(assoc, config)
    assert test_result.result_type == qc.ResultType.WARNING

    # Fails because of a cardinality check
    a[4] = "GO:0003674"
    a[15] = "occurs_in(EMAPA:123),occurs_in(EMAPA:1987654)"
    assoc = gafparser.to_association(a).associations[0]
    test_result = qc.GoRule58().test(assoc, config)
    assert test_result.result_type == qc.ResultType.WARNING
Пример #3
0
def test_go_rule_17():
    # IDA with anything in withfrom
    a = ["blah"] * 15
    a[3] = ""
    a[6] = "IDA"
    a[7] = "BLAH:12345"
    a[8] = "P"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule17().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.WARNING

    # Nothing in withfrom, passes
    assoc.evidence.with_support_from = []
    test_result = qc.GoRule17().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #4
0
def test_all_rules():
    # pass
    config = assocparser.AssocParserConfig(ontology=ontology)
    a = ["blah"] * 15
    a[3] = ""
    a[4] = "GO:0006397"
    a[6] = "ISS"
    a[8] = "P"
    a[13] = "20180330"
    assoc = gafparser.to_association(a).associations[0]

    test_results = qc.test_go_rules(assoc, config).all_results
    assert len(test_results.keys()) == 22
    assert test_results[
        qc.GoRules.GoRule26.value].result_type == qc.ResultType.PASS
    assert test_results[
        qc.GoRules.GoRule29.value].result_type == qc.ResultType.PASS
Пример #5
0
def test_gorule42():
    a = ["blah"] * 15
    a[3] = "NOT"
    a[6] = "IKR"
    a[8] = "P"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule42().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    assoc.evidence.type = "ECO:0000305"  # Not IKR so this rule is fine
    test_result = qc.GoRule42().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    assoc.evidence.type = "ECO:0000320"
    assoc.negated = False  # Not negated, so wrong
    test_result = qc.GoRule42().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR
Пример #6
0
def test_go_rule02():
    a = ["blah"] * 15
    a[3] = "NOT"
    a[4] = "GO:0005515"
    a[8] = "F"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule02().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.WARNING

    assoc.negated = False
    test_result = qc.GoRule02().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    assoc.negated = True
    assoc.object.id = "GO:0003674"
    test_result = qc.GoRule02().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #7
0
def test_gorule55():
    a = ["blah"] * 15
    a[0] = "HELLO"
    a[1] = "123"
    a[3] = ""
    a[5] = "GO:0012345|GO:1234567"
    a[6] = "ISS"
    a[7] = "HELLO:123"
    a[8] = "P"
    a[13] = "20200303"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule55().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.WARNING

    assoc.evidence.has_supporting_reference = ["GO:0001234", "PMID:123456"]
    test_result = qc.GoRule55().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #8
0
def test_gorule39():
    a = ["blah"] * 15
    a[0] = "ComplexPortal"
    a[3] = ""
    a[4] = "GO:0032991"
    a[8] = "C"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule39().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    assoc.subject.id = "FB:1234"
    test_result = qc.GoRule39().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    assoc.subject.id = "ComplexPortal:12345"
    assoc.object.id = "GO:0000023"
    test_result = qc.GoRule39().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #9
0
def test_all_rules():
    # pass
    config = all_rules_config(ontology=ontology)
    a = ["blah"] * 15
    a[3] = ""
    a[4] = "GO:0006397"
    a[5] = "PMID:21873635"
    a[6] = "ISS"
    a[7] = "PomBase:SPAC25B8.17"
    a[8] = "P"
    a[12] = "taxon:123"
    a[13] = "20180330"
    assoc = gafparser.to_association(a).associations[0]

    test_results = qc.test_go_rules(assoc, config).all_results
    assert len(test_results.keys()) == 24
    assert test_results[
        qc.GoRules.GoRule26.value].result_type == qc.ResultType.PASS
    assert test_results[
        qc.GoRules.GoRule29.value].result_type == qc.ResultType.PASS
Пример #10
0
def test_go_rule_07():
    a = ["blah"] * 15
    a[3] = ""
    a[4] = "GO:0003824"
    a[6] = "IPI"
    a[8] = "F"
    a[13] = "20200303"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule07().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.WARNING

    assoc.object.id = "GO:1234567"
    test_result = qc.GoRule07().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.PASS

    assoc.object.id = "GO:0003824"
    assoc.evidence.type = "ECO:0000501" # Not IPI
    test_result = qc.GoRule07().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.PASS
Пример #11
0
def test_go_rule_06():
    a = ["blah"] * 15
    a[3] = ""
    a[4] = "GO:0005575" # Cellular component
    a[6] = "HEP"
    a[8] = "C"
    a[13] = "20200303"

    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule06().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.ERROR

    assoc.aspect = "P"
    assoc.object.id = "GO:0008150"
    test_result = qc.GoRule06().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.PASS

    assoc.evidence.type = "ECO:0000501"
    test_result = qc.GoRule06().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.PASS
Пример #12
0
def test_gorule50():
    a = ["blah"] * 15
    a[0] = "HELLO"
    a[1] = "123"
    a[3] = ""
    a[6] = "ISS"
    a[7] = "HELLO:123"
    a[8] = "P"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule50().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.WARNING

    assoc.subject.id = "BYE:567"
    test_result = qc.GoRule50().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    a[1] = "HELLO:123"
    a[6] = "ECO:0000501"
    # Not ISS, so fine to have repeated columns
    test_result = qc.GoRule50().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #13
0
def test_go_rule_16():
    # No GO term w/ID
    a = ["blah"] * 15
    a[3] = ""
    a[4] = "GO:1234567"
    a[6] = "IC"
    a[7] = "BLAH:12345"
    a[8] = "P"
    a[13] = "20200303"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule16().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    # withfrom has GO term
    assoc.evidence.with_support_from = [association.ConjunctiveSet(["GO:0023456"])]

    test_result = qc.GoRule16().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    # Pipe
    assoc.evidence.with_support_from = [association.ConjunctiveSet(["GO:0012345"]), association.ConjunctiveSet(["BLAH:54321"])]

    test_result = qc.GoRule16().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    # Empty withfrom
    assoc.evidence.with_support_from = []

    test_result = qc.GoRule16().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    # Not IC
    assoc.evidence.type = "ECO:0000501"
    assoc.evidence.with_support_from =  [association.ConjunctiveSet(["BLAH:5555555"]),  association.ConjunctiveSet(["FOO:999999"])]

    test_result = qc.GoRule16().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #14
0
def test_go_rule29():
    a = ["blah"] * 15
    a[3] = ""
    a[6] = "IEA"
    a[8] = "P"
    a[13] = "19901111"  # Nov 11, 1990, more than a year old
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    assoc.evidence.type = "ECO:0000305"  #Not IEA

    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    now = datetime.datetime.now()
    six_months_ago = now - datetime.timedelta(days=180)
    assoc.date = six_months_ago.strftime("%Y%m%d")
    assoc.evidence.type = "ECO:0000501"

    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Пример #15
0
def test_go_rules_15():

    a = ["blah"] * 15
    a[3] = ""
    a[4] = "GO:0044419"
    a[6] = "IEA"
    a[8] = "P"
    a[12] = "taxon:123|taxon:456"
    a[13] = "20200303"
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule15().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.PASS

    assoc.object.id = "GO:1234567"
    test_result = qc.GoRule15().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.WARNING

    assoc.object.id = "GO:0044215"
    assoc.object.id = "NCBITaxon:123"
    assoc.interacting_taxon = None # This is the important part, no interacting taxon
    test_result = qc.GoRule15().test(assoc, assocparser.AssocParserConfig(ontology=ontology))
    assert test_result.result_type == qc.ResultType.PASS
Пример #16
0
def test_go_rules_13():

    a = [
        "PomBase", "SPBC11B10.09", "cdc2", "", "GO:0007275", "PMID:21873635",
        "IBA", "PANTHER:PTN000623979|TAIR:locus:2099478", "P",
        "Cyclin-dependent kinase 1", "UniProtKB:P04551|PTN000624043",
        "protein", "taxon:284812", "20170228", "GO_Central", "", ""
    ]
    assoc = gafparser.to_association(a).associations[0]
    gaferences = gaference.load_gaferencer_inferences_from_file(
        "tests/resources/test.inferences.json")
    test_result = qc.GoRule13().test(
        assoc,
        assocparser.AssocParserConfig(annotation_inferences=gaferences,
                                      rule_set=assocparser.RuleSet.ALL))
    assert test_result.result_type == qc.ResultType.ERROR

    a = [
        "PomBase", "SPBC11B10.09", "cdc2", "", "GO:0007275", "PMID:21873635",
        "EXP", "PANTHER:PTN000623979|TAIR:locus:2099478", "P",
        "Cyclin-dependent kinase 1", "UniProtKB:P04551|PTN000624043",
        "protein", "taxon:284812", "20170228", "GO_Central", "", ""
    ]
    assoc = gafparser.to_association(a).associations[0]
    gaferences = gaference.load_gaferencer_inferences_from_file(
        "tests/resources/test.inferences.json")
    test_result = qc.GoRule13().test(
        assoc,
        assocparser.AssocParserConfig(annotation_inferences=gaferences,
                                      rule_set=assocparser.RuleSet.ALL))
    assert test_result.result_type == qc.ResultType.WARNING

    a = [
        "PomBase", "SPBC11B10.09", "cdc2", "NOT", "GO:0007275",
        "PMID:21873635", "EXP", "PANTHER:PTN000623979|TAIR:locus:2099478", "P",
        "Cyclin-dependent kinase 1", "UniProtKB:P04551|PTN000624043",
        "protein", "taxon:284812", "20170228", "GO_Central", "", ""
    ]
    assoc = gafparser.to_association(a).associations[0]
    gaferences = gaference.load_gaferencer_inferences_from_file(
        "tests/resources/test.inferences.json")
    test_result = qc.GoRule13().test(
        assoc,
        assocparser.AssocParserConfig(annotation_inferences=gaferences,
                                      rule_set=assocparser.RuleSet.ALL))
    assert test_result.result_type == qc.ResultType.PASS

    a = [
        "AspGD", "ASPL0000059928", "AN0127", "", "GO:0032258",
        "AspGD_REF:ASPL0000000005", "IEA", "SGD:S000001917", "P", "",
        "AN0127|ANID_00127|ANIA_00127", "gene_product", "taxon:227321",
        "20200201", "AspGD", "", ""
    ]
    assoc = gafparser.to_association(a).associations[0]
    gaferences = gaference.load_gaferencer_inferences_from_file(
        "tests/resources/test.inferences.json")
    test_result = qc.GoRule13().test(
        assoc,
        assocparser.AssocParserConfig(annotation_inferences=gaferences,
                                      rule_set=assocparser.RuleSet.ALL))
    assert test_result.result_type == qc.ResultType.ERROR