def test_unmapped_eco_to_gaf_codes(): # By default, ECO codes in GPAD need to be convertible to an ECO GAF code (e.g. IDA, ISO) vals = [ "MGI", "MGI:88276", "is_active_in", "GO:0098831", "PMID:8909549", "ECO:0000164", "", "", "20180711", "SynGO", "part_of(UBERON:0000956)", "" ] parser = GpadParser(config=assocparser.AssocParserConfig()) result = parser.parse_line("\t".join(vals)) assert len(result.associations) == 0 messages = parser.report.messages assert messages[0]["type"] == parser.report.UNKNOWN_EVIDENCE_CLASS parser.config.allow_unmapped_eco = True result = parser.parse_line("\t".join(vals)) assert len(result.associations) == 1 parser.config.allow_unmapped_eco = False vals[5] = "ECO:0000314" # maps to IDA result = parser.parse_line("\t".join(vals)) assert len(result.associations) == 1 vals[5] = "ECO:0006003" # indirectly maps to IDA via gaf-eco-mapping-derived.txt result = parser.parse_line("\t".join(vals)) assert len(result.associations) == 1
def test_obsolete_term_repair_withfrom(): vals = ["ZFIN", "ZFIN:ZDB-GENE-980526-362", "acts_upstream_of_or_within", "GO:0007155", "PMID:15494018", "ECO:0000305", "GO:0005913|GO:1,GO:4|ZFIN:ZDB-MRPHLNO-010101-1,MGI:1232453", "", "20041026", "ZFIN", "", "contributor=GOC:zfin_curators|model-state=production|noctua-model-id=gomodel:ZFIN_ZDB-GENE-980526-362" ] ont = OntologyFactory().create(ALT_ID_ONT) config = assocparser.AssocParserConfig(ontology=ont, rule_set=assocparser.RuleSet.ALL) parser = GpadParser(config=config) result = parser.parse_line("\t".join(vals)) assoc = result.associations[0] # GO:0005913 should be repaired to its replacement term, GO:00005912 assert [ConjunctiveSet(elements=[Curie(namespace='GO', identity='0005912')]), # repaired test GO elements ConjunctiveSet(elements=[Curie(namespace='GO', identity='2'), Curie(namespace='GO', identity='3')]), # non GO elements stay the same, could be obsolete or not ConjunctiveSet(elements=[Curie(namespace='ZFIN', identity='ZDB-MRPHLNO-010101-1'), Curie(namespace='MGI', identity='1232453')])] == assoc.evidence.with_support_from
def test_aspect_fill_for_obsolete_terms(): # Test null aspect on an obsolete term # GO:4 is obsolete and has no aspect (hasOBONamespace) in obsolete.json ontology # GO:3 is it's replacement term # Note that GPAD lines contain no aspect data vals = [ "MGI", "MGI:105128", "involved_in", "GO:4", "PMID:25901318", "ECO:0000314", "", "", "20190517", "MGI", "", "contributor=http://orcid.org/0000-0002-9796-7693|model-state=production|noctua-model-id=gomodel:5c4605cc00004132" ] ont = OntologyFactory().create(ALT_ID_ONT) config = assocparser.AssocParserConfig(ontology=ont, rule_set=assocparser.RuleSet.ALL) parser = GpadParser(config=config) result = parser.parse_line("\t".join(vals)) assoc = result.associations[0] assert assoc.object.id == Curie("GO", "3") # GO:4 should be repaired to its replacement term, GO:3 assert assoc.aspect == 'P' # Aspect should not be empty
def filter_rule_validate_lines(annots, assoc_filter): filtered = [] # Converts split GPAD line into ontobio assoc obj for passing into standard FilterRule validation gpad_parser = GpadParser() for a in annots: parse_result = gpad_parser.parse_line("\t".join(a)) if len(parse_result.associations) > 0: # Right now, GpadParser only returns 0 or 1 associations assoc = parse_result.associations[0] assoc = extract_properties(assoc) if "annotation_properties" in assoc: a.append(assoc["annotation_properties"]) if assoc_filter.validate_line(assoc): filtered.append(a) return filtered