Esempio n. 1
0
def _get_well_list_horizontal(rows, columns):
    """Helper to get wells in 'horizontal' order."""
    wells = []
    for row in rows:
        for column in columns:
            wells.append(get_well_name(row, column))
    return wells
Esempio n. 2
0
def get_384_parent_well(child_quadrant, child_position):
    """
    Get the 384-format position corresponding to a 96-format child position.

    Uses the child's quadrant (A1, A2, B1, or B2) and the child's position
    to calculate this.
    """
    if child_quadrant[0] == 'A':
        odd_row = True
    else:
        odd_row = False

    if child_quadrant[1] == '1':
        odd_column = True
    else:
        odd_column = False

    child_row = child_position[0]
    child_row_index = ROWS_96.index(child_row)
    parent_row_index = child_row_index * 2
    if not odd_row:
        parent_row_index += 1
    parent_row = ROWS_384[parent_row_index]

    child_column = int(child_position[1:])
    parent_column = child_column * 2
    if odd_column:
        parent_column -= 1

    return get_well_name(parent_row, parent_column)
Esempio n. 3
0
def _index_to_well(index):
    """Convert 0-indexed snake order (see module docstring) to well."""
    row = ROWS_96[index / NUM_COLS_96]
    index_in_row = index % NUM_COLS_96

    if row in BACKWARDS_ROWS:
        position_from_left = NUM_COLS_96 - 1 - index_in_row
    else:
        position_from_left = index_in_row

    column = position_from_left + 1
    return get_well_name(row, column)
Esempio n. 4
0
def _index_to_well(index):
    """Convert 0-indexed snake order (see module docstring) to well."""
    row = ROWS_96[index / NUM_COLS_96]
    index_in_row = index % NUM_COLS_96

    if row in BACKWARDS_ROWS:
        position_from_left = NUM_COLS_96 - 1 - index_in_row
    else:
        position_from_left = index_in_row

    column = position_from_left + 1
    return get_well_name(row, column)
Esempio n. 5
0
def get_symmetric_well(well, is_384=False):
    """
    Get the well that is symmetric to the provided well.

    Well A is symmetric to well B if the two would swap positions if the
    plate were flipped 180 degrees.
    """
    if not is_proper_well_name(well):
        raise ValueError('{} is an improper well name'.format(well))

    rows, cols = get_rows_and_cols(is_384)

    row_idx = (len(rows) - 1) - rows.index(well[0])
    row = rows[row_idx]
    col = (len(cols) + 1) - int(well[1:])
    return get_well_name(row, col)
Esempio n. 6
0
def get_well_grid(is_384=False):
    """
    Get a 2D list representing the wells in one plate.

    is_384 param determines if the well list should be for 384-format
    plates, or 96-format plates. Defaults to 96-format.
    """
    rows, cols = get_rows_and_cols(is_384)

    plate = []
    for row in rows:
        this_row = []
        for column in cols:
            well = get_well_name(row, column)
            this_row.append(well)

        plate.append(this_row)

    return plate
Esempio n. 7
0
def get_random_well(is_384=False):
    """Get a random well."""
    rows, cols = get_rows_and_cols(is_384)
    row = random.choice(rows)
    col = random.choice(cols)
    return get_well_name(row, col)