Exemple #1
0
    def test_01_g(self):
        args = CLI([TESTS_EXAMPLE_ALIGNMENT_01, '--verbose'])

        args.parameters.left_padding = 4
        args.parameters.right_padding = 4

        flaimapper = FlaiMapper(args)

        i = 0
        for region in flaimapper.regions():
            if i == 0:
                self.assertEqual(region.region[0], 'chr1')

                self.assertEqual(region.region[1],
                                 13 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 43 + 20 + args.parameters.right_padding)
            else:
                self.assertEqual(region.region[0], 'chr2')

                self.assertEqual(region.region[1],
                                 54 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 54 + 26 + args.parameters.right_padding)

            i += 1

        self.assertEqual(i, 2)
Exemple #2
0
    def test_01_b(self):
        args = CLI([
            TESTS_EXAMPLE_ALIGNMENT_01, '-p', TESTS_FUNCTIONAL_DUCK7_PARAMS,
            '--verbose'
        ])

        # Use custom file that must be set to a padding of 7
        self.assertEqual(args.parameters.left_padding, 7)
        self.assertEqual(args.parameters.right_padding, 7)

        flaimapper = FlaiMapper(args)

        i = 0
        for region in flaimapper.regions():
            if i == 0:
                self.assertEqual(region.region[0], 'chr1')

                self.assertEqual(region.region[1],
                                 13 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 43 + 20 + args.parameters.right_padding)
            elif i == 1:
                self.assertEqual(region.region[0], 'chr2')

                self.assertEqual(region.region[1],
                                 54 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 54 + 26 + args.parameters.right_padding)
            else:
                self.asserTrue(False, "Race condition?")

            i += 1

        self.assertEqual(i, 2)
Exemple #3
0
    def test_04_b(self):
        args = CLI([
            TESTS_EXAMPLE_ALIGNMENT_01, '-p', TESTS_FUNCTIONAL_DUCK7_PARAMS,
            '--verbose'
        ])

        fm = FlaiMapper(args)

        # First check whether it's looking in the right regions
        i = 0
        for region in fm:
            if i == 0:
                self.assertEqual(region.region[0], 'chr1')

                self.assertEqual(region.region[1],
                                 13 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 43 + 20 + args.parameters.right_padding)
            elif i == 1:
                self.assertEqual(region.region[0], 'chr2')

                self.assertEqual(region.region[1],
                                 54 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 54 + 26 + args.parameters.right_padding)
            else:
                self.asserTrue(False, "Race condition?")
            i += 1

        self.assertEqual(i, 2)

        # Then detect the fragments
        i = 0
        for region in fm:
            for fragment in region:
                if i == 0:
                    self.assertEqual(region.region[1] + fragment.start, 13)
                    self.assertEqual(region.region[1] + fragment.stop, 36)
                elif i == 1:
                    self.assertEqual(region.region[1] + fragment.start, 43)
                    self.assertEqual(region.region[1] + fragment.stop, 62)
                elif i == 2:
                    self.assertEqual(region.region[1] + fragment.start, 54)
                    self.assertEqual(region.region[1] + fragment.stop, 79)
                else:
                    self.asserTrue(False, "Race condition?")
                i += 1

        self.assertEqual(i, 3)
Exemple #4
0
    def test_02b(self):
        fname = 'test_FlaiMapper_test_02b_output.gtf'
        args = CLI([
            TESTS_EXAMPLE_ALIGNMENT_01, '-o', fname, '--verbose', '--offset5p',
            '5', '--offset3p', '5'
        ])

        flaimapper = FlaiMapper(args)

        # Run analysis
        flaimapper.run()

        # assert Contents:
        assertion = (not filecmp.cmp(fname,
                                     TESTS_FLAIMAPPER_TEST_02_OUTPUT_GTF))
        self.assertTrue(assertion)

        if assertion:
            os.remove(fname)
Exemple #5
0
    def test_03_a(self):
        fname = 'test_FlaiMapper_test_03_output.txt'
        args = CLI([
            TESTS_EXAMPLE_ALIGNMENT_01, '-o', fname, '-f', '1', '--verbose',
            '--offset5p', '4', '--offset3p', '4'
        ])

        flaimapper = FlaiMapper(args)

        # Run analysis
        flaimapper.run()

        # assert Contents:
        self.assertTrue(
            filecmp.cmp(TESTS_FLAIMAPPER_TEST_03_a_OUTPUT_TXT, fname),
            msg="diff '" + TESTS_FLAIMAPPER_TEST_03_a_OUTPUT_TXT + "' '" +
            fname + "':\n" +
            get_file_diff(TESTS_FLAIMAPPER_TEST_03_a_OUTPUT_TXT, fname))

        os.remove(fname)
Exemple #6
0
    def test_02(self):
        fname = 'test_FlaiMapper_test_02_output.gtf'
        args = CLI([
            TESTS_EXAMPLE_ALIGNMENT_01, '-o', fname, '--verbose', '--offset5p',
            '4', '--offset3p', '4'
        ])

        flaimapper = FlaiMapper(args)

        # Run analysis
        flaimapper.run()

        # assert Contents:
        self.assertTrue(
            filecmp.cmp(TESTS_FLAIMAPPER_TEST_02_OUTPUT_GTF, fname),
            msg="diff '" + TESTS_FLAIMAPPER_TEST_02_OUTPUT_GTF + "' '" +
            fname + "':\n" +
            get_file_diff(TESTS_FLAIMAPPER_TEST_02_OUTPUT_GTF, fname))

        os.remove(fname)  # does not get executed if assertion is False
Exemple #7
0
    def test_01_a(self):
        args = CLI([TESTS_EXAMPLE_ALIGNMENT_01, '--verbose'])

        args.parameters.left_padding = 1
        args.parameters.right_padding = 1

        flaimapper = FlaiMapper(args)

        i = 0
        for region in flaimapper.regions():
            if i == 0:
                self.assertEqual(region.region[0], 'chr1')

                self.assertEqual(region.region[1],
                                 13 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 13 + 20 + 4 + args.parameters.right_padding)
            elif i == 1:
                self.assertEqual(region.region[0], 'chr1')

                self.assertEqual(region.region[1],
                                 43 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 43 + 20 + args.parameters.right_padding)
            elif i == 2:
                self.assertEqual(region.region[0], 'chr2')

                self.assertEqual(region.region[1],
                                 54 - 1 - args.parameters.left_padding)
                self.assertEqual(region.region[2],
                                 54 + 26 + args.parameters.right_padding)
            else:
                self.asserTrue(False, "Race condition?")

            i += 1

        self.assertEqual(i, 3)
Exemple #8
0
    def test_02(self):
        cli = CLI([TESTS_EXAMPLE_ALIGNMENT_01, "-p", PARAMETERS_DEFAULT])

        self.assertTrue(cli.parameters.left_padding, 15)
        self.assertTrue(cli.parameters.right_padding, 15)
Exemple #9
0
    def test_01(self):
        cli = CLI([TESTS_EXAMPLE_ALIGNMENT_01])

        self.assertTrue(cli.parameters.left_padding, 15)
        self.assertTrue(cli.parameters.right_padding, 15)