def read_sample_map(samples, prefix=""):
    """Reads in a file containing demultiplexing barcodes and prefixes for output FASTQ file, and prepares the files.

    Parameters
    ----------
    samples : str
        Name of file to parse
    prefix : str
        Prefix to give every file

    Returns
    -------
    sample_dict : {str: [file output stream, int, str]}
        Keys are the demultiplexing barcodes, values are lists containing (1) the file handle (2) the number of reads
        that are mapped to that handle (initialized as zero) (3) the prefixes
    """
    sample_dict = {}
    with open(samples) as fin:
        # First value is the P1 barcode, second value is the sample identifier for output
        for line in fin:
            data = line.split()
            barcode = data[0]
            fout = open(f"{prefix}{data[1]}.fastq", "w")
            sample_dict[barcode] = [fout, 0, data[1]]

    return sample_dict