Skip to content

CHORE: version update #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 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.2"
version = "0.4.3"
edition = "2021"
description = "A crate to read Bruker timsTOF data"
license = "Apache-2.0"
Expand All @@ -18,7 +18,7 @@ zstd = "0.13.2"
rayon = "1.10.0"
linreg = "0.2.0"
bytemuck = "1.18.0"
thiserror = "1.0.0"
thiserror = "2.0.3"
memmap2 = "0.9.3"
rusqlite = { version = "0.32.0", features = ["bundled"], optional = true }
parquet = { version = "53.0.0", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

![Crates.io](https://img.shields.io/crates/v/timsrust?link=https%3A%2F%2Fcrates.io%2Fcrates%2Ftimsrust)
![docs.rs](https://img.shields.io/docsrs/timsrust?link=https%3A%2F%2Fdocs.rs%2Ftimsrust%2F0.2.1%2Ftimsrust%2F)
[![Crates.io](https://img.shields.io/crates/v/timsrust?link=https%3A%2F%2Fcrates.io%2Fcrates%2Ftimsrust)](https://crates.io/crates/timsrust)
[![docs.rs](https://img.shields.io/docsrs/timsrust?link=https%3A%2F%2Fdocs.rs%2Ftimsrust%2F0.2.1%2Ftimsrust%2F)](https://docs.rs/timsrust/0.4.2/timsrust/)

# TimsRust

Expand Down
5 changes: 5 additions & 0 deletions src/io/readers/file_readers/tdf_blob_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ impl TdfBlobReader {
.bin_file_reader
.get_data(offset, byte_count)
.ok_or(TdfBlobReaderError::CorruptData)?;
if data.len() == 0 {
return Err(TdfBlobReaderError::EmptyData);
}
let bytes =
decode_all(data).map_err(|_| TdfBlobReaderError::Decompression)?;
let blob = TdfBlob::new(bytes)?;
Expand Down Expand Up @@ -130,6 +133,8 @@ pub enum TdfBlobReaderError {
IO(#[from] io::Error),
#[error("{0}")]
TdfBlob(#[from] TdfBlobError),
#[error("No binary data")]
EmptyData,
#[error("Data is corrupt")]
CorruptData,
#[error("Decompression fails")]
Expand Down
11 changes: 7 additions & 4 deletions src/io/readers/frame_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ impl FrameReader {
let sql_frames = SqlFrame::from_sql_reader(&tdf_sql_reader)?;
let tdf_bin_reader = TdfBlobReader::new(&path)?;
#[cfg(feature = "timscompress")]
let compressed_reader = CompressedTdfBlobReader::new(&path)
.ok_or_else(|| FrameReaderError::TimscompressError)?;
let compressed_reader = CompressedTdfBlobReader::new(
&path.as_ref().to_path_buf().join("analysis.tdf_bin"),
)
.ok_or_else(|| FrameReaderError::TimscompressError)?;
let acquisition = if sql_frames.iter().any(|x| x.msms_type == 8) {
AcquisitionType::DDAPASEF
} else if sql_frames.iter().any(|x| x.msms_type == 9) {
Expand Down Expand Up @@ -165,7 +167,7 @@ impl FrameReader {
let offset = self.get_binary_offset(index);
let blob = self.tdf_bin_reader.get(offset)?;
let scan_count: usize =
blob.get(0).ok_or(FrameReaderError::CorruptFrame)? as usize;
blob.get(0).expect("Blob cannot be empty") as usize;
let peak_count: usize = (blob.len() - scan_count) / 2;
frame.scan_offsets = read_scan_offsets(scan_count, peak_count, &blob)?;
frame.intensities = read_intensities(scan_count, peak_count, &blob)?;
Expand All @@ -189,7 +191,8 @@ impl FrameReader {
let offset = self.get_binary_offset(index);
let raw_frame = self
.compressed_reader
.get_raw_frame_data(offset, self.scan_count);
.get_raw_frame_data(offset, self.scan_count)
.ok_or_else(|| FrameReaderError::TimscompressError)?;
frame.tof_indices = raw_frame.tof_indices;
frame.intensities = raw_frame.intensities;
frame.scan_offsets = raw_frame.scan_offsets;
Expand Down