<jupyter_start><jupyter_text>Vectorized sequence alignment diagrams<jupyter_code>from genetracks import Figure, Track, Alignment, Multitrack, Label
f = Figure()
t1 = Track(50, 300, direction='f', label="Another sequence", regions=[(50, 100, 'lightblue')])
t2 = Track(110, 410, direction='r', label="Sequence 1", regions=[(150, 200, 'salmon')])
f.add(t1)
f.add(t2)
f.show()<jupyter_output><empty_output><jupyter_text>Linear tracks MultitracksIn this example we pack multiple tracks onto the same row and join them to illustrate gaps. The child tracks inherit the parent's translations.<jupyter_code>f = Figure()
for i in range(0,3):
    o = i * 30
    e = i * 25
    f.add(Multitrack([
        Track(o, 150 + o, direction='f', label='Read {}, forward'.format(i + 1)),
        Track(300 + e, 450 + e, direction='r', label='Read {}, reverse'.format(i + 1))], join=True))
f.show()<jupyter_output><empty_output><jupyter_text>DirectionalityTracks can be rendered with arrows indicating strand direction.<jupyter_code>figure = Figure()
figure.add(Multitrack([
        Track(0, 150, direction='f', label='Forward read'),
        Track(200, 350, direction='r', label='Reverse read')], join=True))
figure.add(Track(50, 250, direction='fr', label='Read-through', color='salmon', regions=[(75, 225, 'lightgrey')]))
figure.add(Track(50, 300, label='Reads overlap'))
figure.show()<jupyter_output><empty_output><jupyter_text>The `Alignment` class allows us to illustrate the relationship between regions of two different tracks:  AlignmentRegions beetween two tracts can be illustrated with an `Alignment`.<jupyter_code>f = Figure()
f.add(Alignment(Track(50, 310, direction='r', regions=[(110, 300, 'lightblue')]),
                Track(100, 360, direction='f', regions=[(110, 300, 'salmon')]),
               [(110, 300), (300, 110)]))
f.show()<jupyter_output><empty_output><jupyter_text>Label ObjectsLabel offsets and text size can be adjusted to make informative tracks.<jupyter_code>f = Figure()

def draw_hiv_genes(f):
    third = [
        (2085, 5096, "pol", "orange"),
        (5559, 5850, "vpr", "turquoise"),
        (5970, 6045, "rev", 'yellowgreen'),
        (6225, 8795, "env", 'salmon'),
    ]
    second = [
        (5831, 6045, "tat", "plum"),
        (6062, 6310, "vpu", "red"),
        (8379, 8653, "rev", 'yellowgreen'),
        (9086, 9719, "3' LTR", 'darkgrey'),
    ]

    first = [
        (0, 634, "5' LTR", "darkgrey"),
        (790, 2292, "gag", "lightblue"),
        (5041, 5619, "vif", 'steelblue'),
        (8379, 8469, "tat", 'plum'),
        (8797, 9417, "nef", 'mediumaquamarine'),
    ]

    for reading_frame in [first, second, third]:
        f.add(Multitrack([Track(l, r, label=Label(0, text, offset=1), color=color)
                          for l, r, text, color in reading_frame]), gap=0)

draw_hiv_genes(f)
f.show(w=900)<jupyter_output><empty_output><jupyter_text>Circular genomesThere is experimental support for circular genomes.<jupyter_code>from genetracks import Plasmid, Region

p = Plasmid(360, regions=[Region(100, 101, color='orange'),
                          Region(110, 280, color='salmon'),
                          Region(230, 275, color='firebrick'),
                          Region(320, 20, color='lightblue'),
                          Region(20, 50, color='slateblue')])
p.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup