Rust-covpyo3 0.2.4__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/Cargo.lock +1 -1
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/Cargo.toml +1 -1
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/PKG-INFO +1 -1
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/src/lib.rs +21 -0
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/.gitignore +0 -0
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/LICENSE +0 -0
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/pyproject.toml +0 -0
- {rust_covpyo3-0.2.4 → rust_covpyo3-0.3.0}/readme.rmd +0 -0
|
@@ -46,6 +46,26 @@ fn get_header(bam_path: String) -> PyResult<Vec<String>>{
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
/// return number mapped reads per chromosome, plus the number of unmapped reads
|
|
50
|
+
#[pyfunction]
|
|
51
|
+
fn get_mapped_reads(bam_path: String) -> PyResult<Vec<(String, u64)>>{
|
|
52
|
+
|
|
53
|
+
let mut bam = IndexedReader::from_path(&bam_path).unwrap();
|
|
54
|
+
let mut seq: Vec<(String, u64)> = Vec::new();
|
|
55
|
+
let stats = bam.index_stats().unwrap();
|
|
56
|
+
|
|
57
|
+
for (tid, length, mapped, unreads) in stats{
|
|
58
|
+
if tid < 0{
|
|
59
|
+
seq.push(("Unammped".to_string(), mapped));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let name = std::str::from_utf8(bam.header().tid2name(tid as u32)).unwrap();
|
|
63
|
+
seq.push((name.to_string(), mapped));
|
|
64
|
+
}
|
|
65
|
+
Ok(seq)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
49
69
|
/// Calculates coverage at each position using the pileup algorithm.
|
|
50
70
|
///
|
|
51
71
|
/// Retrieves primary aligned reads from a BAM file within a specified genomic region
|
|
@@ -261,5 +281,6 @@ fn Rust_covpyo3(_py: Python, m: &PyModule) -> PyResult<()> {
|
|
|
261
281
|
m.add_function(wrap_pyfunction!(get_coverage, m)?)?;
|
|
262
282
|
m.add_function(wrap_pyfunction!(get_header, m)?)?;
|
|
263
283
|
m.add_function(wrap_pyfunction!(get_coverage_algo2, m)?)?;
|
|
284
|
+
m.add_function(wrap_pyfunction!(get_mapped_reads, m)?)?;
|
|
264
285
|
Ok(())
|
|
265
286
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|