diff --git a/Cargo.toml b/Cargo.toml index 817964672..54c504304 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,9 +109,7 @@ trivial_numeric_casts = "warn" # Disable some of the lints enabled by default # https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html -dead_code = "allow" elided_lifetimes_in_paths = "allow" -unused_variables = "allow" # Enable lints not enabled by default # https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html @@ -210,6 +208,7 @@ pattern_type_mismatch = "allow" print_stderr = "allow" print_stdout = "allow" pub_use = "allow" +pub_with_shorthand = "allow" question_mark_used = "allow" self_named_module_files = "allow" semicolon_inside_block = "allow" diff --git a/packages/nextclade-cli/src/cli/nextclade_loop.rs b/packages/nextclade-cli/src/cli/nextclade_loop.rs index 8566a8381..1eaf4d54c 100644 --- a/packages/nextclade-cli/src/cli/nextclade_loop.rs +++ b/packages/nextclade-cli/src/cli/nextclade_loop.rs @@ -124,12 +124,10 @@ pub fn nextclade_run(run_args: NextcladeRunArgs) -> Result<(), Report> { }); } - let writer = s.spawn(move || { + s.spawn(move || { let nextclade = &nextclade; let AnalysisInitialData { - genome_size, - gene_map, clade_node_attr_key_descs, phenotype_attr_descs, aa_motif_keys, diff --git a/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs b/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs index d52976ab8..0a29cffe0 100644 --- a/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs +++ b/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs @@ -127,7 +127,7 @@ pub fn run(args: &NextcladeSortArgs, minimizer_index: &MinimizerIndexJson, verbo }); } - let writer = s.spawn(move || { + s.spawn(move || { writer_thread(args, result_receiver, verbose).unwrap(); }); }); diff --git a/packages/nextclade-cli/src/dataset/dataset_download.rs b/packages/nextclade-cli/src/dataset/dataset_download.rs index a86834c54..f4c8741e3 100644 --- a/packages/nextclade-cli/src/dataset/dataset_download.rs +++ b/packages/nextclade-cli/src/dataset/dataset_download.rs @@ -16,11 +16,9 @@ use nextclade::{make_error, make_internal_error, o}; use std::collections::BTreeMap; use std::fs::File; use std::io::{BufReader, Cursor, Read, Seek, Write}; -use std::path::{Path, PathBuf}; +use std::path::Path; use zip::ZipArchive; -const PATHOGEN_JSON: &str = "pathogen.json"; - pub fn nextclade_get_inputs( run_args: &NextcladeRunArgs, cdses: &Option>, @@ -275,14 +273,6 @@ pub fn dataset_individual_files_load( } } -#[allow(clippy::struct_field_names)] -pub struct DatasetFilePaths<'a> { - input_ref: &'a Path, - input_tree: &'a Option, - input_pathogen_json: &'a Option, - input_annotation: &'a Option, -} - pub fn read_from_path_or_url( http: &HttpClient, dataset: &Dataset, diff --git a/packages/nextclade/src/align/backtrace.rs b/packages/nextclade/src/align/backtrace.rs index 4d47849c8..a63a28610 100644 --- a/packages/nextclade/src/align/backtrace.rs +++ b/packages/nextclade/src/align/backtrace.rs @@ -1,15 +1,8 @@ -use crate::align::band_2d::{Band2d}; +use crate::align::band_2d::Band2d; use crate::align::score_matrix::{BOUNDARY, MATCH, QRY_GAP_EXTEND, QRY_GAP_MATRIX, REF_GAP_EXTEND, REF_GAP_MATRIX}; use crate::alphabet::letter::Letter; - - use serde::{Deserialize, Serialize}; - -const fn index_to_shift(si: i32, band_width: i32, mean_shift: i32) -> i32 { - si - band_width + mean_shift -} - #[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema, PartialEq, Eq)] pub struct AlignmentOutput { pub qry_seq: Vec, @@ -27,8 +20,6 @@ pub fn backtrace>( ) -> AlignmentOutput { let num_cols = scores.num_cols(); let num_rows = scores.num_rows(); - let qry_len = qry_seq.len() as i32; - let ref_len = ref_seq.len() as i32; // max length of the alignment is the sum of query and reference length let aln_capacity = scores.num_cols() + scores.num_rows(); @@ -108,7 +99,7 @@ mod tests { use crate::align::band_2d::simple_stripes; use crate::align::gap_open::{get_gap_open_close_scores_codon_aware, GapScoreMap}; use crate::align::params::AlignPairwiseParams; - + use crate::alphabet::nuc::{to_nuc_seq, Nuc}; use crate::gene::gene_map::GeneMap; use eyre::Report; diff --git a/packages/nextclade/src/align/band_2d.rs b/packages/nextclade/src/align/band_2d.rs index 35de3c1b4..f710b93f5 100644 --- a/packages/nextclade/src/align/band_2d.rs +++ b/packages/nextclade/src/align/band_2d.rs @@ -55,9 +55,7 @@ pub fn simple_stripes(mean_shift: i32, band_width: usize, ref_len: usize, qry_le pub fn full_matrix(ref_len: usize, qry_len: usize) -> Vec { let mut stripes = Vec::::with_capacity(ref_len + 1); - let ref_len_i32 = ref_len.to_i32().unwrap(); - let qry_len_i32 = qry_len.to_i32().unwrap(); - for i in 0..=ref_len_i32 { + for _ in 0..=ref_len { stripes.push(Stripe::new(0, qry_len + 1)); } stripes @@ -67,7 +65,7 @@ pub fn full_matrix(ref_len: usize, qry_len: usize) -> Vec { /// /// The underlying storage is sparse - the row storage consists of `Stripe`s, each of a given size (`stripe.length`) /// and shifted by a given amount (`stripe.begin`) relative to the left boundary of the matrix. In each row, the cells -/// which are outside of the corresponding stripe are not allocated and accessing them is illegal. +/// which are outside the corresponding stripe are not allocated and accessing them is illegal. /// /// Stripe begins must increase monotonically #[derive(Clone, PartialEq, Eq)] diff --git a/packages/nextclade/src/align/score_matrix.rs b/packages/nextclade/src/align/score_matrix.rs index e9619f199..8f1192de5 100644 --- a/packages/nextclade/src/align/score_matrix.rs +++ b/packages/nextclade/src/align/score_matrix.rs @@ -94,7 +94,6 @@ pub fn score_matrix>( let r_gap_extend: i32; let r_gap_open: i32; let q_gap_open: i32; - let tmp_match: i32; let mut tmp_score: i32; if qpos == 0 { @@ -209,7 +208,7 @@ mod tests { use super::*; use crate::align::band_2d::simple_stripes; use crate::align::gap_open::{get_gap_open_close_scores_codon_aware, GapScoreMap}; - + use crate::alphabet::nuc::{to_nuc_seq, Nuc}; use crate::gene::gene_map::GeneMap; use eyre::Report; diff --git a/packages/nextclade/src/align/seed_alignment.rs b/packages/nextclade/src/align/seed_alignment.rs index 499cd41a4..47fa5791e 100644 --- a/packages/nextclade/src/align/seed_alignment.rs +++ b/packages/nextclade/src/align/seed_alignment.rs @@ -1,34 +1,10 @@ use crate::align::band_2d::Stripe; use crate::align::seed_match::SeedMatch2; -use crate::alphabet::letter::Letter; - -use log::trace; use num_traits::abs; use num_traits::clamp; use std::cmp::max; use std::cmp::min; -/// generate a vector of query sequence positions that are followed by at least `seed_length` -/// valid characters. Positions in this vector are thus "good" positions to start a query k-mer. -fn get_map_to_good_positions>(qry_seq: &[L], seed_length: usize) -> Vec { - let qry_len = qry_seq.len(); - - let mut map_to_good_positions = Vec::::with_capacity(qry_len); - let mut distance_to_last_bad_pos: i32 = 0; - - for (i, letter) in qry_seq.iter().enumerate() { - // TODO: Exclude ambiguous letters - if letter.is_unknown() { - distance_to_last_bad_pos = 0; - } else if distance_to_last_bad_pos >= seed_length as i32 { - map_to_good_positions.push(i - seed_length); - } - distance_to_last_bad_pos += 1; - } - - map_to_good_positions -} - #[derive(Debug, Clone, Copy)] pub struct SeedMatch { pub qry_pos: usize, @@ -201,7 +177,6 @@ pub fn create_alignment_band( }); } } - // write_stripes_to_file(&stripes, "stripes.csv"); // trim stripes to reachable regions regularize_stripes(stripes, qry_len as usize) @@ -236,53 +211,58 @@ fn regularize_stripes(mut stripes: Vec, qry_len: usize) -> (Vec, (stripes, band_area) } -fn trace_stripe_stats(stripes: &[Stripe]) { - let mut stripe_lengths = Vec::new(); - for stripe in stripes { - assert!( - stripe.begin <= stripe.end, - "Stripe begin must be <= stripe end for stripe {stripe:?}", - ); - stripe_lengths.push(stripe.end - stripe.begin); +#[cfg(feature = "debug-seed-alignment")] +mod debug { + use crate::align::band_2d::Stripe; + use crate::align::seed_match::SeedMatch2; + use crate::alphabet::letter::Letter; + use log::trace; + + fn trace_stripe_stats(stripes: &[Stripe]) { + let mut stripe_lengths = Vec::new(); + for stripe in stripes { + assert!( + stripe.begin <= stripe.end, + "Stripe begin must be <= stripe end for stripe {stripe:?}", + ); + stripe_lengths.push(stripe.end - stripe.begin); + } + stripe_lengths.sort_unstable(); + let median = stripe_lengths[stripe_lengths.len() / 2]; + let mean = stripe_lengths.iter().sum::() as f32 / stripe_lengths.len() as f32; + let max = stripe_lengths[stripe_lengths.len() - 1]; + let min = stripe_lengths[0]; + trace!("Stripe width stats: min: {min}, max: {max}, mean: {mean:.1}, median: {median}",); } - stripe_lengths.sort_unstable(); - let median = stripe_lengths[stripe_lengths.len() / 2]; - let mean = stripe_lengths.iter().sum::() as f32 / stripe_lengths.len() as f32; - let max = stripe_lengths[stripe_lengths.len() - 1]; - let min = stripe_lengths[0]; - trace!("Stripe width stats: min: {min}, max: {max}, mean: {mean:.1}, median: {median}",); -} -#[cfg(feature = "debug-seed-alignment")] -fn trace_matches(matches: &[SeedMatch2]) { - for (i, seed) in matches.iter().enumerate() { - trace!( - "Match {}: ref_pos: {}, qry_offset: {}, length: {}", - i, - seed.ref_pos, - -seed.offset, - seed.length, - ); + fn trace_matches(matches: &[SeedMatch2]) { + for (i, seed) in matches.iter().enumerate() { + trace!( + "Match {}: ref_pos: {}, qry_offset: {}, length: {}", + i, + seed.ref_pos, + -seed.offset, + seed.length, + ); + } } -} -#[cfg(feature = "debug-seed-alignment")] -fn write_stripes_to_file(stripes: &[Stripe], filename: &str) { - use std::io::Write; - let mut file = std::fs::File::create(filename).unwrap(); - writeln!(file, "ref,begin,end").unwrap(); - for (i, stripe) in stripes.iter().enumerate() { - writeln!(file, "{i},{begin},{end}", begin = stripe.begin, end = stripe.end).unwrap(); + fn write_stripes_to_file(stripes: &[Stripe], filename: &str) { + use std::io::Write; + let mut file = std::fs::File::create(filename).unwrap(); + writeln!(file, "ref,begin,end").unwrap(); + for (i, stripe) in stripes.iter().enumerate() { + writeln!(file, "{i},{begin},{end}", begin = stripe.begin, end = stripe.end).unwrap(); + } } -} -#[cfg(feature = "debug-seed-alignment")] -pub fn write_matches_to_file(matches: &[SeedMatch2], filename: &str) { - use std::io::Write; - let mut file = std::fs::File::create(filename).unwrap(); - writeln!(file, "ref_pos,qry_pos,length").unwrap(); - for match_ in matches { - writeln!(file, "{},{},{}", match_.ref_pos, match_.qry_pos, match_.length).unwrap(); + pub fn write_matches_to_file(matches: &[SeedMatch2], filename: &str) { + use std::io::Write; + let mut file = std::fs::File::create(filename).unwrap(); + writeln!(file, "ref_pos,qry_pos,length").unwrap(); + for match_ in matches { + writeln!(file, "{},{},{}", match_.ref_pos, match_.qry_pos, match_.length).unwrap(); + } } } diff --git a/packages/nextclade/src/analyze/divergence.rs b/packages/nextclade/src/analyze/divergence.rs index 6662e410c..b9b9680e0 100644 --- a/packages/nextclade/src/analyze/divergence.rs +++ b/packages/nextclade/src/analyze/divergence.rs @@ -1,36 +1,29 @@ use crate::analyze::nuc_sub::NucSub; use crate::coord::range::NucRefGlobalRange; -use crate::tree::params::TreeBuilderParams; use crate::tree::tree::DivergenceUnits; -pub struct NucMutsCounted<'a> { - muts: Vec<&'a NucSub>, - masked_muts: Vec<&'a NucSub>, - other_muts: Vec<&'a NucSub>, +pub struct NucMutsCounted { n_muts: usize, n_masked_muts: usize, n_other_muts: usize, } -pub fn count_nuc_muts<'a>(nuc_muts: &'a [NucSub], masked_ranges: &[NucRefGlobalRange]) -> NucMutsCounted<'a> { +pub fn count_nuc_muts<'a>(nuc_muts: &'a [NucSub], masked_ranges: &[NucRefGlobalRange]) -> NucMutsCounted { // Split away non_acgt mutations - let (nuc_muts, other_muts): (Vec<_>, Vec<_>) = nuc_muts + let (nuc_muts, other_muts) = nuc_muts .iter() - .partition(|m| m.ref_nuc.is_acgt() && m.qry_nuc.is_acgt()); + .partition::, _>(|m| m.ref_nuc.is_acgt() && m.qry_nuc.is_acgt()); // Split away masked mutations - let (masked_muts, muts): (Vec<_>, Vec<_>) = nuc_muts + let (masked_muts, muts) = nuc_muts .iter() - .partition(|m| masked_ranges.iter().any(|range| range.contains(m.pos))); + .partition::, _>(|m| masked_ranges.iter().any(|range| range.contains(m.pos))); let n_muts = muts.len(); let n_masked_muts = masked_muts.len(); let n_other_muts = other_muts.len(); NucMutsCounted { - muts, - masked_muts, - other_muts, n_muts, n_masked_muts, n_other_muts, @@ -47,7 +40,6 @@ pub fn calculate_branch_length( n_muts, n_masked_muts, n_other_muts, - .. } = count_nuc_muts(nuc_muts, masked_ranges); let mut this_div = n_muts as f64; @@ -65,12 +57,11 @@ pub fn calculate_branch_length( } /// Calculate nuc mut score -pub fn score_nuc_muts(nuc_muts: &[NucSub], masked_ranges: &[NucRefGlobalRange], params: &TreeBuilderParams) -> f64 { +pub fn score_nuc_muts(nuc_muts: &[NucSub], masked_ranges: &[NucRefGlobalRange]) -> f64 { let NucMutsCounted { n_muts, n_masked_muts, n_other_muts, - .. } = count_nuc_muts(nuc_muts, masked_ranges); let mut score = n_muts as f64; // modify the score by sub-integer amounts for masked and other mutations. this effectively means diff --git a/packages/nextclade/src/features/feature_group.rs b/packages/nextclade/src/features/feature_group.rs index 4440dc553..3fc13dddf 100644 --- a/packages/nextclade/src/features/feature_group.rs +++ b/packages/nextclade/src/features/feature_group.rs @@ -37,7 +37,7 @@ impl PartialOrd for FeatureGroup { } impl FeatureGroup { - pub fn new(id: &str, features: &[Feature]) -> Self { + pub fn new(features: &[Feature]) -> Self { let index = features .iter() .map(|feature| feature.index) diff --git a/packages/nextclade/src/features/feature_tree.rs b/packages/nextclade/src/features/feature_tree.rs index c1da288d1..559583291 100644 --- a/packages/nextclade/src/features/feature_tree.rs +++ b/packages/nextclade/src/features/feature_tree.rs @@ -87,7 +87,7 @@ fn read_gff3_feature_tree_str(content: impl AsRef) -> Result Result .iter() .group_by(|feature| feature.id.clone()) .into_iter() - .map(|(id, features)| FeatureGroup::new(&id, &features.cloned().collect_vec())) + .map(|(_, features)| FeatureGroup::new(&features.cloned().collect_vec())) .collect_vec(); // Find top-level features (having no parents) diff --git a/packages/nextclade/src/features/feature_tree_format.rs b/packages/nextclade/src/features/feature_tree_format.rs index db5226c70..a349d1711 100644 --- a/packages/nextclade/src/features/feature_tree_format.rs +++ b/packages/nextclade/src/features/feature_tree_format.rs @@ -85,9 +85,6 @@ fn format_sequence_region_feature( Ok(()) } -const PASS_ICON: &str = "│ "; -const FORK_ICON: &str = "├──"; -const IMPASSE_ICON: &str = "└──"; const INDENT: usize = 2; fn format_feature_groups(w: &mut W, feature_map: &[FeatureGroup], max_name_len: usize) -> Result<(), Report> { @@ -103,7 +100,7 @@ fn format_feature_groups_recursive( feature_groups .iter() .enumerate() - .try_for_each(|(height, feature_group)| -> Result<(), Report> { + .try_for_each(|(_, feature_group)| -> Result<(), Report> { format_feature_group(w, feature_group, max_name_len, depth)?; format_feature_groups_recursive(w, &feature_group.children, max_name_len, depth + 1)?; Ok(()) diff --git a/packages/nextclade/src/io/file.rs b/packages/nextclade/src/io/file.rs index 499d80d81..77e821712 100644 --- a/packages/nextclade/src/io/file.rs +++ b/packages/nextclade/src/io/file.rs @@ -1,3 +1,4 @@ +use crate::io::compression::{Compressor, Decompressor}; use crate::io::fs::ensure_dir; use eyre::{Report, WrapErr}; use log::info; @@ -5,34 +6,14 @@ use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; -#[cfg(not(target_arch = "wasm32"))] -use log::warn; - -use crate::io::compression::{Compressor, Decompressor}; -#[cfg(not(target_arch = "wasm32"))] -use atty::{is as is_tty, Stream}; - pub const DEFAULT_FILE_BUF_SIZE: usize = 256 * 1024; -const TTY_WARNING: &str = r#"Reading from standard input which is a TTY (e.g. an interactive terminal). This is likely not what you meant. Instead: - - - if you want to read fasta from the output of another program, try: - - cat /path/to/file | nextclade - - - if you want to read from file(s), don't forget to provide a path: - - nextclade /path/to/file -"#; - /// Open stdin pub fn open_stdin() -> Result, Report> { info!("Reading from standard input"); #[cfg(not(target_arch = "wasm32"))] - if is_tty(Stream::Stdin) { - warn!("{TTY_WARNING}"); - } + non_wasm::warn_if_tty(); Ok(Box::new(BufReader::new(stdin()))) } @@ -83,3 +64,27 @@ pub fn is_path_stdout(filepath: impl AsRef) -> bool { let filepath = filepath.as_ref(); filepath == PathBuf::from("-") || filepath == PathBuf::from("/dev/stdout") } + +#[cfg(not(target_arch = "wasm32"))] +mod non_wasm { + use atty::{is as is_tty, Stream}; + use log::warn; + + #[cfg(not(target_arch = "wasm32"))] + const TTY_WARNING: &str = r#"Reading from standard input which is a TTY (e.g. an interactive terminal). This is likely not what you meant. Instead: + + - if you want to read fasta from the output of another program, try: + + cat /path/to/file | nextclade + + - if you want to read from file(s), don't forget to provide a path: + + nextclade /path/to/file +"#; + + pub(super) fn warn_if_tty() { + if is_tty(Stream::Stdin) { + warn!("{TTY_WARNING}"); + } + } +} diff --git a/packages/nextclade/src/io/gff3.rs b/packages/nextclade/src/io/gff3.rs index 67b4f0ff2..f91139293 100644 --- a/packages/nextclade/src/io/gff3.rs +++ b/packages/nextclade/src/io/gff3.rs @@ -11,8 +11,6 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fmt::Debug; - - /// Possible keys for name attribute (in order of preference!) pub const NAME_ATTRS_GENE: &[&str] = &[ "Gene", @@ -162,24 +160,9 @@ impl GffCommonInfo { } } -/// Retrieve GFF records of a certain "feature_type" -fn get_records_by_feature_type<'r>( - records: &'r [(usize, GffRecord)], - record_type: &str, -) -> Vec<&'r (usize, GffRecord)> { - records - .iter() - .filter(|(i, record)| { - let searched = record_type.to_lowercase(); - let candidate = record.feature_type().to_lowercase(); - (candidate == searched) || (candidate == get_sequence_onthology_code(&searched).unwrap_or_default()) - }) - .collect_vec() -} - #[inline] #[must_use] -pub fn get_sequence_onthology_code(feature_name: &str) -> Option<&str> { +pub fn get_sequence_ontology_code(feature_name: &str) -> Option<&str> { match feature_name { "cds" => Some("SO:0000316"), "gene" => Some("SO:0000704"), diff --git a/packages/nextclade/src/io/nextclade_csv.rs b/packages/nextclade/src/io/nextclade_csv.rs index 01dc48d0b..5a97c7b3b 100644 --- a/packages/nextclade/src/io/nextclade_csv.rs +++ b/packages/nextclade/src/io/nextclade_csv.rs @@ -234,7 +234,7 @@ fn prepare_headers( .categories .iter() .flat_map(|(_, columns)| columns.iter()) - .filter(|(column, enabled)| **enabled) + .filter(|(_, enabled)| **enabled) .map(|(column, _)| column.as_str()); let individual_headers = column_config.individual.iter().map(String::as_str); @@ -799,14 +799,7 @@ pub fn format_escape(escape: &[PhenotypeValue]) -> String { fn format_aa_motifs(motifs: &[AaMotif]) -> String { motifs .iter() - .map( - |AaMotif { - name, - cds, - position, - seq, - }| format!("{}:{}:{seq}", cds, position + 1), - ) + .map(|AaMotif { cds, position, seq, .. }| format!("{}:{}:{seq}", cds, position + 1)) .join(";") } diff --git a/packages/nextclade/src/io/results_json.rs b/packages/nextclade/src/io/results_json.rs index 61ef82ab9..6543d2039 100644 --- a/packages/nextclade/src/io/results_json.rs +++ b/packages/nextclade/src/io/results_json.rs @@ -6,10 +6,10 @@ use crate::types::outputs::{ combine_outputs_and_errors_sorted, NextcladeErrorOutputs, NextcladeOutputOrError, NextcladeOutputs, }; use crate::utils::datetime::date_iso_now; +use crate::utils::info::this_package_version_str; use eyre::Report; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; -use crate::utils::info::this_package_version_str; #[derive(Serialize, Deserialize, schemars::JsonSchema)] #[serde(rename_all = "camelCase")] @@ -129,7 +129,7 @@ pub fn results_to_ndjson_string( let output_or_errors = combine_outputs_and_errors_sorted(outputs, errors); - for (i, output_or_error) in output_or_errors { + for (_, output_or_error) in output_or_errors { match output_or_error { NextcladeOutputOrError::Outputs(output) => writer.write(&output), NextcladeOutputOrError::Error(error) => writer.write_nuc_error(error.index, &error.seq_name, &error.errors), diff --git a/packages/nextclade/src/qc/qc_rule_mixed_sites.rs b/packages/nextclade/src/qc/qc_rule_mixed_sites.rs index 678197343..7cb921089 100644 --- a/packages/nextclade/src/qc/qc_rule_mixed_sites.rs +++ b/packages/nextclade/src/qc/qc_rule_mixed_sites.rs @@ -32,7 +32,7 @@ pub fn rule_mixed_sites( // Calculate total of mixed (ambiguous) nucleotides: non-ACGT, non-N, non-Gap let total_mixed_sites = nucleotide_composition .iter() - .filter(|(nuc, total)| !(nuc.is_acgtn() || nuc.is_gap())) + .filter(|(nuc, _)| !(nuc.is_acgtn() || nuc.is_gap())) .map(|(_, total)| total) .sum(); diff --git a/packages/nextclade/src/run/nextclade_run_one.rs b/packages/nextclade/src/run/nextclade_run_one.rs index 5fbe2126a..bdc3fd322 100644 --- a/packages/nextclade/src/run/nextclade_run_one.rs +++ b/packages/nextclade/src/run/nextclade_run_one.rs @@ -46,7 +46,6 @@ struct NextcladeResultWithAa { total_aminoacid_insertions: usize, nuc_to_aa_muts: BTreeMap>, missing_genes: Vec, - present_genes: HashSet, warnings: Vec, aa_insertions: Vec, frame_shifts: Vec, @@ -148,7 +147,6 @@ pub fn nextclade_run_one( total_unknown_aa, aa_alignment_ranges, aa_unsequenced_ranges, - .. } = if !gene_map.is_empty() { let coord_map_global = CoordMapGlobal::new(&alignment.ref_seq); @@ -232,7 +230,6 @@ pub fn nextclade_run_one( total_aminoacid_insertions, nuc_to_aa_muts, missing_genes, - present_genes, warnings, aa_insertions, frame_shifts, diff --git a/packages/nextclade/src/tree/tree_builder.rs b/packages/nextclade/src/tree/tree_builder.rs index 1ce4b7457..5c2683c55 100644 --- a/packages/nextclade/src/tree/tree_builder.rs +++ b/packages/nextclade/src/tree/tree_builder.rs @@ -86,10 +86,10 @@ pub fn graph_attach_new_node_in_place( } else { // for the attachment on the reference tree ('result') fine tune the position // on the updated graph to minimize the number of private mutations - finetune_nearest_node(graph, result.nearest_node_id, &mutations_seq, params)? + finetune_nearest_node(graph, result.nearest_node_id, &mutations_seq)? }; - // add the new node at the fine tuned position while accounting for shared mutations + // add the new node at the fine-tuned position while accounting for shared mutations // on the branch leading to the nearest node. knit_into_graph(graph, nearest_node_key, result, &private_mutations, ref_seq_len, params)?; @@ -106,7 +106,6 @@ pub fn finetune_nearest_node( graph: &AuspiceGraph, nearest_node_key: GraphNodeKey, seq_private_mutations: &BranchMutations, - params: &TreeBuilderParams, ) -> Result<(GraphNodeKey, BranchMutations), Report> { let masked_ranges = graph.data.meta.placement_mask_ranges(); let mut best_node = graph.get_node(nearest_node_key)?; @@ -115,7 +114,7 @@ pub fn finetune_nearest_node( loop { // Check how many mutations are shared with the branch leading to the current_best_node or any of its children let (candidate_node, candidate_split, shared_muts_score) = - find_shared_muts(graph, best_node, &private_mutations, masked_ranges, params).wrap_err_with(|| { + find_shared_muts(graph, best_node, &private_mutations, masked_ranges).wrap_err_with(|| { format!( "When calculating shared mutations against the current best node '{}'", best_node.payload().name @@ -123,7 +122,7 @@ pub fn finetune_nearest_node( })?; // Check if the new candidate node is better than the current best - let left_muts_score = score_nuc_muts(&candidate_split.left.nuc_muts, masked_ranges, params); + let left_muts_score = score_nuc_muts(&candidate_split.left.nuc_muts, masked_ranges); match find_better_node_maybe(graph, best_node, candidate_node, shared_muts_score, left_muts_score) { None => break, Some(better_node) => best_node = better_node, @@ -147,7 +146,6 @@ fn find_shared_muts<'g>( best_node: &'g Node, private_mutations: &BranchMutations, masked_ranges: &[NucRefGlobalRange], - params: &TreeBuilderParams, ) -> Result<(&'g Node, SplitMutsResult, f64), Report> { let (mut candidate_split, mut shared_muts_score) = if best_node.is_root() { // Don't include node if node is root as we don't attach nodes above the root @@ -165,7 +163,7 @@ fn find_shared_muts<'g>( best_node.payload().name ) })?; - let shared_muts_score = score_nuc_muts(&candidate_split.shared.nuc_muts, masked_ranges, params); + let shared_muts_score = score_nuc_muts(&candidate_split.shared.nuc_muts, masked_ranges); (candidate_split, shared_muts_score) }; @@ -178,7 +176,7 @@ fn find_shared_muts<'g>( child.payload().name ) })?; - let child_shared_muts_score = score_nuc_muts(&child_split.shared.nuc_muts, masked_ranges, params); + let child_shared_muts_score = score_nuc_muts(&child_split.shared.nuc_muts, masked_ranges); if child_shared_muts_score > shared_muts_score { shared_muts_score = child_shared_muts_score; candidate_split = child_split; diff --git a/packages/nextclade/src/utils/error.rs b/packages/nextclade/src/utils/error.rs index 0ecc1a2a4..ab79ffdff 100644 --- a/packages/nextclade/src/utils/error.rs +++ b/packages/nextclade/src/utils/error.rs @@ -15,14 +15,6 @@ pub fn from_eyre_error(val_or_err: Result) -> Result String { - #[cfg(not(debug_assertions))] - return "An unexpected error occurred. Please try again later.".to_owned(); - - #[cfg(debug_assertions)] - report_to_string(report) -} - /// Preserves only the Result::Ok values in a given collection pub fn keep_ok(results: &[Result]) -> impl Iterator { results.iter().filter_map(|res| match res { diff --git a/packages/nextclade/src/utils/global_init.rs b/packages/nextclade/src/utils/global_init.rs index b85cc7fda..6645564ec 100644 --- a/packages/nextclade/src/utils/global_init.rs +++ b/packages/nextclade/src/utils/global_init.rs @@ -3,13 +3,8 @@ use crate::utils::datetime::{date_format_precise, date_now}; use env_logger::Env; use log::{Level, LevelFilter, Record}; use owo_colors::OwoColorize; -use std::env; use std::io::Write; -fn get_current_exe_filename() -> Option { - env::current_exe().ok().and_then(filename_maybe) -} - fn get_file_line(record: &Record) -> String { let file = record.file().and_then(filename_maybe); match (file, record.line()) { @@ -42,7 +37,6 @@ pub fn setup_logger(filter_level: LevelFilter) { env_logger::Builder::from_env(Env::default().default_filter_or("warn")) .filter_level(filter_level) .format(|buf, record| { - let current_exe = get_current_exe_filename().unwrap_or_default().dimmed().to_string(); let file_line = get_file_line(record); let level = color_log_level(record); let date = date_format_precise(&date_now()).dimmed().to_string();