Skip to content

Commit 8e96109

Browse files
committed
chore: lints, formatting, touch up mgf charge regex
1 parent fe43750 commit 8e96109

File tree

7 files changed

+104
-100
lines changed

7 files changed

+104
-100
lines changed

crates/sage-cli/src/main.rs

+14-24
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use sage_core::mass::Tolerance;
99
use sage_core::scoring::{Feature, Scorer};
1010
use sage_core::spectrum::{ProcessedSpectrum, SpectrumProcessor};
1111
use sage_core::tmt::TmtQuant;
12-
use std::path::PathBuf;
1312
use std::time::Instant;
1413

1514
mod input;
@@ -192,34 +191,25 @@ impl Runner {
192191
self.parameters.deisotope,
193192
);
194193

195-
let bruker_extensions = ["d", "tdf", "tdf_bin"];
194+
let bruker_extensions = [".d", ".tdf", ".tdf_bin"];
196195
let spectra = chunk
197196
.par_iter()
198197
.enumerate()
199198
.flat_map(|(idx, path)| {
200-
let res = match path {
201-
path if bruker_extensions.contains(
202-
&PathBuf::from(path)
203-
.extension()
204-
.unwrap_or_default()
205-
.to_str()
206-
.unwrap_or_default(),
207-
) =>
208-
{
209-
sage_cloudpath::util::read_tdf(path, chunk_idx * batch_size + idx)
210-
}
211-
path if PathBuf::from(path)
212-
.extension()
213-
.unwrap_or_default()
214-
.to_str()
215-
.unwrap_or_default()
216-
.to_lowercase()
217-
== "mgf" =>
218-
{
219-
sage_cloudpath::util::read_mgf(path, chunk_idx * batch_size + idx)
220-
}
221-
_ => sage_cloudpath::util::read_mzml(path, chunk_idx * batch_size + idx, sn),
199+
let file_id = chunk_idx * batch_size + idx;
200+
201+
let path_lower = path.to_lowercase();
202+
let res = if path_lower.ends_with(".mgf.gz") || path_lower.ends_with(".mgf") {
203+
sage_cloudpath::util::read_mgf(path_lower, file_id)
204+
} else if bruker_extensions
205+
.iter()
206+
.any(|ext| path_lower.ends_with(ext))
207+
{
208+
sage_cloudpath::util::read_tdf(path, file_id)
209+
} else {
210+
sage_cloudpath::util::read_mzml(path, file_id, sn)
222211
};
212+
223213
match res {
224214
Ok(s) => {
225215
log::trace!("- {}: read {} spectra", path, s.len());

crates/sage-cloudpath/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::path::PathBuf;
66
use std::str::FromStr;
77
use tokio::io::{AsyncBufRead, AsyncRead, AsyncWriteExt, BufReader};
88

9+
pub mod mgf;
910
pub mod mzml;
1011
pub mod tdf;
11-
pub mod mgf;
1212
pub mod util;
1313

1414
#[cfg(feature = "parquet")]

0 commit comments

Comments
 (0)