Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add glob::glob file expansion #134

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/sage-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 23 additions & 1 deletion crates/sage-cli/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -176,7 +177,28 @@ impl Input {
input.database.fasta = Some(fasta.into());
}
if let Some(mzml_paths) = matches.get_many::<String>("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::<bool>("write-pin").copied() {
Expand Down
Loading