import collections
import csv


def load_barcode_csv(barcode_csv):
    """ Load a csv file of (genome,barcode) """

    bcs_per_genome = collections.defaultdict(list)
    with open(barcode_csv, 'r') as f:
        reader = csv.reader(f)
        for row in reader:
            if len(row) != 2:
                raise ValueError("Bad barcode file: %s" % barcode_csv)
            (genome, barcode) = row
            bcs_per_genome[genome].append(barcode)
    return bcs_per_genome