PeeperLab / CopywriteR

DNA copy number detection from off-target sequence data
GNU General Public License v3.0
28 stars 10 forks source link

matching bam index with file name pattern like "a.bam" and "a.bai" #32

Open MajoroMask opened 3 years ago

MajoroMask commented 3 years ago

Since many softwares (like GATK 4.1.7.0 I'm using now) generate bam index with file name like a.bam and a.bai instead of a.bam.bai, maybe we can change the index matching code from this:

## Index .bam files
-   if (!all(file.exists(gsub("$", ".bai", sample.paths)))) {
+   if (!all(file.exists(gsub("$", ".bai", sample.paths)) | file.exists(gsub("\\.bam$", ".bai", sample.paths)))) {
        if (file.access(".", 2) == -1) {
            stop(.wrap("The .bam files are not indexed and you do not have",
                       "write permission in (one of) the folder(s) where the",
                       ".bam files are located."))
        }
        IndexBam <- function(sample.paths) {
            indexBam(sample.paths)
            paste0("indexBam(\"", sample.paths, "\")")
        }
        to.log <- bplapply(sample.paths, IndexBam, BPPARAM = bp.param)
        lapply(to.log, flog.info)
    }