Beispiel #1
0
 def _index_row_column(row: str, column: str) -> bpu.EL:
     """
     get split of row or  column in multi value
     """
     comp = re.compile("(\w+)")
     lrow = len(row)
     lcolumn = len(re.findall(comp, column))
     if lrow > 1 and lcolumn > 1:
         value = BioPlateMatrix.__m_row_m_column(row, column)
         return value
     elif lrow == 1 and lcolumn == 1:
         ro = BioPlateMatrix._well_letter_index(row)
         return bpu.EL("W", int(ro), int(column))
     elif lrow > 1 and lcolumn == 1:
         row1, row2 = list(
             map(
                 BioPlateMatrix._well_letter_index,
                 BioPlateMatrix._multi_row_column(row),
             ))
         return bpu.EL("C", slice(int(row1), int(row2) + 1, 1), int(column))
     else:  # lcolumn > 1 and lrow == 1:
         column1, column2 = sorted(
             map(int, BioPlateMatrix._multi_row_column(column)))
         ro = BioPlateMatrix._well_letter_index(row)
         return bpu.EL("R", int(ro), slice(column1, column2 + 1, 1))
Beispiel #2
0
 def _all_row_column(well: str) -> bpu.EL:
     try:
         index = int(well)
         return bpu.EL("C", slice(1, None), index)
     except ValueError:
         index = BioPlateMatrix._well_letter_index(well)
         return bpu.EL("R", index, slice(1, None))
Beispiel #3
0
 def __m_row_m_column(row: str, column: str) -> bpu.EL:
     val = re.compile("(\w+)")
     comp = lambda x: list(BioPlateMatrix._multi_row_column(x))
     iterator, selector = list(map(comp, [row, column]))
     try:
         row1, row2 = list(map(BioPlateMatrix._well_letter_index, selector))
         column1, column2 = sorted(map(int, iterator))
         return bpu.EL(
             "C",
             slice(int(row1),
                   int(row2) + 1, 1),
             slice(int(column1),
                   int(column2) + 1, 1),
         )
     except ValueError:
         row1, row2 = list(map(BioPlateMatrix._well_letter_index, iterator))
         column1, column2 = sorted(map(int, [selector[0], selector[1]]))
         return bpu.EL("R", slice(int(row1),
                                  int(row2) + 1, 1),
                       slice(column1, column2 + 1, 1))
Beispiel #4
0
    def test_general(self):
        self.assertEqual(BioPlateMatrix("A2"), bpu.EL("W", 1, 2))
        self.assertEqual(BioPlateMatrix("5G"), bpu.EL("W", 7, 5))

        self.assertEqual(BioPlateMatrix("B[2,8]"),
                         bpu.EL("R", 2, slice(2, 9, 1)))
        self.assertEqual(BioPlateMatrix("2[B-G]"),
                         bpu.EL("C", slice(2, 8, 1), 2))

        self.assertEqual(BioPlateMatrix("A-G[1-8]"),
                         bpu.EL("R", slice(1, 8, 1), slice(1, 9, 1)))
        self.assertEqual(BioPlateMatrix("1-8[A-G]"),
                         bpu.EL("C", slice(1, 8, 1), slice(1, 9, 1)))

        self.assertEqual(BioPlateMatrix("C"), bpu.EL("R", 3, slice(1, None)))
        self.assertEqual(BioPlateMatrix("12"), bpu.EL("C", slice(1, None), 12))
Beispiel #5
0
 def test_index_row_column(self):
     self.assertEqual(BioPlateMatrix._index_row_column("A", "1"),
                      bpu.EL("W", 1, 1))
     self.assertEqual(BioPlateMatrix._index_row_column("D", "10"),
                      bpu.EL("W", 4, 10))
     self.assertEqual(
         BioPlateMatrix._index_row_column("D-G", "10"),
         bpu.EL("C", slice(4, 8, 1), 10),
     )
     self.assertEqual(
         BioPlateMatrix._index_row_column("G-I", "5-8"),
         bpu.EL("R", slice(7, 10, 1), slice(5, 9, 1)),
     )
     self.assertEqual(BioPlateMatrix._index_row_column("G", "5-8"),
                      bpu.EL("R", 7, slice(5, 9, 1)))
     self.assertEqual(BioPlateMatrix._index_row_column("B-E", "5"),
                      bpu.EL("C", slice(2, 6, 1), 5))
Beispiel #6
0
 def test_all_row_column(self):
     self.assertEqual(BioPlateMatrix._all_row_column("A"),
                      bpu.EL("R", 1, slice(1, None)))
     self.assertEqual(BioPlateMatrix._all_row_column(3),
                      bpu.EL("C", slice(1, None), 3))