def test_variants(db, variant_track): from pita.dbcollection import DbCollection from pita.io import read_bed_transcripts from pita.util import model_to_bed for tname, source, exons in read_bed_transcripts(open(variant_track)): db.add_transcript("{0}{1}{2}".format("t1", "|", tname), source, exons) c = DbCollection(db) best_model = [m for m in c.get_connected_models()][0][0] cuts = [str(e) for e in c.get_node_cuts(best_model)] assert ["chr1:800+900", "chr1:1400+1500"] == cuts best_variant = c.get_best_variant(best_model, [{"weight":1,"type":"length","name":"length"}]) s = [str(s) for s in best_variant] assert ["chr1:100+200", "chr1:400+700", "chr1:800+900", "chr1:1000+1300", "chr1:1400+1500", "chr1:1600+1900", "chr1:2000+2100"] == s