def to_ms(ts):
    """
    Returns an ms-formatted version of the specified tree sequence.
    """
    output = ""
    for tree in ts.trees():
        length = tree.interval[1] - tree.interval[0]
        output += "[{}]{}\n".format(length, tree.newick())
    return output