Skip to content

Commit c9d22bc

Browse files
committed
Pseudobulk now does not need to resort fragment files.
1 parent c620032 commit c9d22bc

File tree

5 files changed

+597
-0
lines changed

5 files changed

+597
-0
lines changed

pycistopic-lib/Cargo.lock

Lines changed: 241 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pycistopic-lib/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "pycistopic-lib"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
# The name of the native library. This is the name which will be used in Python to import the
8+
# library (i.e. `import string_sum`). If you change this, you must also change the name of the
9+
# `#[pymodule]` in `src/lib.rs`.
10+
name = "pycistopic_lib"
11+
# "cdylib" is necessary to produce a shared library for Python to import from.
12+
#
13+
# Downstream Rust code (including code in `bin/`, `examples/`, and `tests/`) will not be able
14+
# to `use string_sum;` unless the "rlib" or "lib" crate type is also included, e.g.:
15+
# crate-type = ["cdylib", "rlib"]
16+
crate-type = ["cdylib"]
17+
18+
[dependencies]
19+
pyo3 = { version = "0.23.5", features = ["extension-module"] }
20+
flate2 = {version = "1.1.0",features = ["zlib-ng"], default-features = false}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
use pyo3::exceptions::{PyIOError, PyValueError};
2+
use std::fmt;
3+
use pyo3::PyErr;
4+
5+
#[derive(Debug)]
6+
pub struct InvalidFragmentFileError {
7+
pub filename: String,
8+
}
9+
10+
impl InvalidFragmentFileError {
11+
pub fn new(filename: &str) -> InvalidFragmentFileError {
12+
InvalidFragmentFileError{
13+
filename: filename.to_string()
14+
}
15+
}
16+
}
17+
18+
impl std::error::Error for InvalidFragmentFileError{}
19+
20+
impl fmt::Display for InvalidFragmentFileError {
21+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22+
write!(f, "{}: Invalid fragment file.", self.filename)
23+
}
24+
}
25+
26+
impl From<InvalidFragmentFileError> for PyErr {
27+
fn from(err: InvalidFragmentFileError) -> PyErr {
28+
PyIOError::new_err(err.to_string())
29+
}
30+
}
31+
32+
#[derive(Debug)]
33+
pub struct ValueError {
34+
pub message: String,
35+
}
36+
37+
impl ValueError {
38+
pub fn new(message: String) -> ValueError {
39+
ValueError {
40+
message
41+
}
42+
}
43+
}
44+
45+
impl std::error::Error for ValueError{}
46+
47+
impl fmt::Display for ValueError {
48+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
49+
write!(f, "{}", self.message)
50+
}
51+
}
52+
53+
impl From<ValueError> for PyErr {
54+
fn from(err: ValueError) -> PyErr {
55+
PyValueError::new_err(err.to_string())
56+
}
57+
}
58+

pycistopic-lib/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
mod pseudobulk;
2+
mod custom_errors;
3+
4+
use pyo3::prelude::*;
5+
6+
7+
/// A Python module implemented in Rust. The name of this function must match
8+
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
9+
/// import the module.
10+
#[pymodule]
11+
fn pycistopic_lib(m: &Bound<'_, PyModule>) -> PyResult<()> {
12+
m.add_function(wrap_pyfunction!(pseudobulk::split_fragment_files_by_cell_type, m)?)?;
13+
Ok(())
14+
}

0 commit comments

Comments
 (0)