Skip to content

Commit

Permalink
update BAI check
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonAlien committed Jun 11, 2024
1 parent 1992ee7 commit 8f6e4f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/ntcounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ bamreadcounts = function(bam = NULL, loci = NULL, zerobased = FALSE, mapq = 10,
}

if(!file.exists(paste0(x , ".bai"))){
stop("Index file for ", x, " not found!")
#Check for foo.bai as well
x_bn = unlist(data.table::tstrsplit(x = basename(x), split = "\\.", keep = 1))
if(! file.exists(paste0(dirname(x),"/", x_bn, ".bai"))){
stop("Index file for ", x, " not found!")
}
}

gsub(pattern = "\\.bam$", replacement = "", x = basename(x), ignore.case = TRUE)
Expand Down

0 comments on commit 8f6e4f7

Please sign in to comment.