Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvollger committed Jan 10, 2024
1 parent 78e9b44 commit ca10f3e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ spin = "0.9.8"
tch = {version = "0.14.0", optional = true}
tempfile = "3.3.0"
derive_builder = "0.12.0"
gzp = "0.11.3"
niffler = {version = "2.5.0", default-features = false, features = ["gz"]}

[features]
cli = ["dep:clap", "dep:clap_complete", "dep:clap_mangen", "dep:console"]
Expand Down
16 changes: 8 additions & 8 deletions src/bamlift/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ where
/// Normal sort is supposed to be very fast on two sorted lists
/// <https://doc.rust-lang.org/std/vec/struct.Vec.html#current-implementation-6>
/// ```
/// use bamlift::*;
/// use fibertools_rs::bamlift::*;
/// let x = vec![1,3];
/// let x_q = vec!["a","b"];
/// let y = vec![2,4];
Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn positions_on_complimented_sequence(
/// get positions on the complimented sequence in the cigar record
pub fn positions_on_complimented_sequence_in_place(
record: &bam::Record,
input_positions: &mut Vec<i64>,
input_positions: &mut [i64],
part_of_range: bool,
) {
if !record.is_reverse() {
Expand Down Expand Up @@ -107,7 +107,7 @@ where
/// a\[i-1\] <= v < a\[i\]
/// <https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html>
/// ```
/// use bamlift::*;
/// use fibertools_rs::bamlift::*;
/// let a = vec![1, 2, 3, 5, 6, 7, 8, 9, 10];
/// let v = vec![0, 1, 3, 4, 11, 11];
/// let indexes = search_sorted(&a, &v);
Expand Down Expand Up @@ -187,22 +187,22 @@ fn liftover_closest(
// get the previous closest position
let (best_r_pos, best_diff) = pos_mapping.get_mut(cur_pos).unwrap();
// exact match found
if cur_pos >= &q_st && cur_pos < &q_en {
if cur_pos >= q_st && cur_pos < q_en {
let dist_from_start = cur_pos - q_st;
*best_diff = 0;
*best_r_pos = r_st + dist_from_start;
break;
}
// we are before the start of the block
else if cur_pos < &q_st {
else if cur_pos < q_st {
let diff = (q_st - cur_pos).abs();
if diff < *best_diff {
*best_diff = diff;
*best_r_pos = *r_st;
}
}
// we are past the end of the block
else if cur_pos >= &q_en {
else if cur_pos >= q_en {
let diff = (q_en - cur_pos).abs();
if diff < *best_diff {
*best_diff = diff;
Expand Down Expand Up @@ -237,7 +237,7 @@ pub fn lift_reference_positions(

/// find the closest query positions for a list of reference positions
pub fn lift_query_positions(
aligned_block_pairs: &Vec<([i64; 2], [i64; 2])>,
aligned_block_pairs: &[([i64; 2], [i64; 2])],
reference_positions: &[i64],
) -> Vec<Option<i64>> {
// if lifting to the query, we need to reverse the pairs
Expand Down Expand Up @@ -266,7 +266,7 @@ fn lift_range(
assert_eq!(ref_starts.len(), ref_ends.len());
let rtn = ref_starts
.into_iter()
.zip(ref_ends.into_iter())
.zip(ref_ends)
.map(|(start, end)| match (start, end) {
(Some(start), Some(end)) => {
if start == end {
Expand Down
4 changes: 2 additions & 2 deletions src/basemods/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bamlift::*;
use super::bamlift::*;
use super::bio_io::*;
use bio::alphabets::dna::revcomp;
use bio_io::*;
use itertools::{izip, multiunzip};
use lazy_static::lazy_static;
use regex::Regex;
Expand Down
12 changes: 6 additions & 6 deletions src/bio_io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ pub fn no_length_progress_bar() -> ProgressBar {
let bar = ProgressBar::new(0);
bar.set_style(style);
let finish = indicatif::ProgressFinish::AndLeave;
let bar = bar.with_finish(finish);
bar
bar.with_finish(finish)
}

/*
Expand Down Expand Up @@ -98,12 +97,12 @@ pub fn write_to_file(out: &str, buffer: &mut Box<dyn Write>) {

/// a reader that can read compressed files but also stdin (indicated by -)
/// ```
/// use bio_io::buffer_from;
/// use fibertools_rs::bio_io::buffer_from;
/// use std::io;
/// let reader = buffer_from("../tests/data/test.txt.gz").expect("Error: cannot open file");
/// let reader = buffer_from("tests/data/test.txt.gz").expect("Error: cannot open file");
/// let msg = io::read_to_string(reader).unwrap();
/// assert_eq!(msg, "Hello World!\n");
/// let reader = buffer_from("../tests/data/test.txt").expect("Error: cannot open file");
/// let reader = buffer_from("tests/data/test.txt").expect("Error: cannot open file");
/// let msg = io::read_to_string(reader).unwrap();
/// assert_eq!(msg, "Hello World!\n");
/// ```
Expand Down Expand Up @@ -321,8 +320,9 @@ pub fn find_pb_polymerase(header: &bam::Header) -> PbChem {

///```
/// use rust_htslib::{bam, bam::Read};
/// use fibertools_rs::bio_io;
/// use log;
/// let mut bam = bam::Reader::from_path(&"../tests/data/all.bam").unwrap();
/// let mut bam = bam::Reader::from_path(&"tests/data/all.bam").unwrap();
/// for record in bam.records() {
/// let record = record.unwrap();
/// let n_s = bio_io::get_u32_tag(&record, b"ns");
Expand Down
4 changes: 2 additions & 2 deletions src/fiber.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::bamlift::*;
use super::basemods::BaseMods;
use super::bio_io::*;
use super::center::CenterPosition;
use super::center::CenteredFiberData;
use bamlift::*;
use bio_io::*;
use rayon::prelude::*;
use rust_htslib::bam::Read;
use rust_htslib::{bam, bam::ext::BamRecordExtensions, bam::record::Aux, bam::HeaderView};
Expand Down
1 change: 1 addition & 0 deletions src/footprint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::center::CenterPosition;

use super::bam_writer;
use super::bio_io;
use super::cli::FootprintOptions;
use super::fiber::*;
use anyhow;
Expand Down
1 change: 1 addition & 0 deletions tests/extract_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use fibertools_rs::bio_io;
use rust_htslib::bam::Read;

fn get_fiber_data_from_test_bam(bam_file: &str) -> Vec<fibertools_rs::fiber::FiberseqData> {
Expand Down

0 comments on commit ca10f3e

Please sign in to comment.