def _create_merge_filelist(bam_files, base_file, config):
    """Create list of input files for merge, ensuring all files are valid.
    """
    bam_file_list = "%s.list" % os.path.splitext(base_file)[0]
    samtools = config_utils.get_program("samtools", config)
    with open(bam_file_list, "w") as out_handle:
        for f in sorted(bam_files):
            do.run('{} quickcheck -v {}'.format(samtools, f),
                   "Ensure integrity of input merge BAM files")
            out_handle.write("%s\n" % f)
    return bam_file_list
Create list of input files for merge, ensuring all files are valid.