# Path: segeval/format.py
# def convert_positions_to_masses(positions):
#     '''
#     Convert an ordered sequence of boundary position labels into a
#     sequence of segment masses, e.g., ``[1,1,1,1,1,2,2,2,3,3,3,3,3]`` becomes
#     ``[5,3,5]``.
# 
#     :param segments: Ordered sequence of which segments a unit belongs to.
#     :type segments: tuple
# 
#     .. deprecated:: 1.0
#     '''
#     return tuple([len(list(group)) for _, group in groupby(positions)])


import csv
from segeval.format import convert_positions_to_masses
    from segeval.data import Dataset, name_from_filepath
                    if j is 0:
                        coder = str(col)
                        dataset[item][coder] = list()
                    else:
                        dataset[item][coder].append(int(col))
                dataset[item][coder] = tuple(dataset[item][coder])

    return dataset


def input_linear_positions_tsv(filepath, delimiter=DEFAULT_DELIMITER):
    '''
    Takes a file path.  Returns segmentation mass codings as a :class:`Dataset`.

    :param filepath: path to the mass file containing segment position
                         codings.
    :param delimiter:    the delimiter used when reading a TSV file (by default,
                         a tab, but it can also be a comma, whitespace, etc.
    :type filepath: str
    :type delimiter: str

    .. deprecated:: 1.0

    .. warning:: This I/O function is for legacy files only and will be removed
        in later versions.
    '''
    dataset = input_linear_mass_tsv(filepath, delimiter)
    # Convert each segment position to masses
    for item, coder_positions in dataset.items():
        for coder, positions in coder_positions.items():

# Path: segeval/format.py
# def convert_positions_to_masses(positions):
#     '''
#     Convert an ordered sequence of boundary position labels into a
#     sequence of segment masses, e.g., ``[1,1,1,1,1,2,2,2,3,3,3,3,3]`` becomes
#     ``[5,3,5]``.
# 
#     :param segments: Ordered sequence of which segments a unit belongs to.
#     :type segments: tuple
# 
#     .. deprecated:: 1.0
#     '''
#     return tuple([len(list(group)) for _, group in groupby(positions)])


# Path: segeval/data/tsv.py
import csv
from segeval.format import convert_positions_to_masses
    from segeval.data import Dataset, name_from_filepath

                    if j is 0:
                        coder = str(col)
                        dataset[item][coder] = list()
                    else:
                        dataset[item][coder].append(int(col))
                dataset[item][coder] = tuple(dataset[item][coder])

    return dataset


def input_linear_positions_tsv(filepath, delimiter=DEFAULT_DELIMITER):
    '''
    Takes a file path.  Returns segmentation mass codings as a :class:`Dataset`.

    :param filepath: path to the mass file containing segment position
                         codings.
    :param delimiter:    the delimiter used when reading a TSV file (by default,
                         a tab, but it can also be a comma, whitespace, etc.
    :type filepath: str
    :type delimiter: str

    .. deprecated:: 1.0

    .. warning:: This I/O function is for legacy files only and will be removed
        in later versions.
    '''
    dataset = input_linear_mass_tsv(filepath, delimiter)
    # Convert each segment position to masses
    for item, coder_positions in dataset.items():
        for coder, positions in coder_positions.items():

            dataset[item][coder] = convert_positions_to_masses(positions)