def setUp(self): rfu_data = [[1, 2, 3], [4, 5, 6]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'FLAG', 'FLAG'] } row_metadata = { 'PlateId': ['P0012345', 'P0012345'], 'Barcode': ['SL1234', 'SL1235'] } header_metadata = {} self.adat0 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'PASS', 'FLAG'] } row_metadata = { 'PlateId': ['Set 01', 'Set 02'], 'Barcode': ['SL1236', 'SL1237'] } header_metadata = {} self.adat1 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata)
def setUp(self): rfu_data = [[1, 2, 3], [4, 5, 6]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'FLAG', 'FLAG'] } row_metadata = { 'PlateId': ['A12', 'A12'], 'Barcode': ['SL1234', 'SL1235'] } header_metadata = { 'AdatId': '1a2b3c', '!AssayRobot': 'Tecan1, Tecan2', 'RunNotes': 'run note 1' } self.adat0 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'PASS', 'FLAG'] } row_metadata = { 'PlateId': ['A13', 'A13'], 'Barcode': ['SL1236', 'SL1237'], 'HybControlNormScale': ['1.2', '5'], 'RowCheck': ['PASS', 'PASS'] } header_metadata = { 'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2' } self.adat1 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[8, 9, 1], [1, 4, 8]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'] } row_metadata = { 'PlateId': ['A14', 'A14'], 'Barcode': ['SL1238', 'SL1239'], 'Stuff': ['foo', 'bar'] } header_metadata = { 'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2' } self.adat2 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata)
def test_v3_seq_id_file_read_warning(self): with pytest.warns(UserWarning) as record: Adat.from_file('tests/data/v3_test.adat') # check that only one warning was raised self.assertEqual(len(record), 1) # check that the message matches self.assertEqual( record[0].message.args[0], 'V3 style seqIds (i.e., 12345-6_7). Converting to V4 Style. The adat file writer has an option to write using the V3 style' )
def setUp(self): rfu_data = [[1, 2, 3], [4, 5, 6]] col_metadata = {'SeqId': ['A', 'B', 'C'], 'ColCheck': ['PASS', 'FLAG', 'FLAG']} row_metadata = {'PlateId': ['A12', 'A12'], 'Barcode': ['SL1234', 'SL1235']} header_metadata = {'AdatId': '1a2b3c', '!AssayRobot': 'Tecan1, Tecan2', 'RunNotes': 'run note 1'} adat1 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = {'SeqId': ['A', 'B', 'C'], 'ColCheck': ['PASS', 'PASS', 'FLAG']} row_metadata = {'PlateId': ['A13', 'A13'], 'Barcode': ['SL1236', 'SL1237']} header_metadata = {'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2'} adat2 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) self.adats = [adat1, adat2]
def test_column_mismatch(self): rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = {'SeqId': ['A', 'B', 'D'], 'ColCheck': ['PASS', 'PASS', 'FLAG']} row_metadata = {'PlateId': ['A13', 'A13'], 'Barcode': ['SL1236', 'SL1237']} header_metadata = {'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2'} adat3 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) self.adats.append(adat3) self.assertRaises(AdatConcatError, concatenate_adats, self.adats)
def test_v3_seq_id_file_read_conversion(self): adat = Adat.from_file('tests/data/v3_test.adat') # check that the adat has the correct column metadata names and data self.assertEqual(['SeqId', 'SeqIdVersion', 'ColCheck'], list(adat.columns.names)) self.assertEqual(['12345-6', '23456-7', '34567-8'], list(adat.columns.get_level_values('SeqId'))) self.assertEqual(['7', '8', '9'], list(adat.columns.get_level_values('SeqIdVersion')))
def setUp(self): rfu_data = [[1, 2, 3], [4, 5, 6]] col_metadata = {'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'FLAG', 'FLAG']} row_metadata = {'PlateId': ['A12', 'A12'], 'Barcode': ['SL1234', 'SL1235'], 'NewColumn': ['1', '2']} header_metadata = {'AdatId': '1a2b3c', '!AssayRobot': 'Tecan1, Tecan2', 'RunNotes': 'run note 1', '!Title': 'stuff'} self.adat0 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = {'SeqId': ['A', 'B', 'D'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'PASS', 'FLAG']} row_metadata = {'PlateId': ['A13', 'A13'], 'Barcode': ['SL1236', 'SL1237'], 'RowCheck': ['PASS', 'FLAG']} header_metadata = {'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2', '!Title': 'morestuff'} self.adat1 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[8, 9, 1], [1, 4, 8]] col_metadata = {'SeqId': ['A', 'D', 'E'], 'SeqIdVersion': ['1', '2', '3']} row_metadata = {'PlateId': ['A14', 'A14'], 'Barcode': ['SL1238', 'SL1239']} header_metadata = {'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2', '!Title': 'evenmorestuff'} self.adat2 = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) rfu_data = [[12, 23, 34], [45, 56, 67]] col_metadata = {'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['2', '3', '4'], 'ColCheck': ['PASS', 'FLAG', 'FLAG']} row_metadata = {'PlateId': ['A12', 'A12'], 'Barcode': ['SL1234', 'SL1235']} header_metadata = {'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2', '!Title': 'whatstuff'} self.adat0a = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata)
def setUp(self): rfu_data = [[1, 2, 3], [4, 5, 6]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'FLAG', 'FLAG'] } row_metadata = { 'PlateId': ['A12', 'A12'], 'Barcode': ['SL1234', 'SL1235'] } header_metadata = { 'AdatId': '1a2b3c', '!AssayRobot': 'Tecan1, Tecan2', 'RunNotes': 'run note 1' } self.adat = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata)
def setUp(self): rfu_data = [[1, 2, 3], [4, 5, 6]] col_metadata = { 'SeqId': ['12345-6_7', '23456-7_8', '34567-8_9'], 'ColCheck': ['PASS', 'FLAG', 'FLAG'] } row_metadata = { 'PlateId': ['A12', 'A12'], 'Barcode': ['SL1234', 'SL1235'] } header_metadata = { 'AdatId': '1a2b3c', '!AssayRobot': 'Tecan1, Tecan2', 'RunNotes': 'run note 1' } adat = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) adat.to_file('tests/data/v3_test.adat')
def test_seq_ids_mismatch_error(self): rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = { 'SeqId': ['A', 'B', 'D'], 'SeqIdVersion': ['4', '5', '6'], 'ColCheck': ['PASS', 'PASS', 'FLAG'] } row_metadata = { 'PlateId': ['A13', 'A13'], 'Barcode': ['SL1236', 'SL1237'] } header_metadata = { 'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2' } mismatch_seq_id_adat = Adat.from_features(rfu_data, row_metadata, col_metadata, header_metadata) with self.assertRaises(AdatMetaError): mismatch_seq_id_adat.update_somamer_metadata_from_adat(self.adat0)
def test_col_meta_replaced(self): rfu_data = [[5, 6, 7], [6, 5, 4]] col_metadata = { 'SeqId': ['A', 'B', 'C'], 'SeqIdVersion': ['1', '2', '3'], 'ColCheck': ['PASS', 'PASS', 'FLAG'] } row_metadata = { 'PlateId': ['A13', 'A13'], 'Barcode': ['SL1236', 'SL1237'] } header_metadata = { 'AdatId': '1a2b3d', '!AssayRobot': 'Tecan2', 'RunNotes': 'run note 2' } truth_meta_replaced_adat_1 = Adat.from_features( rfu_data, row_metadata, col_metadata, header_metadata) meta_replaced_adat = self.adat1.update_somamer_metadata_from_adat( self.adat0) pd.testing.assert_frame_equal(truth_meta_replaced_adat_1, meta_replaced_adat)
def read_file(filepath: str) -> Adat: """Returns an Adat from the filepath/name. Parameters ---------- filepath: str Either the absolute or relative path to the file to be opened. Examples -------- >>> adat = Adat.from_file('path/to/file.adat') Returns ------- adat : Adat """ with open(filepath, 'r') as f: rfu_matrix, row_metadata, column_metadata, header_metadata = parse_file( f) return Adat.from_features(rfu_matrix=rfu_matrix, row_metadata=row_metadata, column_metadata=column_metadata, header_metadata=header_metadata)
def setUp(self): self.adat = Adat.from_file('./tests/data/control_data.adat')
def setUp(self): first_adat = Adat.from_file('./tests/data/control_data.adat') first_adat.to_file(self.filename) self.adat = Adat.from_file(self.filename)
def setUp(self): self.adat = Adat.from_file(self.filename)
def test_adat_from_file_read(self): adat = Adat.from_file(self.filename) self.assertIsInstance(adat, Adat)