Skip to content

Commit

Permalink
Merge pull request #29 from MannLabs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sander-willems-bruker authored Sep 3, 2024
2 parents 96716e5 + d58e46b commit 252b849
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 15 deletions.
17 changes: 10 additions & 7 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "timsrust"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
description = "A crate to read Bruker timsTOF data"
license = "Apache-2.0"
Expand All @@ -22,11 +22,14 @@ thiserror = "1.0.0"
memmap2 = "0.9.3"
rusqlite = { version = "0.31.0", features = ["bundled"], optional = true}
parquet = { version = "42.0.0", optional = true }
serde = { version = "1.0.209", features = ["derive"], optional = true }
serde_json = { version = "1.0.127", optional = true }

[features]
tdf = ["rusqlite"]
minitdf = ["parquet"]
default = ["tdf", "minitdf"]
default = ["tdf", "minitdf", "serialize"]
serialize = ["serde", "serde_json"]

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
Expand Down
4 changes: 4 additions & 0 deletions src/domain_converters/scan_to_im.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};

/// A converter from Scan -> (inversed) ion mobility.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Scan2ImConverter {
scan_intercept: f64,
scan_slope: f64,
Expand Down
3 changes: 3 additions & 0 deletions src/domain_converters/tof_to_mz.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use linreg::linear_regression;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};

/// A converter from TOF -> m/z.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Tof2MzConverter {
tof_intercept: f64,
tof_slope: f64,
Expand Down
1 change: 1 addition & 0 deletions src/io/readers/frame_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl FrameReader {
}

pub fn get(&self, index: usize) -> Result<Frame, FrameReaderError> {
// NOTE: get does it by 0-offsetting the vec, not by Frame index!!!
let mut frame = self.frames[index].clone();
let offset = self.offsets[index];
let blob = self.tdf_bin_reader.get(offset)?;
Expand Down
2 changes: 1 addition & 1 deletion src/io/readers/precursor_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl PrecursorReaderBuilder {
}
}

trait PrecursorReaderTrait: Sync {
trait PrecursorReaderTrait: Sync + Send {
fn get(&self, index: usize) -> Option<Precursor>;
fn len(&self) -> usize;
}
Expand Down
4 changes: 4 additions & 0 deletions src/io/readers/quad_settings_reader.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::path::Path;

use crate::{
Expand Down Expand Up @@ -151,6 +153,7 @@ type ScanSpanStep = (usize, usize);
/// 100 and step 80 between their in the scan number.
///
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum QuadWindowExpansionStrategy {
None,
Even(usize),
Expand All @@ -171,6 +174,7 @@ pub enum FrameWindowSplittingStrategy {
}

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum FrameWindowSplittingConfiguration {
Quadrupole(QuadWindowExpansionStrategy),
Window(QuadWindowExpansionStrategy),
Expand Down
12 changes: 8 additions & 4 deletions src/io/readers/spectrum_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use core::fmt;
#[cfg(feature = "minitdf")]
use minitdf::{MiniTDFSpectrumReader, MiniTDFSpectrumReaderError};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
#[cfg(feature = "tdf")]
use tdf::{TDFSpectrumReader, TDFSpectrumReaderError};
Expand Down Expand Up @@ -64,7 +66,7 @@ impl SpectrumReader {
spectra
}

pub fn calibrate(&mut self) {
fn calibrate(&mut self) {
self.spectrum_reader.calibrate();
}
}
Expand Down Expand Up @@ -116,7 +118,7 @@ impl SpectrumReaderBuilder {
}
}

trait SpectrumReaderTrait: Sync {
trait SpectrumReaderTrait: Sync + Send {
fn get(&self, index: usize) -> Result<Spectrum, SpectrumReaderError>;
fn get_path(&self) -> PathBuf;
fn len(&self) -> usize;
Expand All @@ -135,7 +137,8 @@ pub enum SpectrumReaderError {
SpectrumReaderFileError(PathBuf),
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct SpectrumProcessingParams {
pub smoothing_window: u32,
pub centroiding_window: u32,
Expand All @@ -154,7 +157,8 @@ impl Default for SpectrumProcessingParams {
}
}

#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct SpectrumReaderConfig {
pub spectrum_processing_params: SpectrumProcessingParams,
#[cfg(feature = "tdf")]
Expand Down
2 changes: 1 addition & 1 deletion src/io/readers/spectrum_reader/tdf/raw_spectra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl RawSpectrumReader {
}
}

pub trait RawSpectrumReaderTrait: Sync {
pub trait RawSpectrumReaderTrait: Sync + Send {
fn get(&self, index: usize) -> Result<RawSpectrum, RawSpectrumReaderError>;
fn len(&self) -> usize;
}
Expand Down

0 comments on commit 252b849

Please sign in to comment.