From 10af3ee99959f6afb8ce5fc65c3d4c2a0b15a136 Mon Sep 17 00:00:00 2001 From: wdecoster Date: Mon, 29 Jul 2024 10:30:12 +0200 Subject: [PATCH] also don't check for index of remote file, doh --- src/utils.rs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index c6c458c..edeafd5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -25,19 +25,26 @@ pub fn reader(filename: &str) -> Box { } 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);