Skip to content

Commit

Permalink
add function for file type check
Browse files Browse the repository at this point in the history
  • Loading branch information
paretje committed Aug 23, 2024
1 parent f5d34ba commit bcca893
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashMap<String, Precursor>> {
Expand Down Expand Up @@ -57,6 +68,7 @@ pub fn get_ms2_spectra(spectrum_path: String) -> PyResult<Vec<ms2_spectrum::MS2S
fn ms2rescore_rs(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<Precursor>()?;
m.add_class::<MS2Spectrum>()?;
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(())
Expand Down

0 comments on commit bcca893

Please sign in to comment.