Ejemplo n.º 1
0
 def test_contains_bam_header_and_samviewrows(self, mpopen, msys, mpool):
     mpool.return_value.map = map
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     msys.stdout.write.assert_has_calls([
         mock.call(self.headers[0]),
         mock.call(self.headers[1]),
         mock.call(self.headers[2]),
         mock.call(self.uniquereads[0])
     ])
Ejemplo n.º 2
0
 def test_contains_bam_header_and_samviewrows(self, mpopen, msys, mpool):
     mpool.return_value.map = map
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     msys.stdout.write.assert_has_calls([
         mock.call(self.headers[0]),
         mock.call(self.headers[1]),
         mock.call(self.headers[2]),
         mock.call(self.uniquereads[0])
     ])
Ejemplo n.º 3
0
 def test_uniquereads_empty_sequence(self, mpopen, msys, mpool):
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     ecalls = []
     for c in self.headers:
         ecalls.append(mock.call(c))
     msys.stdout.write.assert_has_calls(ecalls)
Ejemplo n.º 4
0
 def test_uniquereads_empty_sequence(self, mpopen, msys, mpool):
     mpopen.return_value.stdout = self.headers
     r = subsamplebam.make_subselected_bam('foo.bam', self.uniquereads)
     ecalls = []
     for c in self.headers:
         ecalls.append(mock.call(c))
     msys.stdout.write.assert_has_calls(ecalls)
Ejemplo n.º 5
0
def test_sort_and_print_entries_excludes_paths_between_of_20_to_100_with_reverse_filter_option():
    with patch(mock_print) as p:
        # tmp/a1/path1
        # tmp/a1 (1)/path1
        # tmp/a130/path1
        sort_and_print_entries(entries, Args(None, [(20, 100)], False, True, False))
        e = [call(entries[i]) for i in [2, 3, 4]]
        p.assert_has_calls(e)
Ejemplo n.º 6
0
def test_sort_and_print_entries_keeps_only_paths_between_of_20_to_100_with_filter_option():
    with patch(mock_print) as p:
        # tmp/a23/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        sort_and_print_entries(entries, Args([(20, 100)], None, False, False, False))
        e = [call(entries[i]) for i in [1, 0, 5, 6]]
        p.assert_has_calls(e)
Ejemplo n.º 7
0
def test_sort_and_print_entries_excludes_paths_23_or_130_with_exclude_option_list():
    with patch(mock_print) as p:
        # tmp/a1/path1
        # tmp/a1 (1)/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        sort_and_print_entries(entries, Args(None, None, [23, 130], True, False))
        e = [call(entries[i]) for i in [2, 3, 0, 5, 6]]
        p.assert_has_calls(e)
Ejemplo n.º 8
0
def test_sort_and_print_entries_excludes_paths_between_of_20_to_100_with_reverse_filter_option(
):
    with patch(mock_print) as p:
        # tmp/a1/path1
        # tmp/a1 (1)/path1
        # tmp/a130/path1
        sort_and_print_entries(entries,
                               Args(None, [(20, 100)], False, True, False))
        e = [call(entries[i]) for i in [2, 3, 4]]
        p.assert_has_calls(e)
Ejemplo n.º 9
0
def test_sort_and_print_entries_keeps_only_paths_between_of_20_to_100_with_filter_option(
):
    with patch(mock_print) as p:
        # tmp/a23/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        sort_and_print_entries(entries,
                               Args([(20, 100)], None, False, False, False))
        e = [call(entries[i]) for i in [1, 0, 5, 6]]
        p.assert_has_calls(e)
Ejemplo n.º 10
0
def test_sort_and_print_entries_uses_default_algorithm_with_all_options_false():
    with patch(mock_print) as p:
        # tmp/a1 (1)/path1
        # tmp/a1/path1
        # tmp/a23/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        # tmp/a130/path1
        sort_and_print_entries(entries, Args(None, None, False, False, False))
        e = [call(entries[i]) for i in [3, 2, 1, 0, 5, 6, 4]]
        p.assert_has_calls(e)
Ejemplo n.º 11
0
def test_sort_and_print_entries_reverses_order_with_reverse_option():
    with patch(mock_print) as p:
        # tmp/a130/path1
        # tmp/a64/path2
        # tmp/a64/path1
        # tmp/a57/path2
        # tmp/a23/path1
        # tmp/a1 (1)/path1
        # tmp/a1/path1
        sort_and_print_entries(entries, Args(None, None, False, True, True))
        e = [call(entries[i]) for i in reversed([2, 3, 1, 0, 5, 6, 4])]
        p.assert_has_calls(e)
Ejemplo n.º 12
0
def test_sort_and_print_entries_uses_PATH_algorithm_with_path_option_true_to_properly_sort_OS_generated_path_names():
    with patch(mock_print) as p:
        # tmp/a1/path1
        # tmp/a1 (1)/path1
        # tmp/a23/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        # tmp/a130/path1
        sort_and_print_entries(entries, Args(None, None, False, True, False))
        e = [call(entries[i]) for i in [2, 3, 1, 0, 5, 6, 4]]
        p.assert_has_calls(e)
Ejemplo n.º 13
0
def test_sort_and_print_entries_reverses_order_with_reverse_option():
    with patch(mock_print) as p:
        # tmp/a130/path1
        # tmp/a64/path2
        # tmp/a64/path1
        # tmp/a57/path2
        # tmp/a23/path1
        # tmp/a1 (1)/path1
        # tmp/a1/path1
        sort_and_print_entries(entries, Args(None, None, False, True, True))
        e = [call(entries[i]) for i in reversed([2, 3, 1, 0, 5, 6, 4])]
        p.assert_has_calls(e)
Ejemplo n.º 14
0
def test_sort_and_print_entries_excludes_paths_23_or_130_with_exclude_option_list(
):
    with patch(mock_print) as p:
        # tmp/a1/path1
        # tmp/a1 (1)/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        sort_and_print_entries(entries, Args(None, None, [23, 130], True,
                                             False))
        e = [call(entries[i]) for i in [2, 3, 0, 5, 6]]
        p.assert_has_calls(e)
Ejemplo n.º 15
0
def test_sort_and_print_entries_uses_default_algorithm_with_all_options_false(
):
    with patch(mock_print) as p:
        # tmp/a1 (1)/path1
        # tmp/a1/path1
        # tmp/a23/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        # tmp/a130/path1
        sort_and_print_entries(entries, Args(None, None, False, False, False))
        e = [call(entries[i]) for i in [3, 2, 1, 0, 5, 6, 4]]
        p.assert_has_calls(e)
Ejemplo n.º 16
0
def test_sort_and_print_entries_uses_PATH_algorithm_with_path_option_true_to_properly_sort_OS_generated_path_names(
):
    with patch(mock_print) as p:
        # tmp/a1/path1
        # tmp/a1 (1)/path1
        # tmp/a23/path1
        # tmp/a57/path2
        # tmp/a64/path1
        # tmp/a64/path2
        # tmp/a130/path1
        sort_and_print_entries(entries, Args(None, None, False, True, False))
        e = [call(entries[i]) for i in [2, 3, 1, 0, 5, 6, 4]]
        p.assert_has_calls(e)