def test_multiple_output_files(self):
        """ Creates one file per sampleID for fasta/qual output """
        convert_fastaqual(
            self.fasta_file_path, multiple_output_files=True, output_directory=self.output_dir, per_file_buffer_size=23
        )

        sample_id_s = [
            ("PC.634", expected_fasta_634_default, expected_qual_634_default),
            ("PC.354", expected_fasta_354_default, expected_qual_354_default),
            ("PC.481", expected_fasta_481_default, expected_qual_481_default),
        ]
        for sample_id, expected_fasta, expected_qual in sample_id_s:
            actual_output_fasta_path = get_filename_with_new_ext(
                self.fasta_file_path, "_" + sample_id + ".fna", self.output_dir
            )

            actual_output_qual_path = get_filename_with_new_ext(
                self.fasta_file_path, "_" + sample_id + ".qual", self.output_dir
            )

            actual_output_fasta = open(actual_output_fasta_path)
            actual_output_qual = open(actual_output_qual_path)
            actual_fasta = actual_output_fasta.read()
            actual_output_fasta.close()
            actual_qual = actual_output_qual.read()
            actual_output_qual.close()
            self._files_to_remove.append(actual_output_fasta_path)
            self._files_to_remove.append(actual_output_qual_path)

            self.assertEquals(actual_fasta, expected_fasta)
            self.assertEquals(actual_qual, expected_qual)
    def test_multiple_output_files(self):
        """ properly writes multiple fasta files for each sampleID"""
        convert_fastq(
            self.fasta_file_path,
            self.qual_file_path,
            multiple_output_files=True,
            output_directory=self.output_dir,
            per_file_buffer_size=23,
        )

        sample_ids = [
            ("PC.634", expected_fastq_634_default),
            ("PC.354", expected_fastq_354_default),
            ("PC.481", expected_fastq_481_default),
        ]
        for sample_id, expected_output in sample_ids:
            actual_output_file_path = get_filename_with_new_ext(
                self.fasta_file_path, "_" + sample_id + ".fastq", self.output_dir
            )

            actual_output_file = open(actual_output_file_path)
            actual_output = actual_output_file.read()
            actual_output_file.close()
            self._files_to_remove.append(actual_output_file_path)

            self.assertEquals(actual_output, expected_output)
    def test_full_fasta_headers(self):
        """ Full headers written to fasta/qual files """
        convert_fastaqual(self.fasta_file_path, full_fasta_headers=True, output_directory=self.output_dir)

        actual_output_fasta_path = get_filename_with_new_ext(self.fasta_file_path, ".fna", self.output_dir)

        actual_output_qual_path = get_filename_with_new_ext(self.fasta_file_path, ".qual", self.output_dir)

        actual_output_fasta = open(actual_output_fasta_path)
        actual_output_qual = open(actual_output_qual_path)
        actual_fasta = actual_output_fasta.read()
        actual_output_fasta.close()
        actual_qual = actual_output_qual.read()
        actual_output_qual.close()
        self._files_to_remove.append(actual_output_fasta_path)
        self._files_to_remove.append(actual_output_qual_path)

        self.assertEquals(actual_fasta, expected_fasta_full_fasta_headers)
        self.assertEquals(actual_qual, expected_qual_full_fasta_headers)
    def test_default_settings(self):
        """ Converting to fasta/qual files handles default settings """
        convert_fastaqual(self.fasta_file_path, output_directory=self.output_dir)

        actual_output_fasta_path = get_filename_with_new_ext(self.fasta_file_path, ".fna", self.output_dir)

        actual_output_qual_path = get_filename_with_new_ext(self.fasta_file_path, ".qual", self.output_dir)

        actual_output_fasta = open(actual_output_fasta_path)
        actual_output_qual = open(actual_output_qual_path)
        actual_fasta = actual_output_fasta.read()
        actual_output_fasta.close()
        actual_qual = actual_output_qual.read()
        actual_output_qual.close()
        self._files_to_remove.append(actual_output_fasta_path)
        self._files_to_remove.append(actual_output_qual_path)

        self.assertEquals(actual_fasta, expected_fasta_default_options)
        self.assertEquals(actual_qual, expected_qual_default_options)
    def test_default_settings(self):
        """ Handles conversions with default settings """
        convert_fastq(self.fasta_file_path, self.qual_file_path, output_directory=self.output_dir)

        actual_output_file_path = get_filename_with_new_ext(self.fasta_file_path, ".fastq", self.output_dir)

        actual_output_file = open(actual_output_file_path)
        actual_output = actual_output_file.read()
        actual_output_file.close()
        self._files_to_remove.append(actual_output_file_path)

        self.assertEquals(actual_output, expected_fastq_default_options)
    def test_get_filename_with_new_ext(self):
        """ Tests proper function of the utility function. """
        test_paths = [
            ("/from/root/test.xxx", "test.yyy"),
            ("../relative/path/test.xxx", "test.yyy"),
            ("/double/extension/in/filename/test.zzz.xxx", "test.zzz.yyy"),
        ]

        for input, exp_output in test_paths:
            exp_output = join(self.output_dir, exp_output)

            self.assertEquals(get_filename_with_new_ext(input, ".yyy", self.output_dir), exp_output)
    def test_full_fasta_headers(self):
        """ Properly retains full fasta headers """
        convert_fastq(
            self.fasta_file_path, self.qual_file_path, full_fasta_headers=True, output_directory=self.output_dir
        )

        actual_output_file_path = get_filename_with_new_ext(self.fasta_file_path, ".fastq", self.output_dir)

        actual_output_file = open(actual_output_file_path)
        actual_output = actual_output_file.read()
        actual_output_file.close()
        self._files_to_remove.append(actual_output_file_path)

        self.assertEquals(actual_output, expected_fastq_full_fasta_headers)