Ejemplo n.º 1
0
    def test_arguments(self):
        # Should print the usage
        with self.assertRaises(SystemExit):
            with Quieter():
                tps_distance_per_gene.parse_args([])

        with self.assertRaises(SystemExit):
            with Quieter():
                tps_distance_per_gene.parse_args(["regions filename"])

        regions_file = generate_random_filename()
        with open(regions_file, 'w') as file:
            file.write(
                "\t".join(['chr1', '1', '3', 'name', '0', '+'])
            )

        max_threads = multiprocessing.cpu_count()
        result = tps_distance_per_gene.parse_args([regions_file, 'seq_file'])
        self.assertEqual(result, (regions_file, ['seq_file'], 2, max_threads))

        result = tps_distance_per_gene.parse_args([regions_file, 'seq_file', '-t', '2'])
        self.assertEqual(result, (regions_file, ['seq_file'], 2, 2))

        result = tps_distance_per_gene.parse_args([regions_file, 'seq_file', '--threads', '2'])
        self.assertEqual(result, (regions_file, ['seq_file'], 2, 2))
    def test_arguments(self):
        with self.assertRaises(SystemExit):
            with Quieter():
                sequence_from_region_around_max_tss.parse_args([])

        with self.assertRaises(SystemExit):
            with Quieter():
                sequence_from_region_around_max_tss.parse_args(
                    ["max_tss_file"])

        with self.assertRaises(SystemExit):
            with Quieter():
                sequence_from_region_around_max_tss.parse_args(
                    ["max_tss_file", 'left'])

        max_tss_file = generate_random_filename()

        with open(max_tss_file, 'w') as file:
            file.write(
                "\t".join(["chr16", "53607", "53608", "POLR3K", "0", "-"]) +
                "\n" +
                "\t".join(["chr16", "53872", "53873", "SNRNP25", "0", "+"]) +
                "\n")

        result = sequence_from_region_around_max_tss.parse_args(
            [max_tss_file, '-5', '10'])
        search = [["-", 5], ['+', 10]]
        self.assertEqual(result, (False, max_tss_file, search))

        remove_files(max_tss_file)
Ejemplo n.º 3
0
    def test_incorrect_number_of_arguments(self):
        with self.assertRaises(SystemExit):
            with Quieter():
                nucleotide_heatmap.parse_args([])

        with self.assertRaises(SystemExit):
            with Quieter():
                nucleotide_heatmap.parse_args(["max_tss_file"])

        with self.assertRaises(SystemExit):
            with Quieter():
                nucleotide_heatmap.parse_args(["max_tss_file", "region_width"])

        with self.assertRaises(SystemExit):
            with Quieter():
                nucleotide_heatmap.parse_args(["max_tss_file", "region_width", "vertical_average", "extra"])

        max_tss_file = generate_random_filename()
        with open(max_tss_file, 'w') as file:
            file.write(
                "\t".join(['chr1', '1', '2', 'name', '0', '+'])
            )

        result = nucleotide_heatmap.parse_args([max_tss_file, '50', '2000', '2'])
        self.assertEqual(result, (max_tss_file, 50, 2000, 2))

        remove_files(max_tss_file)
Ejemplo n.º 4
0
    def test_no_input(self):
        with self.assertRaises(SystemExit):
            with Quieter():
                make_regions_file_centered_on_max_tss.parse_args([])

        with self.assertRaises(SystemExit):
            with Quieter():
                make_regions_file_centered_on_max_tss.parse_args(['truQuant_file'])

        result = make_regions_file_centered_on_max_tss.parse_args(['truQuant_file', '10'])
        self.assertEqual(result, ('truQuant_file', 10, False))
    def test_arguments(self):
        with self.assertRaises(SystemExit):
            with Quieter():
                read_through_transcription.parse_input([
                    'Regions Filename', 'TSR Filename', '1000', '50000', '50'
                ])

        with self.assertRaises(SystemExit):
            with Quieter():
                read_through_transcription.parse_input(
                    ['Regions Filename', 'TSR Filename', '1000', '50000'])

        with self.assertRaises(SystemExit):
            with Quieter():
                read_through_transcription.parse_input(
                    ['Regions Filename', 'TSR Filename', '1000'])

        with self.assertRaises(SystemExit):
            with Quieter():
                read_through_transcription.parse_input(
                    ['Regions Filename', 'TSR Filename'])

        with self.assertRaises(SystemExit):
            with Quieter():
                read_through_transcription.parse_input(['Regions Filename'])

        max_threads = multiprocessing.cpu_count()

        result = read_through_transcription.parse_input([
            'Regions Filename', 'TSR Filename', '1000', '50000', '50',
            'seq_file'
        ])
        self.assertEqual(result, ('Regions Filename', 'TSR Filename', 1000,
                                  50000, 50, ['seq_file'], max_threads))

        # Test threading works
        result = read_through_transcription.parse_input([
            'Regions Filename', 'TSR Filename', '1000', '50000', '50',
            'seq_file', '-t', '4'
        ])
        self.assertEqual(result, ('Regions Filename', 'TSR Filename', 1000,
                                  50000, 50, ['seq_file'], 4))

        result = read_through_transcription.parse_input([
            'Regions Filename', 'TSR Filename', '1000', '50000', '50',
            'seq_file', '--threads', '4'
        ])
        self.assertEqual(result, ('Regions Filename', 'TSR Filename', 1000,
                                  50000, 50, ['seq_file'], 4))
Ejemplo n.º 6
0
    def test_parse_input(self):
        # No arguments throws error
        with self.assertRaises(SystemExit):
            with Quieter():
                metaplot.parse_input([])

        # Needs a region file and at least one seq file
        regions_file = generate_random_filename()
        with open(regions_file, 'w') as file:
            file.write("\t".join(['chr1', '1', '3', 'name', '0', '+']))

        region_length = 2
        max_threads = multiprocessing.cpu_count()

        # These will work!!
        result = metaplot.parse_input(['five', regions_file, 'seq_file'])
        self.assertEqual(result,
                         ('five', regions_file, ['seq_file'], 2, max_threads))
        result = metaplot.parse_input(['three', regions_file, 'seq_file'])
        self.assertEqual(result,
                         ('three', regions_file, ['seq_file'], 2, max_threads))

        # Test the threading is working
        result = metaplot.parse_input(
            ['five', regions_file, 'seq_file', '-t', '4'])
        self.assertEqual(result, ('five', regions_file, ['seq_file'], 2, 4))

        result = metaplot.parse_input(
            ['three', regions_file, 'seq_file', '--threads', '4'])
        self.assertEqual(result, ('three', regions_file, ['seq_file'], 2, 4))

        remove_files(regions_file)
    def test_arguments(self):
        # No arguments throws an error
        with self.assertRaises(SystemExit):
            with Quieter():
                base_distribution.parse_args([])

        regions_file = generate_random_filename()
        with open(regions_file, 'w') as file:
            file.write("\t".join(['chr1', '1', '3', 'name', '0', '+']))

        # Regions file works file
        result = base_distribution.parse_args([regions_file])
        self.assertEqual(result, (regions_file, 2))

        # Multiple arguments throws an error
        with self.assertRaises(SystemExit):
            with Quieter():
                base_distribution.parse_args(['first', 'second'])

        remove_files(regions_file)
Ejemplo n.º 8
0
    def test_arguments(self):
        with self.assertRaises(SystemExit):
            with Quieter():
                truQuant.parse_input([])

        seq_file_for_annotation = generate_random_filename()

        with open(seq_file_for_annotation, 'w') as file:
            file.write("\t".join(['chr1', '1', '3', 'name', '0', '+']))

        max_threads = multiprocessing.cpu_count()

        result = truQuant.parse_input([seq_file_for_annotation])
        self.assertEqual(result, ([seq_file_for_annotation], 1000, 0.3, 75,
                                  (150, 20, 30, 600), max_threads))

        result = truQuant.parse_input([
            seq_file_for_annotation, '-a', '500', '-b'
            '0.6', '-r', '10', '-t', '20'
        ])
        self.assertEqual(result, ([seq_file_for_annotation], 500, 0.6, 10,
                                  (150, 20, 30, 600), 20))

        result = truQuant.parse_input([
            seq_file_for_annotation, '-a', '500', '--blacklist_percent', '0.6',
            '-r', '10', '-t', '20'
        ])
        self.assertEqual(result, ([seq_file_for_annotation], 500, 0.6, 10,
                                  (150, 20, 30, 600), 20))

        # Try making the blacklist percent greater than one
        with self.assertRaises(SystemExit):
            with Quieter():
                truQuant.parse_input([seq_file_for_annotation, '-b', '1.5'])

        remove_files(seq_file_for_annotation)
    def test_arguments(self):
        with self.assertRaises(SystemExit):
            with Quieter():
                pausing.parse_input(['regions_filename'])

        regions_file = generate_random_filename()
        with open(regions_file, 'w') as file:
            file.write("\t".join(['chr1', '1', '3', 'name', '0', '+']))

        max_threads = multiprocessing.cpu_count()

        result = pausing.parse_input([regions_file, 'seq_file'])
        self.assertEqual(result,
                         (regions_file, ['seq_file'], 100, max_threads))

        # Test the threading option
        result = pausing.parse_input([regions_file, 'seq_file', '-t', '2'])
        self.assertEqual(result, (regions_file, ['seq_file'], 100, 2))
        result = pausing.parse_input(
            [regions_file, 'seq_file', '--threads', '2'])
        self.assertEqual(result, (regions_file, ['seq_file'], 100, 2))

        remove_files(regions_file)
Ejemplo n.º 10
0
 def test_invalid_number_of_arguments(self):
     # Should print the usage
     with self.assertRaises(SystemExit):
         with Quieter():
             TES_fold_change_heatmap.main([])
 def test_search_not_in_region(self):
     # Should raise an InvalidSearch error because polr2a file is -10 to +10
     with self.assertRaises(InvalidSearchException):
         with Quieter():
             sequence_searches.parse_input(
                 [self.polr2a_region_file, 'TATA,-20:-10'])
 def test_incorrect_search(self):
     # Should raise an InvalidSearch error because of the underscore
     with self.assertRaises(InvalidSearchException):
         with Quieter():
             sequence_searches.parse_input(
                 [self.polr2a_region_file, 'TATA,-5_7'])
 def test_only_regions_file(self):
     # Should print the usage
     with self.assertRaises(SystemExit):
         with Quieter():
             sequence_searches.parse_input([self.polr2a_region_file])
 def test_no_arguments(self):
     # Should print the usage
     with self.assertRaises(SystemExit):
         with Quieter():
             sequence_searches.parse_input([])