PoisonAlien / maftools

Summarize, Analyze and Visualize MAF files from TCGA or in-house studies.
http://bioconductor.org/packages/release/bioc/html/maftools.html
MIT License
452 stars 222 forks source link

sampleSwaps.R: add an error message in case of missing index files #1028

Closed eolaniru closed 5 months ago

eolaniru commented 5 months ago

issue With the sampleSwaps() function, if no index bai file is provided, it crashes r session without any useful error message. It will be useful to raise an error that bai index files should be provided. Thank you

PoisonAlien commented 5 months ago

Hi,

Thanks for the issue. I have updated the function. It should now throw an error if it can't find BAI files in the same directory.

eolaniru commented 5 months ago

Brilliant! Thank you

eolaniru commented 5 months ago

if(!file.exists(paste0(x , ".bai"))){ stop("Index file for ", x, " not found!") } This looks for file.bam.bai as index, since x is file.bam. It will not find file.bai. Would it be possible for check for either file extension? Thank you

eolaniru commented 5 months ago

This should work

    if(!file.exists(paste0(sub("\\.bam$", "", x), ".bai")) && !file.exists(paste0(x, ".bai"))){
      stop("Index file for ", x, " not found!")
    }
PoisonAlien commented 5 months ago

Hi,

Thanks again. I have updated the function, it should check for both now.

8f6e4f7

eolaniru commented 5 months ago

Brilliant! Thank you