Thomas 1 year ago
parent
commit
b9d4d901ed
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/lib.rs

+ 12 - 0
src/lib.rs

@@ -101,6 +101,18 @@ impl Blast {
         }
     }
 
+    pub fn to_bed(&self) -> anyhow::Result<String> {
+        if let Some(results) = &self.results {
+            let mut lines = Vec::new();
+            for result in results.iter() {
+                lines.push(result.to_bed());
+            }
+            Ok(lines.join("\n"))
+        } else {
+            Err(anyhow!("No results"))
+        }
+    }
+
     pub fn save_file(self, file_path: &str) -> anyhow::Result<()> {
         let data = self.to_json()?;
         let mut file = File::create(file_path)?;