def test_check_seqs_no_primers(self): """check_seqs handles disabled primers """ # Fifth test, no primers, fixed length barcodes # Should correct one of the passed barcodes in_seqs = self.in_seqs_fixed_len_bc1 bc_map = self.bc_map_fixed_len_bc1 primer_seq_lens = {} all_primers = {} expected = self.expected_fasta_fixed_len_bc1_no_primers out_f = FakeOutFile() actual = check_seqs( fasta_out=out_f, fasta_files = [in_seqs], starting_ix=0, valid_map = bc_map, qual_mappings={}, filters=[], barcode_len=12, keep_primer=False, keep_barcode=False, barcode_type="golay_12", max_bc_errors=1.5, remove_unassigned=True, attempt_bc_correction=True, primer_seqs_lens=primer_seq_lens, all_primers=all_primers, max_primer_mm=0, disable_primer_check=True) self.assertEqual(out_f.data,expected)
def test_check_seqs_fixed_len_bc(self): """check_seqs handles fixed length barcodes """ # Third test, fixed length barcodes, fixed length primers + one # degenerate test. Should correct one of the passed barcodes in_seqs = self.in_seqs_fixed_len_bc1 bc_map = self.bc_map_fixed_len_bc1 primer_seq_lens = self.primer_seq_lens_fixed_len_bc1 all_primers = self.all_primers_fixed_len_bc1 expected = self.expected_fasta_fixed_len_bc1 out_f = FakeOutFile() actual = check_seqs( fasta_out=out_f, fasta_files = [in_seqs], starting_ix=0, valid_map = bc_map, qual_mappings={}, filters=[], barcode_len=12, keep_primer=False, keep_barcode=False, barcode_type="golay_12", max_bc_errors=1.5, remove_unassigned=True, attempt_bc_correction=True, primer_seqs_lens=primer_seq_lens, all_primers=all_primers, max_primer_mm=0, disable_primer_check=False) self.assertEqual(out_f.data,expected) # Fourth test-set max_bc_errors to 0, and allow some primer mismatches in_seqs = self.in_seqs_fixed_len_bc2 bc_map = self.bc_map_fixed_len_bc2 primer_seq_lens = self.primer_seq_lens_fixed_len_bc2 all_primers = self.all_primers_fixed_len_bc2 expected = self.expected_fasta_fixed_len_bc2 out_f = FakeOutFile() actual = check_seqs( fasta_out=out_f, fasta_files = [in_seqs], starting_ix=0, valid_map = bc_map, qual_mappings={}, filters=[], barcode_len=12, keep_primer=False, keep_barcode=False, barcode_type="golay_12", max_bc_errors=0.5, remove_unassigned=True, attempt_bc_correction=True, primer_seqs_lens=primer_seq_lens, all_primers=all_primers, max_primer_mm=1, disable_primer_check=False) self.assertEqual(out_f.data,expected)
def test_check_seqs_variable_len_bc(self): """check_seqs handles variable length barcodes """ # Simple test with variable length primers in_seqs = self.in_seqs_variable_len_bc1 bc_map = self.bc_map_variable_len_bc1 primer_seq_lens = self.primer_seq_lens_variable_len_bc1 all_primers = self.all_primers_variable_len_bc1 expected = self.expected_fasta_variable_len_bc1 out_f = FakeOutFile() actual = check_seqs( fasta_out=out_f, fasta_files = [in_seqs], starting_ix=0, valid_map = bc_map, qual_mappings={}, filters=[], barcode_len=None, keep_primer=False, keep_barcode=False, barcode_type="variable_length", max_bc_errors=0, remove_unassigned=True, attempt_bc_correction=False, primer_seqs_lens=primer_seq_lens, all_primers=all_primers, max_primer_mm=0, disable_primer_check=False) self.assertEqual(out_f.data,expected) # Second test, includes truncated form of one of the barcodes-the # longest barcode should be found first in_seqs = self.in_seqs_variable_len_bc2 bc_map = self.bc_map_variable_len_bc2 primer_seq_lens = self.primer_seq_lens_variable_len_bc2 all_primers = self.all_primers_variable_len_bc2 expected = self.expected_fasta_variable_len_bc2 out_f = FakeOutFile() actual = check_seqs( fasta_out=out_f, fasta_files = [in_seqs], starting_ix=0, valid_map = bc_map, qual_mappings={}, filters=[], barcode_len=None, keep_primer=False, keep_barcode=False, barcode_type="variable_length", max_bc_errors=0, remove_unassigned=True, attempt_bc_correction=False, primer_seqs_lens=primer_seq_lens, all_primers=all_primers, max_primer_mm=0, disable_primer_check=False) self.assertEqual(out_f.data,expected)