Thomas 3 лет назад
Родитель
Сommit
abeeb78e84
1 измененных файлов с 15 добавлено и 1 удалено
  1. 15 1
      src/lib.rs

+ 15 - 1
src/lib.rs

@@ -648,8 +648,22 @@ impl NeoContig {
         }
         res
     }
+    
     pub fn get_fasta(&self) -> String {
-        String::new()
+        let res = String::new();
+        let fa_lines = self.contig.chars()
+        .collect::<Vec<char>>()
+        .chunks(60)
+        .map(|c| c.iter().collect::<String>())
+        .collect::<Vec<String>>()
+        .join("\n");
+
+        let mut name = String::new();
+        for s in self.alignments {
+            // contig:[pos-pos]
+            name = format!("{}{}:{}-{}_", name, s.ref_name, s.ref_range.0, s.ref_range.0 - 1);
+        }
+        format!(">{}\n{}", name, fa_lines)
     }
 }
 pub struct Fasta {