Browse Source

formatted num

Thomas 1 year ago
parent
commit
7047167854
3 changed files with 4 additions and 1 deletions
  1. 1 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 2 1
      src/lib.rs

+ 1 - 0
Cargo.lock

@@ -1914,6 +1914,7 @@ dependencies = [
  "env_logger 0.10.2",
  "log",
  "minimap2",
+ "num-format",
  "serde",
  "serde_json",
  "thiserror",

+ 1 - 0
Cargo.toml

@@ -13,3 +13,4 @@ serde = { version = "1.0.204", features = ["derive"] }
 confy = "0.6.1"
 minimap2 = { git = "https://github.com/jguhlin/minimap2-rs" }
 desc_seq_lib = { git = "https://git.t0m4.fr/Thomas/desc_seq_lib.git" }
+num-format = "0.4.4"

+ 2 - 1
src/lib.rs

@@ -215,6 +215,7 @@ impl TryFrom<String> for BlastResult {
         })
     }
 }
+use num_format::{Locale, ToFormattedString};
 
 impl BlastResult {
     pub fn swap_query_subject(&self) -> BlastResult {
@@ -232,7 +233,7 @@ impl BlastResult {
 
     pub fn to_bed(&self) -> String {
         let strand = if self.s_start <= self.s_end { "+" } else { "-" };
-        let info = format!("{}:{}-{}", self.subject_id, self.s_start, self.s_end);
+        let info = format!("{}:{}-{}", self.subject_id, self.s_start.to_formatted_string(&Locale::en), self.s_end.to_formatted_string(&Locale::en));
         [
             self.query_id.to_string(),
             self.q_start.to_string(),