def layoutTracks(tracks):
    """layout tracks."""

    # combine subtracks - these are ordered by appearance
    for track in tracks.values():
        if track.mSubTracks:
            s = []
            for subtrack in track.mSubTracks:
                s.append(tracks[subtrack])
                del tracks[subtrack]
            track.mSubTracks = s

    # sort by priority and compute heights
    total_width = sum(map(lambda x: x.height, tracks.values()))

    # convert to list - this is the order in which the tracks will
    # be output
    tracks = list(tracks.values())
    tracks.sort(lambda x, y: cmp(x.priority, y.priority))

    yoffset = 0.1
    ymax_width = 0.8

    for track in tracks:
        track.mYOffset = yoffset
        width = ymax_width * track.height / total_width
        track.mYWidth = width
        yoffset += width

    return tracks
dataset/ETHPy150Open CGATOxford/cgat/scripts/gff2plot.py/layoutTracks/original