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(())