Example #1
0
    X_OFFSET = 75
    Y_INITIAL = 25
    RECTANGLE_HEIGHT = 30
    palette = sns.color_palette(None, len(motifs))
    context = draw_surface(fasta, len(motifs))
    context.set_line_width(1)
    context.save()
    context.set_source_rgb(1, 1, 1)
    context.paint()
    context.restore()

    y_offset = 0
    for header, sequence in fasta.items():
        gene = Gene(header, sequence)
        gene_name = gene.get_gene_name()
        gene_length = gene.get_gene_length()
        introns, exons = gene.get_intron_exon_locations()
        motif_locations = gene.find_motif_locations(motifs)
        context.set_source_rgb(0, 0, 0)
        context.move_to(20, Y_INITIAL + y_offset + 5)
        context.show_text(gene_name)

        draw_introns(introns, X_OFFSET, y_offset, Y_INITIAL)
        draw_exons(exons, X_OFFSET, y_offset, Y_INITIAL, RECTANGLE_HEIGHT)
        draw_motifs(palette, motif_locations, X_OFFSET, y_offset, Y_INITIAL)

        y_offset += 100

    draw_legend(palette, X_OFFSET, y_offset, list(motifs.keys()))