def test_name_check(self): seqs = _build_some_paired_seqs() try: list(group_pairs(seqs, n_seqs_in_pair=4)) self.fail('InterleaveError expected') except InterleaveError: pass seqs = _build_some_paired_seqs() paired_seqs = list( group_pairs(seqs, n_seqs_in_pair=4, check_name_matches=False)) assert [get_str_seq(s) for s in paired_seqs[0]] == ['A', 'C', 'T', 'G']
def test_name_check(self): seqs = _build_some_paired_seqs() try: list(group_pairs(seqs, n_seqs_in_pair=4)) self.fail('InterleaveError expected') except InterleaveError: pass seqs = _build_some_paired_seqs() paired_seqs = list(group_pairs(seqs, n_seqs_in_pair=4, check_name_matches=False)) assert [get_str_seq(s) for s in paired_seqs[0]] == ['A', 'C', 'T', 'G']
def test_n_seqs_check(self): seqs = _build_some_paired_seqs() seqs = seqs[:-1] try: list(group_pairs(seqs, n_seqs_in_pair=2)) self.fail('InterleaveError expected') except InterleaveError: pass paired_seqs = list(group_pairs(seqs, n_seqs_in_pair=2, check_all_same_n_seqs=False)) assert [get_str_seq(s) for s in paired_seqs[0]] == ['A', 'C'] assert [get_str_seq(s) for s in paired_seqs[1]] == ['T']
def test_pair_grouper(self): seqs = _build_some_paired_seqs() paired_seqs = list(group_pairs(seqs)) assert [get_str_seq(s) for s in paired_seqs[0]] == ['A', 'C'] assert [get_str_seq(s) for s in paired_seqs[1]] == ['T', 'G'] assert len(paired_seqs) == 2 seqs = _build_some_paired_seqs() paired_seqs = list(group_pairs(seqs, n_seqs_in_pair=1, check_name_matches=True)) assert [get_str_seq(s) for pair in paired_seqs for s in pair] == ['A', 'C', 'T', 'G']
def test_n_seqs_check(self): seqs = _build_some_paired_seqs() seqs = seqs[:-1] try: list(group_pairs(seqs, n_seqs_in_pair=2)) self.fail('InterleaveError expected') except InterleaveError: pass paired_seqs = list( group_pairs(seqs, n_seqs_in_pair=2, check_all_same_n_seqs=False)) assert [get_str_seq(s) for s in paired_seqs[0]] == ['A', 'C'] assert [get_str_seq(s) for s in paired_seqs[1]] == ['T']
def test_pair_grouper(self): seqs = _build_some_paired_seqs() paired_seqs = list(group_pairs(seqs)) assert [get_str_seq(s) for s in paired_seqs[0]] == ['A', 'C'] assert [get_str_seq(s) for s in paired_seqs[1]] == ['T', 'G'] assert len(paired_seqs) == 2 seqs = _build_some_paired_seqs() paired_seqs = list( group_pairs(seqs, n_seqs_in_pair=1, check_name_matches=True)) assert [get_str_seq(s) for pair in paired_seqs for s in pair] == ['A', 'C', 'T', 'G']
def _read_pairs(in_fhands, paired_reads): seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQITEM]) if paired_reads: pairs = group_pairs_by_name(seqs) else: pairs = group_pairs(seqs, n_seqs_in_pair=1) return pairs
def seq_to_trim_packets(seq_packets, group_paired_reads=False): "It yields packets suitable for the filters" for packet in seq_packets: if group_paired_reads: packet = list(group_pairs_by_name(packet)) else: packet = list(group_pairs(packet, n_seqs_in_pair=1)) yield {SEQS_PASSED: packet, ORPHAN_SEQS: []}
def seq_to_filterpackets(seq_packets, group_paired_reads=False): 'It yields packets suitable for the filters' for packet in seq_packets: if group_paired_reads: packet = list(group_pairs_by_name(packet)) else: packet = list(group_pairs(packet, n_seqs_in_pair=1)) yield {SEQS_PASSED: packet, SEQS_FILTERED_OUT: []}
def seq_to_trim_packets(seq_packets, group_paired_reads=False): 'It yields packets suitable for the filters' for packet in seq_packets: if group_paired_reads: packet = list(group_pairs_by_name(packet)) else: packet = list(group_pairs(packet, n_seqs_in_pair=1)) yield {SEQS_PASSED: packet, ORPHAN_SEQS: []}
def test_empty_iter(): paired_seqs = list(group_pairs([])) assert not paired_seqs