-
Notifications
You must be signed in to change notification settings - Fork 58
/
params.rs
131 lines (108 loc) · 5.11 KB
/
params.rs
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
use clap::{Parser, ValueEnum};
use optfield::optfield;
use serde::{Deserialize, Serialize};
#[derive(ValueEnum, Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum GapAlignmentSide {
Left,
Right,
}
// NOTE: The `optfield` attribute creates a struct that have the same fields, but which are wrapped into `Option`,
// as well as adds a method `.merge_opt(&opt)` to the original struct, which merges values from the optional counterpart
// into self (mutably).
#[allow(clippy::struct_excessive_bools)]
#[optfield(pub AlignPairwiseParamsOptional, attrs, doc, field_attrs, field_doc, merge_fn = pub)]
#[derive(Parser, Debug, Clone, Serialize, Deserialize)]
pub struct AlignPairwiseParams {
/// Minimum length of nucleotide sequence to consider for alignment.
///
/// If a sequence is shorter than that, alignment will not be attempted and a warning will be emitted. When adjusting this parameter, note that alignment of short sequences can be unreliable.
#[clap(long)]
pub min_length: usize,
/// Penalty for extending a gap in alignment. If zero, all gaps regardless of length incur the same penalty.
#[clap(long)]
pub penalty_gap_extend: i32,
/// Penalty for opening of a gap in alignment. A higher penalty results in fewer gaps and more mismatches. Should be less than `--penalty-gap-open-in-frame` to avoid gaps in genes.
#[clap(long)]
pub penalty_gap_open: i32,
/// As `--penalty-gap-open`, but for opening gaps at the beginning of a codon. Should be greater than `--penalty-gap-open` and less than `--penalty-gap-open-out-of-frame`, to avoid gaps in genes, but favor gaps that align with codons.
#[clap(long)]
pub penalty_gap_open_in_frame: i32,
/// As `--penalty-gap-open`, but for opening gaps in the body of a codon. Should be greater than `--penalty-gap-open-in-frame` to favor gaps that align with codons.
#[clap(long)]
pub penalty_gap_open_out_of_frame: i32,
/// Penalty for aligned nucleotides or amino acids that differ in state during alignment. Note that this is redundantly parameterized with `--score-match`
#[clap(long)]
pub penalty_mismatch: i32,
/// Score for matching states in nucleotide or amino acid alignments.
#[clap(long)]
pub score_match: i32,
/// Maximum length of insertions or deletions allowed to proceed with alignment. Alignments with long indels are slow to compute and require substantial memory in the current implementation. Alignment of sequences with indels longer that this value, will not be attempted and a warning will be emitted.
#[clap(long)]
pub max_indel: usize,
/// k-mer length to determine approximate alignments between query and reference and determine the bandwidth of the banded alignment.
#[clap(long)]
pub seed_length: usize,
/// Maximum number of mismatching nucleotides allowed for a seed to be considered a match.
#[clap(long)]
pub mismatches_allowed: usize,
/// Minimum number of seeds to search for during nucleotide alignment. Relevant for short sequences. In long sequences, the number of seeds is determined by `--seed-spacing`.
#[clap(long)]
pub min_seeds: i32,
/// Minimum seed mathing rate (a ratio of seed matches to total number of attempted seeds)
#[clap(long)]
pub min_match_rate: f64,
/// Spacing between seeds during nucleotide alignment.
#[clap(long)]
pub seed_spacing: i32,
/// Retry seed matching step with a reverse complement if the first attempt failed
#[clap(long)]
#[clap(num_args=0..=1, default_missing_value = "true")]
pub retry_reverse_complement: bool,
/// If this flag is present, the amino acid sequences will be truncated at the first stop codon, if mutations or sequencing errors cause premature stop codons to be present. No amino acid mutations in the truncated region will be recorded.
#[clap(long)]
#[clap(num_args=0..=1, default_missing_value = "true")]
pub no_translate_past_stop: bool,
// Internal alignment parameter
#[clap(skip)]
pub left_terminal_gaps_free: bool,
// Internal alignment parameter
#[clap(skip)]
pub right_terminal_gaps_free: bool,
/// Excess bandwidth for internal stripes.
#[clap(long)]
pub excess_bandwidth: i32,
/// Excess bandwidth for terminal stripes.
#[clap(long)]
pub terminal_bandwidth: i32,
/// Whether to align gaps on the left or right side if equally parsimonious.
/// Left aligning gaps is the convention, right align is Nextclade's historic default
#[clap(long, value_enum)]
pub gap_alignment_side: GapAlignmentSide,
}
impl Default for AlignPairwiseParams {
fn default() -> Self {
Self {
min_length: 100,
penalty_gap_extend: 0,
penalty_gap_open: 6,
penalty_gap_open_in_frame: 7,
penalty_gap_open_out_of_frame: 8,
penalty_mismatch: 1,
score_match: 3,
max_indel: 400,
seed_length: 21,
min_seeds: 10,
min_match_rate: 0.3,
seed_spacing: 100,
mismatches_allowed: 3,
retry_reverse_complement: false,
no_translate_past_stop: false,
left_terminal_gaps_free: true,
right_terminal_gaps_free: true,
excess_bandwidth: 9,
terminal_bandwidth: 50,
gap_alignment_side: GapAlignmentSide::Right,
}
}
}