Exemplo n.º 1
0
    def test_humann2_rna_dna_norm_log_10_tsv(self):
        """
        Test norm the tsv file entries from dna and rna input files with humann2_rna_dna_norm_table
        Test with log transform with base 10
        """

        # create a temp folder
        tempdir = utils.create_temp_folder("rna_dna_norm_log_10")
        output_basename = os.path.join(tempdir, "rna_dna_norm")

        # run the command
        utils.run_command([
            "humann2_rna_dna_norm", "--input_dna", cfg.rna_dna_norm_dna_input,
            "--input_rna", cfg.rna_dna_norm_rna_input, "--output_basename",
            output_basename, "--log_transform", "--log_base", "10"
        ])

        # check the output files are as expected
        # allow for varying precision in the calculations with almost equal
        for file_extension, expected_output_file in zip(
                cfg.rna_dna_norm_file_names,
                cfg.rna_dna_norm_log_10_output_files):
            self.assertTrue(
                utils.files_almost_equal(output_basename + file_extension,
                                         expected_output_file))

        # remove the temp file
        utils.remove_temp_folder(tempdir)
Exemplo n.º 2
0
    def test_humann2_rna_dna_norm_witten_bell_tsv(self):
        """
        Test norm the tsv file entries from dna and rna input files with humann2_rna_dna_norm_table
        Test with witten bell
        """

        # create a temp folder
        tempdir = utils.create_temp_folder("rna_dna_norm_witten_bell")
        output_basename = os.path.join(tempdir, "rna_dna_norm")

        # run the command
        utils.run_command([
            "humann2_rna_dna_norm", "--input_dna", cfg.rna_dna_norm_dna_input,
            "--input_rna", cfg.rna_dna_norm_rna_input, "--output_basename",
            output_basename, "--method", "witten_bell"
        ])

        # check the output files are as expected
        for file_extension, expected_output_file in zip(
                cfg.rna_dna_norm_file_names,
                cfg.rna_dna_norm_witten_bell_output_files):
            self.assertTrue(
                utils.files_almost_equal(output_basename + file_extension,
                                         expected_output_file))

        # remove the temp file
        utils.remove_temp_folder(tempdir)
Exemplo n.º 3
0
def _save_resource(logger, resource, resource_path, target_path):
    if not target_path:
        target_path = os.path.join(utils.create_temp_folder(), os.path.basename(resource_path))
    with open(target_path, "w") as f:
        f.write(resource)
    logger.info("Downloaded %s to %s" % (resource_path, target_path))
    return target_path
    def test_humann_fastq_biom_output(self):
        """
        Test the standard humann flow on a fastq input file
        Test biom output is written
        """
        
        # create a temp directory for output
        tempdir = utils.create_temp_folder("fastq")
        
        # run humann test
        command = ["humann","--input",cfg.demo_fastq,"--output",tempdir,
                   "--output-format", "biom"]
        utils.run_humann(command)
        
        # check the output files are as expected
        for expression, message in utils.check_output(cfg.expected_demo_output_files_biom, tempdir):
            self.assertTrue(expression,message)

        # remove the temp directory
        utils.remove_temp_folder(tempdir)
Exemplo n.º 5
0
    def test_humann2_fastq_bypass_translated_search(self):
        """
        Test the standard humann2 flow on a fastq input file
        Test with bypassing translated search
        """

        # create a temp directory for output
        tempdir = utils.create_temp_folder("fastq_bypass_translated_search")

        # run humann2 test
        command = [
            "humann2", "--input", cfg.demo_fastq, "--output", tempdir,
            "--bypass-translated-search"
        ]
        utils.run_humann2(command)

        # check the output files are as expected
        for expression, message in utils.check_output(
                cfg.expected_demo_output_files, tempdir):
            self.assertTrue(expression, message)

        # remove the temp directory
        utils.remove_temp_folder(tempdir)
Exemplo n.º 6
0
    def test_humann2_strain_profile_tsv(self):
        """
        Test the tsv file entries running humann2_strain_profile
        Test with critical mean and critical count values
        """

        # create a temp folder
        tempdir = utils.create_temp_folder("strain_profile")

        # move to this folder as the output files will be created in the current working folder
        current_working_directory = os.getcwd()
        try:
            os.chdir(tempdir)
        except EnvironmentError:
            print("Warning: Unable to move to temp directory: " + tempdir)

        # run the command
        utils.run_command([
            "humann2_strain_profiler", "--input", cfg.strain_profile_input,
            "--critical_mean", "1", "--critical_count", "2"
        ])

        # check the output files are as expected
        # allow for varying precision in the calculations with almost equal
        for file, expected_output_file in zip(
                cfg.strain_profile_file_names,
                cfg.strain_profile_m1_n2_output_files):
            self.assertTrue(
                utils.files_almost_equal(os.path.join(tempdir, file),
                                         expected_output_file))

        # return to original working directory
        os.chdir(current_working_directory)

        # remove the temp file
        utils.remove_temp_folder(tempdir)