Пример #1
0
    def test_different_format(self, tmpdir, filetype, combined_output_type,
                              which_names, extant_files, num_cores):
        """ File content is actually combined, and formats can differ. """

        # Manual creation of the processor here to control output type.
        path_output_file = tmpdir.join(
            "testfile.{}".format(combined_output_type)).strpath
        processor = IdentityProcessor(PATH_ALIGNED_FILE,
                                      cores=num_cores,
                                      outfile=path_output_file,
                                      intermediate_output_type=filetype)
        processor.temp_folder = tmpdir.strpath

        # Write to the dummy output file for each chunk.
        expected_lines = {
            fp: "file{}: {}\n".format(i, fp)
            for i, fp in enumerate(extant_files)
        }
        for fp, line in expected_lines.items():
            with open(fp, 'w') as f:
                f.write(line)

        # For control, enforce that combined output doesn't already exist.
        assert not os.path.exists(path_output_file)
        processor.combine(self.CHUNK_NAMES[which_names], strict=True)
        assert os.path.isfile(path_output_file)

        # Check that output was combined accurately.
        with open(path_output_file, 'r') as combined:
            observed_lines = combined.readlines()
        assert set(expected_lines.values()) == set(observed_lines)
Пример #2
0
    def test_nothing_to_combine(self, tmpdir, path_logs_file, num_cores,
                                error_if_missing):
        """ Complete lack of output is sufficient to warrant a warning. """

        # Create the processor and do combine() step.
        path_output_file = tmpdir.join("output.txt").strpath
        processor = IdentityProcessor(PATH_ALIGNED_FILE,
                                      cores=num_cores,
                                      outfile=path_output_file)
        num_logs_before_combine = len(loglines(path_logs_file))
        processor.combine(good_chromosomes=[], strict=error_if_missing)
        log_records = loglines(path_logs_file)

        # The log record should be a warning, and there's only one.
        assert 1 == len(log_records) - num_logs_before_combine
        assert "WARN" in log_records[num_logs_before_combine]