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.
@@ -13,7 +13,7 @@ dependencies = [
13
13
 
14
14
  [[package]]
15
15
  name = "Rust_covpyo3"
16
- version = "0.2.4"
16
+ version = "0.3.0"
17
17
  dependencies = [
18
18
  "CigarParser",
19
19
  "openssl",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "Rust_covpyo3"
3
- version = "0.2.4"
3
+ version = "0.3.0"
4
4
  edition = "2021"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Rust_covpyo3
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Science/Research
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -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