def attempt_bc_correction(curr_bc, all_bcs, barcode_type = "golay_12"): """ Gets corrected barcode and number of errors curr_bc: current barcode sequence to attempt correction with all_bcs: List of all barcode sequences. barcode_type: Specified barcode, can be golay_12, hamming_8, variable_length, or an integer specifying length. """ # First check for exact matches corrected_bc = get_exact_bc_matches(curr_bc, all_bcs) if corrected_bc: return corrected_bc, 0 if barcode_type == "golay_12": corrected_bc, num_errors = decode_golay_12(curr_bc) elif barcode_type == "hamming_8": corrected_bc, num_errors = decode_barcode_8(curr_bc) elif barcode_type == 0: corrected_bc, num_errors = ('', 0) else: corrected_bc, num_errors = correct_barcode(curr_bc, all_bcs) return corrected_bc, num_errors
def test_correct_barcode(self): """ correct_barcode should correctly assign barcode to 2nd possibility, 2 errors """ original = "ATTTTTTTTTCG" recieved = "ATTTTTTTTTTT" possibilities = ["TGTATTCGTGTA", "ATTTTTTTTTCG", "TGTAGGCGTGTA", "TGTAGAAGTGTA", "TGTAGGCGTATA", "TGTAAAAAAAAA"] decoded, num_errors = barcode.correct_barcode(recieved, possibilities) self.assertEqual(decoded, original) self.assertEqual(num_errors, 2)
def test_correct_barcode(self): """ correct_barcode should correctly assign barcode to 2nd possibility, 2 errors """ original = 'ATTTTTTTTTCG' recieved = 'ATTTTTTTTTTT' possibilities = ['TGTATTCGTGTA','ATTTTTTTTTCG','TGTAGGCGTGTA', 'TGTAGAAGTGTA','TGTAGGCGTATA','TGTAAAAAAAAA'] decoded, num_errors = barcode.correct_barcode(recieved, possibilities) self.assertEqual(decoded, original) self.assertEqual(num_errors, 2)
def test_correct_barcode(self): """ correct_barcode should correctly assign barcode to 2nd possibility, 2 errors """ original = 'ATTTTTTTTTCG' recieved = 'ATTTTTTTTTTT' possibilities = ['TGTATTCGTGTA', 'ATTTTTTTTTCG', 'TGTAGGCGTGTA', 'TGTAGAAGTGTA', 'TGTAGGCGTATA', 'TGTAAAAAAAAA'] decoded, num_errors = barcode.correct_barcode(recieved, possibilities) self.assertEqual(decoded, original) self.assertEqual(num_errors, 2)