def find_min_and_max_pos_per_read(table, phased=False):
    """Return a table with for every read the minimum and maximum position"""
    mm_table = table.loc[:, (['read_name', 'pos'])].groupby('read_name').min(
        ).join(table.loc[:, (['read_name', 'pos'])].groupby('read_name').
        max(), lsuffix='min', rsuffix='max')
    if phased:
        return mm_table.join(table.loc[:, (['read_name', 'HP'])].
            drop_duplicates(subset='read_name').set_index('read_name'))
    else:
        return mm_table
