Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhang committed Oct 3, 2024
1 parent dc80360 commit 2d24f86
Show file tree
Hide file tree
Showing 5 changed files with 445 additions and 412 deletions.
22 changes: 6 additions & 16 deletions python/src/pyseqspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,8 @@ impl SeqSpec {

/// Delete a read from the SeqSpec object.
#[pyo3(signature = (read_id), text_signature = "($self, read_id)")]
pub fn delete_read(&mut self, read_id: &str) -> Result<()> {
let reads = self.0.sequence_spec.take();
if let Some(r) = reads {
self.0.sequence_spec = Some(
r.into_iter().filter(|r| r.read_id != read_id).collect::<Vec<_>>()
);
}
Ok(())
pub fn delete_read(&mut self, read_id: &str) {
self.0.delete_read(read_id);
}

/*
Expand All @@ -120,17 +114,13 @@ impl SeqSpec {
fn __repr__(&self) -> String {
let assay = &self.0;
let mut read_list = HashMap::new();
if let Some(reads) = assay.sequence_spec.as_ref() {
for read in reads {
read_list.entry(read.primer_id.clone()).or_insert(Vec::new()).push(read);
}
for read in assay.sequence_spec.values() {
read_list.entry(read.primer_id.clone()).or_insert(Vec::new()).push(read);
}

let tree = Tree::new("".to_string()).with_leaves(
assay.library_spec.as_ref()
.unwrap_or(&Vec::new()).iter()
.map(|region| build_tree(region, &read_list))
);
assay.library_spec.iter().map(|region| build_tree(region, &read_list))
);
format!("{}", tree)
}

Expand Down
1 change: 1 addition & 0 deletions seqspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
anyhow = "1.0"
cached-path = "0.6"
flate2 = "1.0"
indexmap = "2.5"
log = "0.4"
noodles = { version = "0.80", features = ["core", "fastq", "async"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
Loading

0 comments on commit 2d24f86

Please sign in to comment.