Skip to content

Commit

Permalink
also don't check for index of remote file, doh
Browse files Browse the repository at this point in the history
  • Loading branch information
wdecoster committed Jul 29, 2024
1 parent b13e993 commit 10af3ee
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ pub fn reader(filename: &str) -> Box<dyn BufRead> {
}

pub fn check_files_exist(args: &crate::Cli) {
if !Path::new(&args.bam).exists() && !args.bam.starts_with("s3") && !args.bam.starts_with("https://") {
error!("Alignment file not found: {}", args.bam);
std::process::exit(1);
}
let index_extension = if args.bam.ends_with(".cram") {
"crai"
} else {
"bai"
};
let index = format!("{}.{}", args.bam, index_extension);
if !Path::new(&index).exists() {
error!("Index file not found: {}", index);
std::process::exit(1);
// check if the input files exist, and if not, exit gracefully

if !args.bam.starts_with("s3") && !args.bam.starts_with("https://") {
// TODO: We don't check for existence of remote files or their indexes
// TODO: this could lead to nastier errors later, if the file happens to be unreachable
// TODO: so maybe some time this should be properly implemented
if !Path::new(&args.bam).exists() {
error!("Alignment file not found: {}", args.bam);
std::process::exit(1);
}
let index_extension = if args.bam.ends_with(".cram") {
"crai"
} else {
"bai"
};
let index = format!("{}.{}", args.bam, index_extension);
if !Path::new(&index).exists() {
error!("Index file not found: {}", index);
std::process::exit(1);
}
}
if !Path::new(&args.fasta).exists() {
error!("FASTA file not found: {}", args.fasta);
Expand Down

0 comments on commit 10af3ee

Please sign in to comment.