Your Name 1 year ago
parent
commit
0baaa7c310
4 changed files with 47 additions and 7 deletions
  1. 30 4
      Cargo.lock
  2. 2 0
      Cargo.toml
  3. 13 2
      src/lib.rs
  4. 2 1
      src/progs/cramino.rs

+ 30 - 4
Cargo.lock

@@ -260,6 +260,12 @@ dependencies = [
  "windows-sys 0.52.0",
 ]
 
+[[package]]
+name = "itoa"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
+
 [[package]]
 name = "lazy_static"
 version = "1.4.0"
@@ -349,6 +355,8 @@ dependencies = [
  "indicatif",
  "log",
  "regex",
+ "serde",
+ "serde_json",
  "tokio",
  "uuid",
 ]
@@ -456,6 +464,12 @@ version = "0.1.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
 
+[[package]]
+name = "ryu"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
+
 [[package]]
 name = "scopeguard"
 version = "1.2.0"
@@ -464,24 +478,36 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
 
 [[package]]
 name = "serde"
-version = "1.0.202"
+version = "1.0.210"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
+checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.202"
+version = "1.0.210"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
+checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
 dependencies = [
  "proc-macro2",
  "quote",
  "syn",
 ]
 
+[[package]]
+name = "serde_json"
+version = "1.0.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
+dependencies = [
+ "itoa",
+ "memchr",
+ "ryu",
+ "serde",
+]
+
 [[package]]
 name = "signal-hook-registry"
 version = "1.4.2"

+ 2 - 0
Cargo.toml

@@ -12,3 +12,5 @@ indicatif = "0.17.8"
 tokio = { version = "1", features = ["full"] }
 futures = "0.3.30"
 regex = "1.10.4"
+serde_json = "1.0.128"
+serde = { version = "1.0.210", features = ["derive"] }

+ 13 - 2
src/lib.rs

@@ -6,6 +6,8 @@ pub mod utils;
 #[cfg(test)]
 mod tests {
 
+    use std::fs::File;
+
     use crate::utils::Run;
     use anyhow::anyhow;
     use env_logger::Env;
@@ -23,12 +25,21 @@ mod tests {
     #[test]
     fn it_works() -> anyhow::Result<()> {
         init();
+        let id = "BECERRA";
+        let time_point = "diag";
+
+        let result_dir = "/data/longreads_basic_pipe";
         let mut cramino = Cramino::default()
             .with_threads(150)
-            .with_result_path("/data/longreads_basic_pipe/CAMARA/diag/CAMARA_diag_hs1_cramino.txt")
-            .with_bam("/data/longreads_basic_pipe/CAMARA/diag/CAMARA_diag_hs1.bam")?;
+            .with_result_path(&format!("{result_dir}/{id}/{time_point}/{id}_{time_point}_hs1_cramino.txt"))
+            .with_bam(&format!("{result_dir}/{id}/{time_point}/{id}_{time_point}_hs1.bam"))?;
         cramino.run()?;
         println!("{cramino:?}");
+        // if let Some(results) = cramino.results {
+        //     let json = serde_json::to_string(&results)?;
+        //     let mut file = File::create(filename)?;
+        //     file.write_all(json.as_bytes())?;
+        // }
         assert!(cramino.results.unwrap().is_woman()?);
         Ok(())
     }

+ 2 - 1
src/progs/cramino.rs

@@ -8,6 +8,7 @@ use std::{
 
 use anyhow::anyhow;
 use log::info;
+use serde::{Deserialize, Serialize};
 use uuid::Uuid;
 
 use crate::utils::{exec_bin_to_file, RunBin};
@@ -151,7 +152,7 @@ impl RunBin for Cramino {
     }
 }
 
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Deserialize, Serialize)]
 pub struct CraminoRes {
     pub file_name: String,
     pub number_of_reads: u64,