Skip to content

Commit

Permalink
v2.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhang committed May 9, 2024
1 parent a6a886f commit 2aa2ec9
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 77 deletions.
6 changes: 3 additions & 3 deletions snapatac2-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ anndata = "0.3.3"
anyhow = "1.0"
bigtools = { version = "0.4", features = ["read", "write"] }
bincode = "1.3"
bed-utils = "0.2"
extsort = "0.4"
bed-utils = "0.3"
extsort = "0.5"
flate2 = "1.0"
tokio = "1.34"
hora = "0.1"
Expand All @@ -36,4 +36,4 @@ serde = "1.0"
statrs = "0.16"
smallvec = "1.13"
tempfile = "3.3"
zstd = { version = "0.13", features = ["zstdmt"] }
zstd = { version = "0.13", features = ["zstdmt"] }
15 changes: 10 additions & 5 deletions snapatac2-core/src/preprocessing/bam/mark_duplicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use noodles::{
use bed_utils::bed::{BEDLike, Strand};
use std::collections::HashMap;
use itertools::Itertools;
use extsort::{sorter::Sortable, ExternalSorter};
use extsort::{Sortable, ExternalSorter};
use bincode;
use log::warn;
use rayon::prelude::ParallelSliceMut;
Expand Down Expand Up @@ -165,12 +165,16 @@ impl AlignmentInfo {
}

impl Sortable for AlignmentInfo {
fn encode<W: std::io::Write>(&self, writer: &mut W) {
bincode::serialize_into(writer, self).unwrap();
fn encode<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
bincode::serialize_into(writer, self).map_err(|e|
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
)
}

fn decode<R: std::io::Read>(reader: &mut R) -> Option<Self> {
bincode::deserialize_from(reader).ok()
fn decode<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
bincode::deserialize_from(reader).map_err(|e|
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
)
}
}

Expand Down Expand Up @@ -420,6 +424,7 @@ where
.then_with(|| a.unclipped_start.cmp(&b.unclipped_start))
.then_with(|| a.unclipped_end.cmp(&b.unclipped_end))
).unwrap()
.map(|x| x.unwrap())
}

RecordGroups {
Expand Down
28 changes: 17 additions & 11 deletions snapatac2-core/src/preprocessing/qc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anndata::data::CsrNonCanonical;
use bed_utils::bed::{GenomicRange, BEDLike, tree::BedTree, ParseError, Strand};
use anyhow::Result;
use serde::{Serialize, Deserialize};
use extsort::sorter::Sortable;
use extsort::Sortable;
use bincode;
use smallvec::{SmallVec, smallvec};

Expand All @@ -22,13 +22,16 @@ pub struct Fragment {
}

impl Sortable for Fragment {
fn encode<W: std::io::Write>(&self, writer: &mut W) {
bincode::serialize_into(writer, self)
.unwrap_or_else(|e| panic!("Failed to serialize fragment: {}", e));
fn encode<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
bincode::serialize_into(writer, self).map_err(|e|
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
)
}

fn decode<R: std::io::Read>(reader: &mut R) -> Option<Self> {
bincode::deserialize_from(reader).ok()
fn decode<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
bincode::deserialize_from(reader).map_err(|e|
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
)
}
}

Expand Down Expand Up @@ -141,13 +144,16 @@ pub struct Contact {
}

impl Sortable for Contact {
fn encode<W: std::io::Write>(&self, writer: &mut W) {
bincode::serialize_into(writer, self)
.unwrap_or_else(|e| panic!("Failed to serialize fragment: {}", e));
fn encode<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
bincode::serialize_into(writer, self).map_err(|e|
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
)
}

fn decode<R: std::io::Read>(reader: &mut R) -> Option<Self> {
bincode::deserialize_from(reader).ok()
fn decode<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
bincode::deserialize_from(reader).map_err(|e|
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
)
}
}

Expand Down
62 changes: 8 additions & 54 deletions snapatac2-python/Cargo.lock

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

6 changes: 3 additions & 3 deletions snapatac2-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snapatac2"
version = "2.6.2-dev0"
version = "2.6.2"
edition = "2021"
authors = ["Kai Zhang <[email protected]>"]
description = "Rust APIs"
Expand All @@ -15,9 +15,9 @@ snapatac2-core = { path = "../snapatac2-core" }
anndata = "0.3.3"
anndata-hdf5 = "0.2"
pyanndata = "0.3.3"
extsort = "0.4"
extsort = "0.5"
anyhow = "1.0"
bed-utils = "0.2"
bed-utils = "0.3"
flate2 = "1.0"
itertools = "0.12"
indicatif = "0.17"
Expand Down
3 changes: 2 additions & 1 deletion snapatac2-python/src/preprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub(crate) fn import_fragments(
f
});
let sorted_fragments: Box<dyn Iterator<Item = Fragment>> = if !fragment_is_sorted_by_name {
Box::new(bed::sort_bed_by_key(fragments, |x| x.barcode.clone(), tempdir))
Box::new(bed::sort_bed_by_key(fragments, |x| x.barcode.clone(), tempdir).map(|x| x.unwrap()))
} else {
Box::new(fragments)
};
Expand Down Expand Up @@ -164,6 +164,7 @@ pub(crate) fn import_contacts(
.with_sort_dir(tmp.path().to_path_buf())
.with_parallel_sort()
.sort_by_key(contacts, |x| x.barcode.clone()).unwrap()
.map(|x| x.unwrap())
)
} else {
Box::new(contacts)
Expand Down

0 comments on commit 2aa2ec9

Please sign in to comment.