1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use md5;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
#[derive(Debug)]
pub struct QuerySequence {
pub hash_header: md5::Digest,
pub full_identifier: &'static str,
pub sequence: &'static str,
}
impl QuerySequence {
#[allow(dead_code)]
pub fn create(
header: &'static str,
sequence: &'static str,
) -> QuerySequence {
let sequence_hash = md5::compute(sequence);
QuerySequence {
hash_header: sequence_hash,
full_identifier: header,
sequence,
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize, clap::ValueEnum)]
#[serde(rename_all = "camelCase")]
pub enum Taxon {
Fungi,
Bacteria,
Eukaryotes,
}
impl FromStr for Taxon {
type Err = ();
fn from_str(input: &str) -> Result<Taxon, Self::Err> {
match input {
"f" | "Fungi" | "fungi" => Ok(Taxon::Fungi),
"b" | "Bacteria" | "bacteria" => Ok(Taxon::Bacteria),
_ => Err(()),
}
}
}
#[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BlastBuilder {
pub subject_reads: String,
pub taxon: Taxon,
pub out_format: &'static str,
pub max_target_seqs: &'static str,
pub perc_identity: &'static str,
pub query_cov: &'static str,
pub strand: &'static str,
pub e_value: &'static str,
pub min_consensus: &'static str,
}
impl BlastBuilder {
pub fn create(subject_reads: &str, taxon: Taxon) -> Self {
BlastBuilder {
subject_reads: subject_reads.to_string(),
taxon,
out_format: "6",
max_target_seqs: "100",
perc_identity: "0.8",
query_cov: "0.8",
strand: "both",
e_value: "0.001",
min_consensus: "0.51",
}
}
}