From bcca89366de9963d1d9bf026065e90b1e6af14fa Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Fri, 23 Aug 2024 14:13:39 +0200 Subject: [PATCH] add function for file type check --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1983074..0daf564 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,17 @@ use file_types::{match_file_type, SpectrumFileType}; use precursor::Precursor; use ms2_spectrum::MS2Spectrum; +/// Check if spectrum path matches a supported file type. +#[pyfunction] +pub fn is_supported_file_type(spectrum_path: String) -> bool { + let file_type = match_file_type(&spectrum_path); + + match file_type { + SpectrumFileType::Unknown => false, + _ => true + } +} + /// Get mapping of spectrum identifiers to precursor information. #[pyfunction] pub fn get_precursor_info(spectrum_path: String) -> PyResult> { @@ -57,6 +68,7 @@ pub fn get_ms2_spectra(spectrum_path: String) -> PyResult PyResult<()> { m.add_class::()?; m.add_class::()?; + m.add_function(wrap_pyfunction!(is_supported_file_type, m)?)?; m.add_function(wrap_pyfunction!(get_precursor_info, m)?)?; m.add_function(wrap_pyfunction!(get_ms2_spectra, m)?)?; Ok(())