Ejemplo n.º 1
0
    def select_pileup_range_and_truncate_output(
            self, pileup, startpos, endpos, pileup_select_range_expected_out,
            pileup_truncate_expected_out):
        """
        select_pileup_range_and_truncate_output - Checks if the program works
        as expected when truncating contiguous start and end regions after
        first selecting a specified range.

        INPUT:
            [2D ARRAY of DICTIONARIES] [pileup]
            [INT] [startpos]
            [INT] [endpos]
            [2D ARRAY OF DICTIONARIES] [pileup_select_range_expected_out]
            [2D ARRAY OF DICTIONARIES] [pileup_truncate_expected_out]
        RETURN:
            TODO
        POST:
            TODO
        """

        pileups = Pileup_List([Pileup(bam) for bam in pileup])
        pileups.select_pileup_range(startpos, endpos)
        select_pileup = pileups.get_pileups_as_array()

        # assert that the pileup positions before startpos and after endpos
        # have been ignored
        assert select_pileup == pileup_select_range_expected_out

        pileups.truncate_output()
        truncated_pileup = pileups.get_pileups_as_array()

        # assert that the pileup is truncated now as expected
        assert truncated_pileup == pileup_truncate_expected_out
Ejemplo n.º 2
0
    def test_truncate_output(self, pileup, expected_truncated_pileup,
                             expected_left_pos_truncated,
                             expected_right_pos_truncated):
        """
        test_truncate_output - Checks that the expected truncated outputs
        matches the actual output.

        INPUT:
            [2D ARRAY OF DICTIONARIES] [pileup] # to be truncated
            [2D ARRAY OF DICTIONARIES] [expected_truncated_pileup]
            [2D ARRAY OF DICTIONARIES] [expected_left_pos_truncated]
            # number of contiguous left positions that were truncated
            [2D ARRAY OF DICTIONARIES] [expected_right_pos_truncated]
            # number of contiguous right positions that were truncated

        RETURN:
            [None]

        POST:
            Checks that the expected outputs match the actual output
        """
        pileups = Pileup_List([Pileup(bam) for bam in pileup])
        pileups.truncate_output()
        truncated = pileups.get_pileups_as_array()

        assert truncated == expected_truncated_pileup
        assert pileups.get_num_left_positions_truncated(
        ) == expected_left_pos_truncated
        assert pileups.get_num_right_positions_truncated(
        ) == expected_right_pos_truncated