def test_mrna_cds(gff, expected): """find all cds that belong to mrna""" genes = [] mrnas = [] cds = [] exons = [] res = {} gf = gffhelper.GFFFile(gff) for o in gf.get_gff_objects(): if o.type == "gene": genes.append(o) if o.type == "mRNA": mrnas.append(o) if o.type == "CDS": cds.append(o) if o.type == "exon": exons.append(o) for g in genes: mg = [m.get_ID() for m in mrnas if g.get_ID() in m.get_Parent()] res[g.get_ID()] = mg for m in mg: emg = [e.get_ID() for e in exons if m in e.get_Parent()] res[m] = [emg] cmg = [c.get_ID() for c in cds if m in c.get_Parent()] res[m].append(cmg) print(res) assert res == expected
def test_attrib_ontology_term(gff, index, expected_Ontology_term, expected_Dbxref): g = gffhelper.GFFFile(gff) o = list(g.get_gff_objects())[index] d = [x.strip('"') for x in o.get_Dbxref()] ot = [x.strip('"') for x in o.get_Ontology_term()] assert d == expected_Dbxref assert ot == expected_Ontology_term pass
def test_attrib_id_alias_note_(gff, index, expected_id, expected_alias, expected_note): g = gffhelper.GFFFile(gff) o = list(g.get_gff_objects())[index] i = o.get_ID() a = o.get_Alias() print(a) n = o.get_Note() assert i == expected_id try: assert a == expected_alias except AssertionError: try: assert a == [] except AssertionError: raise AssertionError try: assert n == expected_note except AssertionError: try: assert n == [] except AssertionError: raise AssertionError
def test_score(gff, index, expected_score, expected_strand, expected_phase): g = gffhelper.GFFFile(gff) objs = list(g.get_gff_objects()) assert objs[index].score == expected_score assert objs[index].strand == expected_strand assert objs[index].phase == expected_phase
def test_start_end(gff, index, expected_start, expected_end): g = gffhelper.GFFFile(gff) objs = list(g.get_gff_objects()) assert int(objs[index].start) == expected_start assert int(objs[index].end) == expected_end
def test_type(gff, index, expected): g = gffhelper.GFFFile(gff) objs = list(g.get_gff_objects()) assert objs[index].type == expected
def test_source(gff, expected): g = gffhelper.GFFFile(gff) for o in g.get_gff_objects(): assert o.source == expected
def test_available_types(gff, expected): g = gffhelper.GFFFile(gff) t = g.get_available_types() print(t) assert t == expected
def test_attrib_is_circular(gff, index, expected_Is_circular): g = gffhelper.GFFFile(gff) o = list(g.get_gff_objects())[index] c = o.get_Is_circular() assert c == expected_Is_circular
def test_attrib_parent(gff, index, expected_Parent): g = gffhelper.GFFFile(gff) objs = list(g.get_gff_objects()) p = objs[index].get_Parent() assert p == expected_Parent
def test_metadata(gff, expected): g = gffhelper.GFFFile(gff) assert g.path == gff assert g.metadata == expected
def test_attributes(gff, index, expected_attributes): g = gffhelper.GFFFile(gff) objs = list(g.get_gff_objects()) for e in expected_attributes: vals = [a.value for a in objs[index].attributes if a.tag == e["tag"]] assert vals == [list(e["value"].split(","))]