Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ indicatif-log-bridge = "0.2.3"
indoc = "=2.0.5"
intervallum = "=1.4.1"
itertools = "=0.14.0"
lazy_static = "=1.5.0"
log = "=0.4.26"
maplit = "=1.0.2"
ndarray = { version = "=0.16.1", features = ["rayon", "serde", "blas", "approx"] }
Expand Down Expand Up @@ -234,6 +233,7 @@ pub_use = "allow"
pub_with_shorthand = "allow"
question_mark_used = "allow"
redundant_closure_for_method_calls = "allow"
redundant_test_prefix = "allow"
renamed_function_params = "allow"
self_named_module_files = "allow"
semicolon_inside_block = "allow"
Expand Down
2 changes: 1 addition & 1 deletion packages/minimap2/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl Minimap2RawRegs {

// SAFETY: calling unsafe function. The `mm_map()` allocates memory for results array and the `.p` field each of
// its elements' using `malloc()`. This memory needs to be deallocated using `free()`.
let regs: *mut mm_reg1_t = unsafe { mm_map(mi, l_seq, seq, &mut n_regs, buf.get_mut(), map_opt, name) };
let regs: *mut mm_reg1_t = unsafe { mm_map(mi, l_seq, seq, &raw mut n_regs, buf.get_mut(), map_opt, name) };

Ok(Self {
regs,
Expand Down
4 changes: 2 additions & 2 deletions packages/minimap2/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ impl Minimap2Options {
}

pub(crate) fn idx_opt_mut(&mut self) -> *mut mm_idxopt_t {
&mut self.idx_opt
&raw mut self.idx_opt
}

pub(crate) fn map_opt(&self) -> &mm_mapopt_t {
&self.map_opt
}

pub(crate) fn map_opt_mut(&mut self) -> *mut mm_mapopt_t {
&mut self.map_opt
&raw mut self.map_opt
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/pangraph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ indicatif-log-bridge = { workspace = true }
indoc = { workspace = true }
intervallum = { workspace = true }
itertools = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
maplit = { workspace = true }
minimap2 = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn create_alignment_band(

// loop over remaining seeds in chain
for next_seed in chain.iter().skip(1) {
let mean_offset = (next_seed.offset + current_seed.offset) / 2; // offset of gap seed
let mean_offset = isize::midpoint(next_seed.offset, current_seed.offset); // offset of gap seed
let shift = abs_shift(current_seed, next_seed) / 2; // distance from mean offset
look_forward_length = shift + excess_bandwidth;

Expand Down
6 changes: 2 additions & 4 deletions packages/pangraph/src/align/nextclade/align_with_nextclade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ mod tests {
use crate::commands::build::build_args::PangraphBuildArgs;
use crate::o;
use eyre::Report;
use lazy_static::lazy_static;
use pretty_assertions::assert_eq;
use rstest::rstest;
use std::sync::LazyLock;

lazy_static! {
static ref EXTRA_BANDWIDTH: usize = PangraphBuildArgs::default().extra_band_width;
}
static EXTRA_BANDWIDTH: LazyLock<usize> = LazyLock::new(|| PangraphBuildArgs::default().extra_band_width);

#[rstest]
fn test_align_with_nextclade_general_case() -> Result<(), Report> {
Expand Down
8 changes: 4 additions & 4 deletions packages/pangraph/src/circularize/merge_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ fn check_sequence_reconstruction(
if seq != new_seq {
warn!("seq1: {}", e1.apply(block_1.consensus())?);
warn!("cons1: {}", block_1.consensus());
warn!("e1: {:?}", e1);
warn!("e1: {e1:?}");
warn!("seq2: {}", e2.apply(block_2.consensus())?);
warn!("cons2: {}", block_2.consensus());
warn!("e2: {:?}", e2);
warn!("e2: {e2:?}");

warn!("new_seq: {}", new_seq);
warn!("new_seq: {new_seq}");
warn!("new_cons: {}", new_block.consensus());
warn!("new_e: {:?}", new_e);
warn!("new_e: {new_e:?}");
}
debug_assert_eq!(seq, new_seq);
}
Expand Down
7 changes: 2 additions & 5 deletions packages/pangraph/src/commands/root_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ use clap::{CommandFactory, Parser, Subcommand, ValueEnum};
use clap_complete::{Shell, generate};
use clap_complete_fig::Fig;
use eyre::{Report, eyre};
use lazy_static::lazy_static;
use num_cpus;
use std::fmt::Debug;
use std::io;

lazy_static! {
pub static ref SHELLS: Vec<&'static str> = ["bash", "elvish", "fish", "fig", "powershell", "zsh"].to_vec();
}
const SHELLS: &[&str] = &["bash", "elvish", "fish", "fig", "powershell", "zsh"];

fn styles() -> styling::Styles {
styling::Styles::styled()
Expand Down Expand Up @@ -90,7 +87,7 @@ pub enum PangraphCommands {
///
Completions {
/// Name of the shell to generate appropriate completions
#[clap(value_name = "SHELL", default_value_t = String::from("bash"), value_parser = SHELLS.clone())]
#[clap(value_name = "SHELL", default_value_t = String::from("bash"), value_parser = SHELLS.to_vec())]
shell: String,
},

Expand Down
8 changes: 4 additions & 4 deletions packages/pangraph/src/io/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use flate2::write::GzEncoder;
use num::Integer;
use num_traits::NumCast;
use std::env;
use std::io::{ErrorKind, Read, Write};
use std::io::{Read, Write};
use std::path::Path;
use std::str::FromStr;

Expand Down Expand Up @@ -123,7 +123,7 @@ impl Read for Decompressor<'_> {
.header("Filename")
})
.with_section(|| self.compression_type.clone().header("Decompressor"))
.map_err(|report| std::io::Error::new(ErrorKind::Other, report_to_string(&report)))
.map_err(|report| std::io::Error::other(report_to_string(&report)))
}
}

Expand Down Expand Up @@ -182,7 +182,7 @@ impl Write for Compressor<'_> {
.header("Filename")
})
.with_section(|| self.compression_type.clone().header("Compressor"))
.map_err(|report| std::io::Error::new(ErrorKind::Other, report_to_string(&report)))
.map_err(|report| std::io::Error::other(report_to_string(&report)))
}

fn flush(&mut self) -> std::io::Result<()> {
Expand All @@ -198,7 +198,7 @@ impl Write for Compressor<'_> {
.header("Filename")
})
.with_section(|| self.compression_type.clone().header("Compressor"))
.map_err(|report| std::io::Error::new(ErrorKind::Other, report_to_string(&report)))
.map_err(|report| std::io::Error::other(report_to_string(&report)))
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/pangraph/src/io/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn open_file_or_stdin<P: AsRef<Path>>(filepath: &Option<P>) -> Result<Box<dy
if is_path_stdin(filepath) {
open_stdin()
} else {
let file = File::open(filepath).wrap_err_with(|| format!("When opening file '{filepath:?}'"))?;
let file = File::open(filepath).wrap_err_with(|| format!("When opening file '{}'", filepath.display()))?;
let buf_file = BufReader::with_capacity(DEFAULT_FILE_BUF_SIZE, file);
let decompressor = Decompressor::from_path(buf_file, filepath)?;
let buf_decompressor = BufReader::with_capacity(DEFAULT_FILE_BUF_SIZE, decompressor);
Expand All @@ -70,7 +70,7 @@ pub fn create_file_or_stdout(filepath: impl AsRef<Path>) -> Result<Box<dyn Write
Box::new(BufWriter::with_capacity(DEFAULT_FILE_BUF_SIZE, stdout()))
} else {
ensure_dir(filepath)?;
Box::new(File::create(filepath).wrap_err_with(|| format!("When creating file: '{filepath:?}'"))?)
Box::new(File::create(filepath).wrap_err_with(|| format!("When creating file: '{}'", filepath.display()))?)
};

let buf_file = BufWriter::with_capacity(DEFAULT_FILE_BUF_SIZE, file);
Expand Down
6 changes: 3 additions & 3 deletions packages/pangraph/src/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub fn ensure_dir(filepath: impl AsRef<Path>) -> Result<(), Report> {

let parent_path = absolute_path(parent_dir)?;

fs::create_dir_all(&parent_path).wrap_err_with(|| format!("When creating directory '{parent_path:#?}'"))
fs::create_dir_all(&parent_path).wrap_err_with(|| format!("When creating directory '{}'", parent_path.display()))
}
.wrap_err_with(|| format!("When ensuring parent directory for '{filepath:#?}'"))
.wrap_err_with(|| format!("When ensuring parent directory for '{}'", filepath.display()))
}

pub fn filename_maybe(filepath: impl AsRef<Path>) -> Option<String> {
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn read_file_to_string(filepath: impl AsRef<Path>) -> Result<String, Report>
let mut data = String::new();
file
.read_to_string(&mut data)
.wrap_err_with(|| format!("When reading file: {filepath:#?}"))?;
.wrap_err_with(|| format!("When reading file: {}", filepath.display()))?;
Ok(data)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pangraph/src/io/gfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl GfaWriteParams {
pub fn gfa_write_file(filepath: impl AsRef<Path>, g: &Pangraph, params: &GfaWriteParams) -> Result<(), Report> {
let filepath = filepath.as_ref();
gfa_write(create_file_or_stdout(filepath)?, g, params)
.wrap_err_with(|| format!("When writing gfa file: {filepath:#?}"))
.wrap_err_with(|| format!("When writing gfa file: {}", filepath.display()))
}

pub fn gfa_write_str(g: &Pangraph, params: &GfaWriteParams) -> Result<String, Report> {
Expand Down
2 changes: 1 addition & 1 deletion packages/pangraph/src/io/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct JsonPretty(pub bool);
pub fn json_write_file<T: Serialize>(filepath: impl AsRef<Path>, obj: &T, pretty: JsonPretty) -> Result<(), Report> {
let filepath = filepath.as_ref();
json_write(create_file_or_stdout(filepath)?, &obj, pretty)
.wrap_err_with(|| format!("When writing JSON file: {filepath:#?}"))
.wrap_err_with(|| format!("When writing JSON file: {}", filepath.display()))
}

pub fn json_write_str<T: Serialize>(obj: &T, pretty: JsonPretty) -> Result<String, Report> {
Expand Down
3 changes: 2 additions & 1 deletion packages/pangraph/src/io/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub fn yaml_read<T: for<'de> Deserialize<'de>>(reader: impl std::io::Read) -> Re

pub fn yaml_write_file<T: Serialize>(filepath: impl AsRef<Path>, obj: &T) -> Result<(), Report> {
let filepath = filepath.as_ref();
yaml_write(create_file_or_stdout(filepath)?, &obj).wrap_err_with(|| format!("When writing YAML file: {filepath:#?}"))
yaml_write(create_file_or_stdout(filepath)?, &obj)
.wrap_err_with(|| format!("When writing YAML file: {}", filepath.display()))
}

pub fn yaml_write_str<T: Serialize>(obj: &T) -> Result<String, Report> {
Expand Down
2 changes: 1 addition & 1 deletion packages/pangraph/src/pangraph/detach_unaligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn detach_unaligned_nodes(
blocks.push(new_block);
// replace the new node in the nodes dictionary
nodes_dict.insert(node_id, new_node.clone());
debug!("Replaced node {} in nodes dictionary with new node", node_id);
debug!("Replaced node {node_id} in nodes dictionary with new node");
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions packages/pangraph/src/pangraph/reweave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ fn update_cigar(
// anchor extension - more reference is a deletion
if let Some(left) = anchor_extension.left {
new_cigar = add_flanking_indel(&new_cigar, Kind::Deletion, left, &Side::Leading).unwrap();
};
}
if let Some(right) = anchor_extension.right {
new_cigar = add_flanking_indel(&new_cigar, Kind::Deletion, right, &Side::Trailing).unwrap();
};
}

// append extension - more query is an insertion
if let Some(left) = append_extension.left {
Expand All @@ -273,14 +273,14 @@ fn update_cigar(
Strand::Reverse => Side::Trailing,
};
new_cigar = add_flanking_indel(&new_cigar, Kind::Insertion, left, &side).unwrap();
};
}
if let Some(right) = append_extension.right {
let side = match orientation {
Strand::Forward => Side::Trailing,
Strand::Reverse => Side::Leading,
};
new_cigar = add_flanking_indel(&new_cigar, Kind::Insertion, right, &side).unwrap();
};
}

new_cigar
}
Expand Down
5 changes: 1 addition & 4 deletions packages/pangraph/src/utils/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ pub fn from_eyre_error<T, E: FromStr>(val_or_err: Result<T, Report>) -> Result<T

/// Preserves only the Result::Ok values in a given collection
pub fn keep_ok<T, E>(results: &[Result<T, E>]) -> impl Iterator<Item = &T> {
results.iter().filter_map(|res| match res {
Ok(val) => Some(val),
Err(_) => None,
})
results.iter().filter_map(|res| res.as_ref().ok())
}

#[macro_export(local_inner_macros)]
Expand Down
10 changes: 5 additions & 5 deletions packages/pangraph/src/utils/float_fmt.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use lazy_static::lazy_static;
use pretty_dtoa::{FmtFloatConfig, dtoa};
use std::sync::LazyLock;

lazy_static! {
static ref FLOAT_CONFIG: FmtFloatConfig = FmtFloatConfig::default()
static FLOAT_CONFIG: LazyLock<FmtFloatConfig> = LazyLock::new(|| {
FmtFloatConfig::default()
.force_no_e_notation()
.add_point_zero(true)
.max_significant_digits(3)
.radix_point('.')
.round();
}
.round()
});

pub fn float_to_significant_digits<F: Into<f64>>(weight: F, max_significant_digits: u8) -> String {
dtoa(
Expand Down
1 change: 0 additions & 1 deletion packages/pangraph/src/utils/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::sync::Arc;
pub struct Lock<T>(Arc<RwLock<RawRwLock, T>>);

impl<T> Clone for Lock<T> {
#[must_use]
fn clone(&self) -> Self {
Lock(Arc::clone(&self.0))
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.85.0"
channel = "1.90.0"
profile = "default"