Thomas 2 年之前
父節點
當前提交
df87951fff
共有 2 個文件被更改,包括 16 次插入18 次删除
  1. 1 2
      Cargo.toml
  2. 15 16
      src/main.rs

+ 1 - 2
Cargo.toml

@@ -6,5 +6,4 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-duct = "0.13.5"
-faimm = "0.3.0"
+duct = "0.13.5"

+ 15 - 16
src/main.rs

@@ -1,5 +1,4 @@
 use duct::cmd;
-use faimm::IndexedFasta;
 
 fn main() {
     let ref_path = "/home/thomas/NGS/ref/hg19.fa";
@@ -291,19 +290,19 @@ pub fn format_seq(name: &str, sequence: &str, line_size: usize) -> String {
     format!(">{name}\n{res}")
 }
 
-pub fn compose_seq(ref_path: &str, ranges: Vec<(String, i32, i32)>) -> String {
-    let fa = IndexedFasta::from_file(ref_path).expect("Error opening fa");
+// pub fn compose_seq(ref_path: &str, ranges: Vec<(String, i32, i32)>) -> String {
+//     let fa = IndexedFasta::from_file(ref_path).expect("Error opening fa");
 
-    let mut sequence = String::new();
-    for (contig, start, stop) in ranges {
-        let chr_index = fa.fai().tid(&contig).expect("Cannot find chr in index");
-        if start < stop {
-            let v = fa.view(chr_index, start as usize,stop as usize).expect("Cannot get .fa view");
-            sequence = format!("{}{}", sequence, v.to_string());
-        } else {
-            let v = fa.view(chr_index, stop as usize, start as usize).expect("Cannot get .fa view");
-            sequence = format!("{}{}", sequence, revcomp(&v.to_string()));
-        }
-    }
-    sequence
-}
+//     let mut sequence = String::new();
+//     for (contig, start, stop) in ranges {
+//         let chr_index = fa.fai().tid(&contig).expect("Cannot find chr in index");
+//         if start < stop {
+//             let v = fa.view(chr_index, start as usize,stop as usize).expect("Cannot get .fa view");
+//             sequence = format!("{}{}", sequence, v.to_string());
+//         } else {
+//             let v = fa.view(chr_index, stop as usize, start as usize).expect("Cannot get .fa view");
+//             sequence = format!("{}{}", sequence, revcomp(&v.to_string()));
+//         }
+//     }
+//     sequence
+// }