# whereas the first timepoint for row H is at
    # (320 - 150) = 170 seconds after mixing
    for row in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']:
        for col in range(1, 13):
            well = '%s%s' % (row, col)
            offset_dict[well] = read_time - row_times[row]
    return offset_dict

# Add the time offset to the time coordinates for the data
timecourse_wells = add_offset_vector(timecourse_wells, time_offset_vector())

# No NBD or lipos (buffer only)
# The buffer only wells are used to establish the background fluorescence
# of the buffer/well.
no_nbd_lipo_well_names = ['B12', 'D12', 'F12'] # Ignoring H12 as an outlier
no_nbd_lipo_wells = extract(no_nbd_lipo_well_names, timecourse_wells)

# NBD-Bax but no lipos
no_lipo_well_names = ['A12', 'C12', 'E12', 'G12']
no_lipo_wells = extract(no_lipo_well_names, timecourse_wells)

bg_layout = collections.OrderedDict([
         ('NBD, No lipos', ['A12', 'C12', 'E12', 'G12']),
         ('No NBD or lipos', ['B12', 'D12', 'F12']),
         ('NBD and lipos', ['G9', 'G10', 'G11']),
        ])
# Produces average timecourses across replicates for the three background
# conditions
(bg_averages, bg_std) = averages(timecourse_wells, bg_layout)

# To do the correct background subtraction we need to account for the
        ('Bax 0 nM',  ['C12']),
    ])

data_path = dirname(sys.modules['tbidbaxlipo.data'].__file__)
timecourse_file = abspath(join(data_path,
                               '140320_NBD_Bax_BimBH3_unlab_Bax_titration.txt'))

# Assemble all the wells included in the layout
# http://stackoverflow.com/questions/406121/
# flattening-a-shallow-list-in-python
wells_to_read = list(itertools.chain(*layout.values()))

# Timecourse wells
timecourse_wells = read_flexstation_kinetics(timecourse_file)
"""The raw (unnormalized) timecourses."""
timecourse_wells = extract(wells_to_read, timecourse_wells)

# Averaged
(timecourse_averages, timecourse_stds) = averages(timecourse_wells, layout)

bax_bg_conditions = [
        'Bax 590 nM',
        'Bax 393 nM',
        'Bax 262 nM',
        'Bax 175 nM',
        'Bax 116 nM',
        'Bax 78 nM',
        'Bax 52 nM',
        'Bax 35 nM',
        'Bax 23 nM',
        'Bax 15 nM',
        ('Lipos 0.001 mg/ml',  ['B11']),
        ('Lipos 0 mg/ml',  ['B12']),
    ])
data_path = dirname(sys.modules['tbidbaxlipo.data'].__file__)
timecourse_file = abspath(join(data_path,
                              '140318_NBD_Bax_BimBH3_lipo_titration.txt'))

# Assemble all the wells included in the layout
# http://stackoverflow.com/questions/406121/
# flattening-a-shallow-list-in-python
wells_to_read = list(itertools.chain(*layout.values()))

# Timecourse wells
timecourse_wells = read_flexstation_kinetics(timecourse_file)
"""The raw (unnormalized) timecourses."""
timecourse_wells = extract(wells_to_read, timecourse_wells)

lipo_bg_conditions = [
        'Lipos 1 mg/ml',
        'Lipos 0.5 mg/ml',
        'Lipos 0.25 mg/ml',
        'Lipos 0.125 mg/ml',
        'Lipos 0.063 mg/ml',
        'Lipos 0.031 mg/ml',
        'Lipos 0.016 mg/ml',
        'Lipos 0.008 mg/ml',
        'Lipos 0.004 mg/ml',
        'Lipos 0.002 mg/ml',
        'Lipos 0.001 mg/ml',
        'Lipos 0 mg/ml']
lipo_bg_layout = extract(lipo_bg_conditions, layout)