|
|
@@ -58,9 +58,12 @@ impl Blast {
|
|
|
|
|
|
let output = cmd.wait_with_output().expect("Failed to read stdout");
|
|
|
|
|
|
- self.results = Some(parse_blastn_touput(
|
|
|
- String::from_utf8_lossy(&output.stdout).to_string(),
|
|
|
- ));
|
|
|
+ self.results = Some(
|
|
|
+ parse_blastn_touput(String::from_utf8_lossy(&output.stdout).to_string())
|
|
|
+ .into_iter()
|
|
|
+ .take(self.config.max_results)
|
|
|
+ .collect::<Vec<BlastResult>>(),
|
|
|
+ );
|
|
|
|
|
|
Ok(self)
|
|
|
}
|
|
|
@@ -233,7 +236,12 @@ 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.to_formatted_string(&Locale::en), self.s_end.to_formatted_string(&Locale::en));
|
|
|
+ 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(),
|
|
|
@@ -339,13 +347,7 @@ fn evalue_to_mapq(evalue: f64) -> u32 {
|
|
|
println!("{mapq}");
|
|
|
|
|
|
// Clamp the value between 0 and 60, which is a typical range for MAPQ scores.
|
|
|
- let clamped_mapq = if mapq > 60.0 {
|
|
|
- 60.0
|
|
|
- } else if mapq < 0.0 {
|
|
|
- 0.0
|
|
|
- } else {
|
|
|
- mapq
|
|
|
- };
|
|
|
+ let clamped_mapq = mapq.clamp(0.0, 60.0);
|
|
|
|
|
|
clamped_mapq as u32
|
|
|
}
|