diff --git a/Cargo.lock b/Cargo.lock index a08e23f..c2d2c63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1205,6 +1205,12 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.24" @@ -2260,6 +2266,7 @@ dependencies = [ "csv", "env_logger", "fnv", + "glob", "itoa", "log", "num_cpus", diff --git a/crates/sage-cli/Cargo.toml b/crates/sage-cli/Cargo.toml index 1ee88d0..368debf 100644 --- a/crates/sage-cli/Cargo.toml +++ b/crates/sage-cli/Cargo.toml @@ -23,6 +23,7 @@ csv = "1" clap = { version="4.0", features = ["cargo", "unicode"] } env_logger = "0.8.4" fnv = "1.0" +glob = "0.3.1" log = "0.4.0" itoa = "1.0" num_cpus = "1.13" diff --git a/crates/sage-cli/src/input.rs b/crates/sage-cli/src/input.rs index 4576103..2d337da 100644 --- a/crates/sage-cli/src/input.rs +++ b/crates/sage-cli/src/input.rs @@ -8,6 +8,7 @@ use sage_core::{ tmt::Isobaric, }; use serde::{Deserialize, Serialize}; +use glob::glob; #[derive(Serialize)] /// Actual search parameters - may include overrides or default values not set by user @@ -176,7 +177,28 @@ impl Input { input.database.fasta = Some(fasta.into()); } if let Some(mzml_paths) = matches.get_many::("mzml_paths") { - input.mzml_paths = Some(mzml_paths.into_iter().map(|p| p.into()).collect()); + let mut paths = Vec::new(); + for path_pattern in mzml_paths { + match glob(path_pattern) { + Ok(glob_paths) => { + for entry in glob_paths { + match entry { + Ok(path) => { + // Convert PathBuf to String, handle potential conversion error + if let Some(path_str) = path.to_str() { + paths.push(path_str.to_string()); + } else { + log::error!("Error converting path to string: {:?}", path); + } + }, + Err(e) => log::error!("Error processing path: {}", e), + } + } + }, + Err(e) => log::error!("Glob pattern error: {}", e), + } + } + input.mzml_paths = Some(paths); } if let Some(write_pin) = matches.get_one::("write-pin").copied() {