use generic_a_star::cost::AStarCost;
use lib_tsalign::config::TemplateSwitchConfig;
use lib_tsalign::costs::U64Cost;
use lib_tsalign::costs::cost_function::CostFunction;
use lib_tsalign::costs::gap_affine::GapAffineAlignmentCostTable;
use compact_genome::implementation::alphabets::dna_alphabet_or_n::DnaAlphabetOrN;
use crate::common::aligner::chain;
use crate::common::aligner::cli::{CliAlignmentArgs, MLSSelector, URMSelector};
use crate::common::cluster_settings::{ClusterStrategy, ClusteringSettings};
type Costs = TemplateSwitchConfig<DnaAlphabetOrN, U64Cost>;
type EditCosts = GapAffineAlignmentCostTable<DnaAlphabetOrN, U64Cost>;
fn infinite() -> U64Cost {
U64Cost::from_primitive(u64::MAX)
}
pub fn warn_about_alignment_settings(args: &CliAlignmentArgs, costs: &Costs) {
for message in alignment_setting_warnings(args, costs) {
tracing::warn!("{message}");
}
}
pub fn warn_about_clustering_settings(settings: &ClusteringSettings) {
for message in clustering_setting_warnings(settings) {
tracing::warn!("{message}");
}
}
#[derive(Clone, Copy, PartialEq, Eq)]
enum Aligner {
AStar,
Fpa,
Chain,
}
impl Aligner {
const fn of(args: &CliAlignmentArgs) -> Self {
if args.use_fpa {
Self::Fpa
} else if args.use_chain {
Self::Chain
} else {
Self::AStar
}
}
const fn finds(self, inter_strand: bool, forward: bool) -> bool {
match self {
Self::AStar => true,
Self::Fpa => inter_strand,
Self::Chain => !forward,
}
}
}
fn enabled_geometries(costs: &Costs) -> impl Iterator<Item = (bool, bool)> {
let base = &costs.base_cost;
[
(false, true, base.rrf),
(false, false, base.rrr),
(false, true, base.qqf),
(false, false, base.qqr),
(true, true, base.rqf),
(true, false, base.rqr),
(true, true, base.qrf),
(true, false, base.qrr),
]
.into_iter()
.filter(|(.., cost)| *cost < infinite())
.map(|(inter_strand, forward, _)| (inter_strand, forward))
}
fn finds_some(aligner: Aligner, costs: &Costs, inter_strand: bool) -> bool {
enabled_geometries(costs)
.any(|(inter, forward)| inter == inter_strand && aligner.finds(inter, forward))
}
fn ignores_some_geometry(aligner: Aligner, costs: &Costs) -> bool {
enabled_geometries(costs).any(|(inter, forward)| !aligner.finds(inter, forward))
}
fn render_bound(bound: Option<isize>) -> String {
bound.map_or_else(|| "unbounded".to_owned(), |bound| bound.to_string())
}
fn offset_bounds(costs: &CostFunction<isize, U64Cost>) -> Option<(Option<isize>, Option<isize>)> {
let lower = costs.minimum_finite_input()?;
Some((
(lower != isize::MIN).then_some(lower),
costs.maximum_finite_input(),
))
}
fn is_free<Input: Clone>(costs: &CostFunction<Input, U64Cost>) -> bool {
let points: Vec<(Input, U64Cost)> = costs.clone().into();
points
.iter()
.all(|(_, cost)| *cost == U64Cost::from_primitive(0))
}
fn charges_gap_open(costs: &EditCosts) -> bool {
costs.max_gap_open_cost() != U64Cost::from_primitive(0)
}
fn has_flanks(costs: &Costs) -> bool {
costs.left_flank_length != 0 || costs.right_flank_length != 0
}
pub fn alignment_setting_warnings(args: &CliAlignmentArgs, costs: &Costs) -> Vec<String> {
let mut warnings = Vec::new();
let aligner = Aligner::of(args);
if !args.no_ts {
let reason = no_template_switch_reason(aligner, costs);
if let Some(reason) = reason {
warnings.push(format!(
"No template switch can ever be found with these costs, because {reason}. Pass --no-ts to skip the template switch alignment entirely."
));
}
warnings.extend(reachability_warnings(args, aligner, costs));
if aligner == Aligner::AStar
&& reason.is_none()
&& matches!(args.min_length_strategy, MLSSelector::PreprocessFilter)
&& enabled_geometries(costs).any(|(_, forward)| forward)
{
warnings.push(
"Forward template switches are enabled, but the minimum length strategy `preprocess-filter` only prunes reverse template switches. Consider --min-length-strategy lookahead."
.to_owned(),
);
}
}
match aligner {
Aligner::AStar => {
if has_flanks(costs) {
warnings.push(format!(
"The cost model sets left_flank_length = {} and right_flank_length = {}. Flanks are not supported and additionally disable extending the alignment beyond its range; set both to 0.",
costs.left_flank_length, costs.right_flank_length,
));
}
}
Aligner::Fpa => warnings.extend(fpa_warnings(costs, !args.no_ts)),
Aligner::Chain => warnings.extend(chain_warnings(costs, !args.no_ts)),
}
warnings.extend(ineffective_ts_flag_warnings(args));
warnings
}
fn no_template_switch_reason(aligner: Aligner, costs: &Costs) -> Option<&'static str> {
let inter = finds_some(aligner, costs, true);
let intra = finds_some(aligner, costs, false);
let jumps = |table: &CostFunction<isize, U64Cost>| table.minimum_finite_input().is_some();
match aligner {
Aligner::AStar if costs.length_costs.minimum_finite_input().is_none() => {
Some("the `Length` table is infinite everywhere")
}
Aligner::AStar if !inter && !intra => Some("all eight base costs are infinite"),
Aligner::AStar
if !((inter && jumps(&costs.rq_qr_offset_costs))
|| (intra && jumps(&costs.rr_qq_offset_costs))) =>
{
Some("every offset table for a geometry with a finite base cost is infinite everywhere")
}
Aligner::Fpa if !inter => Some(
"the four-point aligner only finds inter-strand template switches, and their base costs `rqf`/`rqr`/`qrf`/`qrr` are all infinite",
),
Aligner::Fpa if !jumps(&costs.rq_qr_offset_costs) => {
Some("the `RQQROffset` table is infinite everywhere")
}
Aligner::Chain if !inter && !intra => Some(
"the chaining aligner only finds reverse template switches, and their base costs `rrr`/`rqr`/`qrr`/`qqr` are all infinite",
),
_ => None,
}
}
fn ineffective_ts_flag_warnings(args: &CliAlignmentArgs) -> Vec<String> {
let mode = if args.no_ts {
"--no-ts disables template switch alignment"
} else if args.use_fpa {
"--fpa selects the four-point aligner"
} else if args.use_chain {
"--chain selects the chaining aligner"
} else {
return Vec::new();
};
let flags: Vec<_> = [
(
"--min-length-strategy",
args.min_length_strategy != MLSSelector::default(),
),
(
"--uncertainty-range-mode",
args.uncertainty_range_mode != URMSelector::default(),
),
("--allow-mixed-descendants", args.allow_mixed_descendants),
]
.into_iter()
.filter_map(|(flag, given)| given.then_some(flag))
.collect();
if flags.is_empty() {
Vec::new()
} else {
vec![format!("{mode}, so {} has no effect.", flags.join(", "),)]
}
}
fn reachability_warnings(args: &CliAlignmentArgs, aligner: Aligner, costs: &Costs) -> Vec<String> {
let mut warnings = Vec::new();
let padding = isize::try_from(args.padding).unwrap_or(isize::MAX);
let tables = [
("RQQROffset", &costs.rq_qr_offset_costs, true),
("RRQQOffset", &costs.rr_qq_offset_costs, false),
];
for (name, table, inter_strand) in tables {
if aligner == Aligner::Chain || !finds_some(aligner, costs, inter_strand) {
continue;
}
let Some((lower, upper)) = offset_bounds(table) else {
continue;
};
if lower.is_none_or(|lower| lower < -padding) || upper.is_none_or(|upper| upper > padding) {
warnings.push(format!(
"The `{name}` table prices template switch jumps in [{}, {}], but --padding {} limits reachable jumps to ±{}. Jumps beyond that can never be found; raise --padding or narrow the table.",
render_bound(lower),
render_bound(upper),
args.padding,
args.padding,
));
}
}
let max_length = match aligner {
Aligner::AStar => costs.length_costs.maximum_finite_input(),
Aligner::Chain => chain::length_as_hard_range(&costs.length_costs)
.ok()
.and_then(|lengths| lengths.maximum_finite_input()),
Aligner::Fpa => None,
};
if let Some(max_length) = max_length
&& max_length > args.padding.saturating_mul(2)
{
warnings.push(format!(
"The `Length` table permits template switches of up to {max_length} bases, but with --padding {} only a little more than {} bases of template are available. Lower the longest permitted length, or raise --padding.",
args.padding,
args.padding.saturating_mul(2),
));
}
warnings
}
fn fpa_warnings(costs: &Costs, template_switches: bool) -> Option<String> {
let mut ignored = Vec::new();
if charges_gap_open(&costs.primary_edit_costs)
|| (template_switches
&& (charges_gap_open(&costs.secondary_forward_edit_costs)
|| charges_gap_open(&costs.secondary_reverse_edit_costs)))
{
ignored.push("the gap open costs (the four-point aligner is not gap-affine)");
}
if template_switches {
if !is_free(&costs.length_costs) {
ignored.push("the `Length` table");
}
if !is_free(&costs.length_difference_costs) {
ignored.push("the `LengthDifference` table");
}
if !is_free(&costs.forward_anti_descendant_gap_costs) {
ignored.push("the `ForwardAntiDescendantGap` table");
}
if !is_free(&costs.reverse_anti_descendant_gap_costs) {
ignored.push("the `ReverseAntiDescendantGap` table");
}
if ignores_some_geometry(Aligner::Fpa, costs) {
ignored.push(
"the intra-strand base costs `rrf`/`rrr`/`qqf`/`qqr` and the `RRQQOffset` table (the four-point aligner only finds inter-strand template switches)",
);
}
if has_flanks(costs) {
ignored.push("the flanks");
}
}
(!ignored.is_empty()).then(|| {
format!(
"--fpa ignores parts of the cost model that are configured here: {}.",
ignored.join(", "),
)
})
}
fn chain_warnings(costs: &Costs, template_switches: bool) -> Option<String> {
if !template_switches {
return None;
}
let mut ignored = Vec::new();
if !is_free(&costs.length_difference_costs) {
ignored.push("the `LengthDifference` table".to_owned());
}
if !is_free(&costs.forward_anti_descendant_gap_costs) {
ignored.push("the `ForwardAntiDescendantGap` table".to_owned());
}
let unenforced: Vec<_> = [
(
"`RQQROffset`",
is_free(&costs.rq_qr_offset_costs) || !finds_some(Aligner::Chain, costs, true),
),
(
"`RRQQOffset`",
is_free(&costs.rr_qq_offset_costs) || !finds_some(Aligner::Chain, costs, false),
),
(
"`ReverseAntiDescendantGap`",
is_free(&costs.reverse_anti_descendant_gap_costs),
),
]
.into_iter()
.filter_map(|(name, irrelevant)| (!irrelevant).then_some(name))
.collect();
if !unenforced.is_empty() {
ignored.push(format!(
"the allowed ranges in {} (the chaining aligner does not enforce them, so only --padding bounds the jumps)",
unenforced.join(", "),
));
}
if ignores_some_geometry(Aligner::Chain, costs) {
ignored.push(
"the forward base costs `rrf`/`rqf`/`qrf`/`qqf` (the chaining aligner only finds reverse template switches)"
.to_owned(),
);
}
let zero = U64Cost::from_primitive(0);
let points: Vec<(usize, U64Cost)> = costs.length_costs.clone().into();
if points
.iter()
.any(|(_, cost)| *cost != zero && *cost != infinite())
{
ignored.push(
"the `Length` entries with a finite non-zero cost (those lengths are forbidden rather than penalised)"
.to_owned(),
);
}
(!ignored.is_empty()).then(|| {
format!(
"--chain ignores parts of the cost model that are configured here: {}.",
ignored.join(", "),
)
})
}
pub fn clustering_setting_warnings(settings: &ClusteringSettings) -> Vec<String> {
let mut warnings = Vec::new();
#[expect(clippy::cast_precision_loss)]
let minimum_reachable_density = 1.0 / (settings.max_gap as f64 + 1.0);
if settings.min_density != 0.0 {
warnings.push("--cluster-min-density is not recommended to be used. See https://version.helsinki.fi/kraujasp/twitcher/-/work_items/76 for more info.".to_string());
if settings.min_density <= minimum_reachable_density {
warnings.push(format!(
"--cluster-min-density {} can never reject a cluster, because --cluster-max-gap {} already forces a density above {minimum_reachable_density:.4}.",
settings.min_density, settings.max_gap,
));
} else if settings.strategy == ClusterStrategy::Legacy && settings.min_density > 1.0 {
warnings.push(format!(
"--cluster-min-density {} exceeds the density of a run of single nucleotide variants under --cluster-strategy legacy, so almost nothing will be clustered.",
settings.min_density,
));
}
}
if settings.strategy == ClusterStrategy::Legacy && settings.min_records == Some(1) {
warnings.push(
"--cluster-min-records 1 under --cluster-strategy legacy turns every single variant into a cluster to be realigned, which is slow and mostly produces noise."
.to_owned(),
);
}
warnings
}
#[cfg(test)]
mod tests {
use super::*;
const DEFAULT_TSA: &str = include_str!("../../default_costs.tsa");
fn costs_from(tsa: &str) -> Costs {
TemplateSwitchConfig::read_plain(tsa.as_bytes()).unwrap()
}
fn default_costs() -> Costs {
costs_from(DEFAULT_TSA)
}
fn costs_with(from: &str, to: &str) -> Costs {
assert!(
DEFAULT_TSA.contains(from),
"cost file does not contain {from:?}"
);
costs_from(&DEFAULT_TSA.replace(from, to))
}
fn assert_mentions(warnings: &[String], needle: &str) {
assert!(
warnings.iter().any(|w| w.contains(needle)),
"expected a warning mentioning {needle:?}, got {warnings:#?}"
);
}
#[test]
fn default_settings_and_default_costs_are_silent() {
let warnings = alignment_setting_warnings(&CliAlignmentArgs::default(), &default_costs());
assert!(warnings.is_empty(), "{warnings:#?}");
assert!(clustering_setting_warnings(&ClusteringSettings::default()).is_empty());
}
#[test]
fn offset_window_wider_than_padding_warns() {
let args = CliAlignmentArgs {
padding: 30,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &default_costs()),
"`RQQROffset` table prices template switch jumps in [-200, 200]",
);
}
#[test]
fn unbounded_offset_window_warns() {
let costs = costs_with(
"RQQROffset\n -inf -200 201\n inf 0 inf",
"RQQROffset\n -inf\n 0",
);
assert_mentions(
&alignment_setting_warnings(&CliAlignmentArgs::default(), &costs),
"jumps in [unbounded, unbounded]",
);
}
#[test]
fn unreachable_offset_table_is_not_warned_about() {
let args = CliAlignmentArgs {
padding: 30,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &default_costs());
assert!(
!warnings.iter().any(|w| w.contains("RRQQOffset")),
"{warnings:#?}"
);
}
#[test]
fn inner_length_beyond_the_available_template_warns() {
let args = CliAlignmentArgs {
padding: 30,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &default_costs()),
"permits template switches of up to 400 bases",
);
}
#[test]
fn unbounded_inner_length_is_not_warned_about() {
let costs = costs_with(
"Length\n 0 5 6 7 8 401\n inf 15 10 5 0 inf",
"Length\n 0 5\n inf 0",
);
let warnings = alignment_setting_warnings(&CliAlignmentArgs::default(), &costs);
assert!(
!warnings
.iter()
.any(|w| w.contains("permits template switches")),
"{warnings:#?}"
);
}
#[test]
fn cost_model_without_any_usable_geometry_warns() {
let costs = costs_with(
"rqr_cost = 2\nqrr_cost = 2",
"rqr_cost = inf\nqrr_cost = inf",
);
assert_mentions(
&alignment_setting_warnings(&CliAlignmentArgs::default(), &costs),
"all eight base costs are infinite",
);
}
#[test]
fn cost_model_without_any_finite_length_warns() {
let costs = costs_with(
"Length\n 0 5 6 7 8 401\n inf 15 10 5 0 inf",
"Length\n 0\n inf",
);
assert_mentions(
&alignment_setting_warnings(&CliAlignmentArgs::default(), &costs),
"the `Length` table is infinite everywhere",
);
}
#[test]
fn no_template_switch_possible_is_not_warned_about_with_no_ts() {
let costs = costs_with(
"rqr_cost = 2\nqrr_cost = 2",
"rqr_cost = inf\nqrr_cost = inf",
);
let args = CliAlignmentArgs {
no_ts: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &costs);
assert!(
!warnings.iter().any(|w| w.contains("No template switch")),
"{warnings:#?}"
);
}
#[test]
fn forward_geometry_with_preprocess_filter_warns() {
let costs = costs_with("rqf_cost = inf", "rqf_cost = 8");
assert_mentions(
&alignment_setting_warnings(&CliAlignmentArgs::default(), &costs),
"only prunes reverse template switches",
);
}
#[test]
fn no_ts_with_non_default_ts_flags_warns() {
let args = CliAlignmentArgs {
no_ts: true,
uncertainty_range_mode: URMSelector::None,
allow_mixed_descendants: true,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &default_costs()),
"--uncertainty-range-mode, --allow-mixed-descendants has no effect",
);
}
#[test]
fn fpa_with_non_default_ts_flags_warns() {
let args = CliAlignmentArgs {
use_fpa: true,
min_length_strategy: MLSSelector::Lookahead,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &default_costs()),
"--min-length-strategy has no effect",
);
}
#[test]
fn no_ts_with_default_ts_flags_is_silent() {
let args = CliAlignmentArgs {
no_ts: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &default_costs());
assert!(
!warnings.iter().any(|w| w.contains("has no effect")),
"{warnings:#?}"
);
}
#[test]
fn forward_geometry_with_lookahead_is_silent() {
let costs = costs_with("rqf_cost = inf", "rqf_cost = 8");
let args = CliAlignmentArgs {
min_length_strategy: MLSSelector::Lookahead,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &costs);
assert!(
!warnings.iter().any(|w| w.contains("prunes reverse")),
"{warnings:#?}"
);
}
#[test]
fn fpa_reports_the_cost_tables_it_ignores() {
let args = CliAlignmentArgs {
use_fpa: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &default_costs());
assert_mentions(&warnings, "--fpa ignores parts of the cost model");
assert_mentions(&warnings, "gap open costs");
assert_mentions(&warnings, "the `Length` table");
assert!(
!warnings
.iter()
.any(|w| w.contains("`ReverseAntiDescendantGap`")),
"{warnings:#?}"
);
}
#[test]
fn fpa_reports_unsupported_intra_strand_geometries() {
let costs = costs_with("rrr_cost = inf", "rrr_cost = 3");
let args = CliAlignmentArgs {
use_fpa: true,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &costs),
"only finds inter-strand template switches",
);
}
#[test]
fn chain_reports_the_cost_tables_it_ignores() {
let args = CliAlignmentArgs {
use_chain: true,
padding: 30,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &default_costs());
assert_mentions(&warnings, "--chain ignores parts of the cost model");
assert_mentions(&warnings, "`LengthDifference`");
assert_mentions(&warnings, "allowed ranges in `RQQROffset` (");
assert_mentions(&warnings, "those lengths are forbidden");
for absent in [
"`RRQQOffset`",
"`ReverseAntiDescendantGap`",
"forward base costs",
"prices template switch jumps",
] {
assert!(
!warnings.iter().any(|w| w.contains(absent)),
"{warnings:#?}"
);
}
}
#[test]
fn chain_reports_forward_base_costs() {
let costs = costs_with("rqf_cost = inf", "rqf_cost = 8");
let args = CliAlignmentArgs {
use_chain: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &costs);
assert_mentions(&warnings, "only finds reverse template switches");
assert!(
!warnings.iter().any(|w| w.contains("only prunes reverse")),
"{warnings:#?}"
);
}
#[test]
fn chain_with_non_default_ts_flags_warns() {
let args = CliAlignmentArgs {
use_chain: true,
allow_mixed_descendants: true,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &default_costs()),
"--chain selects the chaining aligner, so --allow-mixed-descendants has no effect",
);
}
#[test]
fn chain_reports_the_unenforced_anti_descendant_gap_range() {
let costs = costs_with(
"ReverseAntiDescendantGap\n -inf\n 0",
"ReverseAntiDescendantGap\n -inf -50 51\n inf 0 inf",
);
let args = CliAlignmentArgs {
use_chain: true,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &costs),
"allowed ranges in `RQQROffset`, `ReverseAntiDescendantGap` (",
);
}
#[test]
fn fpa_does_not_judge_the_length_table() {
let costs = costs_with(
"Length\n 0 5 6 7 8 401\n inf 15 10 5 0 inf",
"Length\n 0\n inf",
);
let args = CliAlignmentArgs {
use_fpa: true,
padding: 30,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &costs);
assert!(
!warnings.iter().any(
|w| w.contains("No template switch") || w.contains("permits template switches")
),
"{warnings:#?}"
);
}
#[test]
fn fpa_without_inter_strand_geometry_finds_nothing() {
let costs = costs_with(
"rrr_cost = inf\nrqr_cost = 2\nqrr_cost = 2",
"rrr_cost = 3\nrqr_cost = inf\nqrr_cost = inf",
);
let args = CliAlignmentArgs {
use_fpa: true,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &costs),
"No template switch can ever be found with these costs, because the four-point aligner only finds inter-strand",
);
let warnings = alignment_setting_warnings(&CliAlignmentArgs::default(), &costs);
assert!(
!warnings.iter().any(|w| w.contains("No template switch")),
"{warnings:#?}"
);
}
#[test]
fn chain_without_reverse_geometry_finds_nothing() {
let costs = costs_with(
"rqf_cost = inf\nqrf_cost = inf\nqqf_cost = inf\nrrr_cost = inf\nrqr_cost = 2\nqrr_cost = 2",
"rqf_cost = 8\nqrf_cost = inf\nqqf_cost = inf\nrrr_cost = inf\nrqr_cost = inf\nqrr_cost = inf",
);
let args = CliAlignmentArgs {
use_chain: true,
..Default::default()
};
assert_mentions(
&alignment_setting_warnings(&args, &costs),
"because the chaining aligner only finds reverse template switches",
);
}
#[test]
fn no_ts_reports_only_ignored_edit_costs() {
let fpa = CliAlignmentArgs {
use_fpa: true,
no_ts: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&fpa, &default_costs());
assert_mentions(&warnings, "gap open costs");
assert!(
!warnings.iter().any(|w| w.contains("`Length`")),
"{warnings:#?}"
);
let chain = CliAlignmentArgs {
use_chain: true,
no_ts: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&chain, &default_costs());
assert!(warnings.is_empty(), "{warnings:#?}");
}
#[test]
fn fpa_lists_flanks_as_ignored() {
let costs = costs_with("left_flank_length = 0", "left_flank_length = 5");
let args = CliAlignmentArgs {
use_fpa: true,
..Default::default()
};
let warnings = alignment_setting_warnings(&args, &costs);
assert_mentions(&warnings, "the flanks");
assert!(
!warnings
.iter()
.any(|w| w.contains("Flanks are not supported")),
"{warnings:#?}"
);
}
#[test]
fn nonzero_flanks_warn() {
let costs = costs_with("left_flank_length = 0", "left_flank_length = 5");
assert_mentions(
&alignment_setting_warnings(&CliAlignmentArgs::default(), &costs),
"Flanks are not supported",
);
}
#[test]
fn density_gate_that_can_never_reject_warns() {
let settings = ClusteringSettings {
min_density: 0.01,
max_gap: 20,
..Default::default()
};
assert_mentions(
&clustering_setting_warnings(&settings),
"can never reject a cluster",
);
}
#[test]
fn density_gate_above_one_warns_under_legacy() {
let settings = ClusteringSettings {
min_density: 1.5,
..Default::default()
};
assert_mentions(
&clustering_setting_warnings(&settings),
"almost nothing will be clustered",
);
}
#[test]
fn single_record_clusters_warn_under_legacy() {
let settings = ClusteringSettings {
min_records: Some(1),
..Default::default()
};
assert_mentions(
&clustering_setting_warnings(&settings),
"--cluster-min-records 1 under --cluster-strategy legacy",
);
}
#[test]
fn single_record_clusters_are_expected_under_edit_mass() {
let settings = ClusteringSettings {
strategy: ClusterStrategy::EditMass,
min_records: Some(1),
..Default::default()
};
assert!(clustering_setting_warnings(&settings).is_empty());
}
}