Skip to content

Commit 0512e10

Browse files
authored
Run cargo clippy --fix (#537)
* Run cargo clippy --fix * cargo fmt
1 parent 15038a6 commit 0512e10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+585
-637
lines changed

Diff for: enclone_build/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn get_commit_hash() -> String {
5454
}
5555

5656
fn is_github() -> bool {
57-
matches!(std::env::var("GITHUB_SHA"), Ok(_))
57+
std::env::var("GITHUB_SHA").is_ok()
5858
}
5959

6060
// We used to have the commit date here but this is easier and serves the same purpose for

Diff for: enclone_denovo/src/bin/denovo.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ fn main() {
849849
.between(":", ".")
850850
.to_string();
851851
}
852-
name = name.replace("_", " ");
852+
name = name.replace('_', " ");
853853
let tig = originy[i].0;
854854
let best = format!(
855855
"{}{}.{} {} {}|{}|{} {:.1} {} {}",
@@ -1086,7 +1086,7 @@ fn main() {
10861086
}
10871087
let mut zref = Vec::<DnaString>::new();
10881088
let mut zheaders = Vec::<String>::new();
1089-
read_fasta_contents_into_vec_dna_string_plus_headers(&r, &mut zref, &mut zheaders);
1089+
read_fasta_contents_into_vec_dna_string_plus_headers(r, &mut zref, &mut zheaders);
10901090
for i in 0..zref.len() {
10911091
if !zheaders[i].contains("V-REGION") {
10921092
continue;
@@ -2675,7 +2675,7 @@ fn main() {
26752675
if start + l + 1 >= r.len() {
26762676
break;
26772677
}
2678-
let bb = aa_seq(&r[start..start + l].to_vec(), 0);
2678+
let bb = aa_seq(&r[start..start + l], 0);
26792679
if bb.contains(&b'*') {
26802680
continue;
26812681
}
@@ -2707,7 +2707,7 @@ fn main() {
27072707
if start < 10 {
27082708
continue;
27092709
}
2710-
let bb = aa_seq(&r[start..start + l].to_vec(), 0);
2710+
let bb = aa_seq(&r[start..start + l], 0);
27112711
for mx in LOW_INTRON..=HIGH_INTRON {
27122712
let start2 = start + l + mx;
27132713
if start2 > r.len() || r.len() - start2 < 10 {
@@ -2741,7 +2741,7 @@ fn main() {
27412741

27422742
// Keep going.
27432743

2744-
let cc = aa_seq(&r[start2 + 2..stop2].to_vec(), 0);
2744+
let cc = aa_seq(&r[start2 + 2..stop2], 0);
27452745
let mid = vec![r[start + l - 1], r[start2], r[start2 + 1]];
27462746
let mut s = String::new();
27472747
if show_transition {
@@ -2923,8 +2923,7 @@ fn main() {
29232923
}
29242924
-n
29252925
};
2926-
let (gap_open, gap_extend) =
2927-
(-1 * n as i32, -n as i32);
2926+
let (gap_open, gap_extend) = (-n, -n);
29282927

29292928
// Set up the aligner.
29302929

@@ -3443,7 +3442,7 @@ fn main() {
34433442
let mut tag_origin = Vec::<(usize, usize)>::new();
34443443
for i in 0..upstream.len() {
34453444
for j in 0..=upstream[i].len() - TAG_LEN {
3446-
if upstream[i][j..].starts_with(&MOTIF1.to_vec()) {
3445+
if upstream[i][j..].starts_with(MOTIF1.as_ref()) {
34473446
tag_origin.push((i, j));
34483447
tags.push(upstream[i][j..j + TAG_LEN].to_vec());
34493448
}
@@ -3659,7 +3658,7 @@ fn main() {
36593658
}
36603659
if wrong || amb {
36613660
mcount += 1;
3662-
m = m.replace("[", &format!("[{}.", mcount));
3661+
m = m.replace('[', &format!("[{}.", mcount));
36633662
print!("\n{}", m);
36643663
// print!(" upstream={}", strme(&upstream[k]));
36653664
println!();
@@ -3670,7 +3669,7 @@ fn main() {
36703669
nonsimples -= 1;
36713670
}
36723671
mcount += 1;
3673-
m = m.replace("[", &format!("[{}.", mcount));
3672+
m = m.replace('[', &format!("[{}.", mcount));
36743673
print!("\n{}", m);
36753674
// print!(" upstream={}", strme(&upstream[k]));
36763675
println!();

Diff for: enclone_denovo/src/bin/download_genbank_assembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn main() {
5252
.output()
5353
.expect("failed to execute wget");
5454
// no idea why this is needed
55-
std::fs::rename(&format!(" {}", fasta_file), &fasta_file).unwrap();
55+
std::fs::rename(format!(" {}", fasta_file), &fasta_file).unwrap();
5656
std::process::exit(0);
5757
}
5858
}

Diff for: enclone_denovo/src/bin/download_isoseq.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use vector_utils::bin_member;
1919

2020
fn main() {
2121
let dir = "/mnt/assembly/isoseq";
22-
let all = read_dir(&dir).unwrap();
22+
let all = read_dir(dir).unwrap();
2323
let mut owned = Vec::<String>::new();
2424
for f in all {
2525
let f = f.unwrap().path();
@@ -30,12 +30,12 @@ fn main() {
3030
}
3131
owned.sort();
3232
let f = include_str!("../isoseq_list");
33-
let _ = std::env::set_current_dir(&dir);
33+
let _ = std::env::set_current_dir(dir);
3434
for line in f.lines() {
3535
if line.starts_with('#') || line.is_empty() {
3636
continue;
3737
}
38-
let line = line.replace(" ", "");
38+
let line = line.replace(' ', "");
3939
let acc = line.after(":").split(',').collect::<Vec<&str>>();
4040
for i in 0..acc.len() {
4141
if !bin_member(&owned, &acc[i].to_string()) {
@@ -45,7 +45,7 @@ fn main() {
4545
SRA/sratoolkit.2.9.2-centos_linux64/bin/fastq-dump",
4646
)
4747
.arg("--fasta")
48-
.arg(&acc[i])
48+
.arg(acc[i])
4949
.output()
5050
.expect("failed to execute fastq-dump");
5151
if o.status.code().unwrap() != 0 {

Diff for: enclone_denovo/src/bin/download_mammals.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
use fasta_tools::read_fasta_to_vec_vec_u8;
1313
use io_utils::write_obj;
1414

15-
use std::fs::{read_dir, File};
15+
use std::fs::read_dir;
1616
use std::process::Command;
1717
use string_utils::TextUtils;
1818
use vector_utils::bin_member;
1919

2020
fn main() {
2121
let dir1 = "/mnt/assembly/genomes";
2222
let dir2 = "/mnt/deck5/david.jaffe/genomes";
23-
let all = read_dir(&dir1).unwrap();
23+
let all = read_dir(dir1).unwrap();
2424
let mut owned = Vec::<String>::new();
2525
for f in all {
2626
let f = f.unwrap().path();

Diff for: enclone_denovo/src/bin/download_one_isoseq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
SRA/sratoolkit.2.9.2-centos_linux64/bin/fastq-dump",
1515
)
1616
.arg("--fasta")
17-
.arg(&acc)
17+
.arg(acc)
1818
.output()
1919
.expect("failed to execute fastq-dump");
2020
if o.status.code().unwrap() != 0 {

Diff for: enclone_denovo/src/bin/squeeze_novo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
required = args[3].to_string();
2323
}
2424
let dir = "/mnt/deck5/david.jaffe/denovo_ref";
25-
let refs = std::fs::read_dir(&dir).unwrap();
25+
let refs = std::fs::read_dir(dir).unwrap();
2626
for f in refs {
2727
let f = f.unwrap().path();
2828
let f = f.to_str().unwrap();

Diff for: enclone_denovo/src/bin/sync_to_genome_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525
}
2626
let (mut acc2, mut fns2) = (Vec::<String>::new(), Vec::<String>::new());
27-
let all = read_dir(&dir).unwrap();
27+
let all = read_dir(dir).unwrap();
2828
for f in all {
2929
let f = f.unwrap().path();
3030
let f = f.to_str().unwrap();

Diff for: enclone_denovo/src/bin/test_const_ighd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() {
4646
let mut log = Vec::<u8>::new();
4747
fwriteln!(log, "running denovo {} = {}", id, species);
4848
let o = Command::new("denovo")
49-
.arg(&id)
49+
.arg(id)
5050
.output()
5151
.expect("failed to execute denovo");
5252
if o.status.code().unwrap() != 0 {

Diff for: enclone_denovo/src/bin/test_denovo.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
if l > 0 {
2222
let s = line.unwrap();
2323
let s = s.as_bytes();
24-
if s.len() == 0 {
24+
if s.is_empty() {
2525
continue;
2626
}
2727
let mut best_mis = 1000000;
@@ -74,9 +74,9 @@ fn main() {
7474
}
7575
}
7676
if best_mis < best_mis_tenx && best_mis < best_mis_imgt {
77-
println!("");
77+
println!();
7878
printme!(l, best_mis, best_mis_tenx, best_mis_imgt);
79-
println!("seq = {}", strme(&s));
79+
println!("seq = {}", strme(s));
8080
println!("novo = {}", strme(&denovo[best_i]));
8181
println!("tenx = {}", strme(&tenx[best_i_tenx]));
8282
println!("imgt = {}", strme(&imgt[best_i_imgt]));

Diff for: enclone_denovo/src/make_fwr3_freqs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn make_fwr3_freqs() -> Vec<Vec<Vec<(u32, u8)>>> {
2929

3030
// Gather the reference sequences.
3131

32-
let all = read_dir(&"v_segments").unwrap();
32+
let all = read_dir("v_segments").unwrap();
3333
for f in all {
3434
let f = f.unwrap().path();
3535
let f = f.to_str().unwrap();
@@ -53,7 +53,7 @@ pub fn make_fwr3_freqs() -> Vec<Vec<Vec<(u32, u8)>>> {
5353

5454
let mut refs = Vec::<DnaString>::new();
5555
let mut headers = Vec::<String>::new();
56-
read_fasta_into_vec_dna_string_plus_headers(&f.to_string(), &mut refs, &mut headers);
56+
read_fasta_into_vec_dna_string_plus_headers(f, &mut refs, &mut headers);
5757

5858
// Skip broken references: Canus_lupus_familiaris and a bunch of others.
5959

Diff for: enclone_denovo/src/make_mammalian_fixed_len.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn make_mammalian_fixed_len() -> Vec<(String, String, usize, Vec<Vec<(u32, u
2323

2424
// Gather the reference sequences.
2525

26-
let all = read_dir(&"v_segments").unwrap();
26+
let all = read_dir("v_segments").unwrap();
2727
for f in all {
2828
let f = f.unwrap().path();
2929
let f = f.to_str().unwrap();
@@ -47,7 +47,7 @@ pub fn make_mammalian_fixed_len() -> Vec<(String, String, usize, Vec<Vec<(u32, u
4747

4848
let mut refs = Vec::<DnaString>::new();
4949
let mut headers = Vec::<String>::new();
50-
read_fasta_into_vec_dna_string_plus_headers(&f.to_string(), &mut refs, &mut headers);
50+
read_fasta_into_vec_dna_string_plus_headers(f, &mut refs, &mut headers);
5151

5252
// Skip broken references: Canus_lupus_familiaris and a bunch of others.
5353

Diff for: enclone_denovo/src/make_mammalian_pwms.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn make_mammalian_pwms() -> Vec<(String, String, usize, Vec<Vec<(u32, u8)>>)
3939

4040
// Gather the reference sequences.
4141

42-
let all = read_dir(&"v_segments").unwrap();
42+
let all = read_dir("v_segments").unwrap();
4343
for f in all {
4444
let f = f.unwrap().path();
4545
let f = f.to_str().unwrap();
@@ -63,7 +63,7 @@ pub fn make_mammalian_pwms() -> Vec<(String, String, usize, Vec<Vec<(u32, u8)>>)
6363

6464
let mut refs = Vec::<DnaString>::new();
6565
let mut headers = Vec::<String>::new();
66-
read_fasta_into_vec_dna_string_plus_headers(&f.to_string(), &mut refs, &mut headers);
66+
read_fasta_into_vec_dna_string_plus_headers(f, &mut refs, &mut headers);
6767

6868
// Skip broken references: Canus_lupus_familiaris and a bunch of others.
6969

@@ -300,7 +300,7 @@ pub fn make_mammalian_pwms() -> Vec<(String, String, usize, Vec<Vec<(u32, u8)>>)
300300
}
301301
-n
302302
};
303-
let (gap_open, gap_extend) = (-1 * n as i32, -n as i32);
303+
let (gap_open, gap_extend) = (-n, -n);
304304

305305
// Set up the aligner.
306306

Diff for: enclone_denovo/src/mammalian_fixed_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn mammalian_fixed_len() -> Vec<(String, String, usize, Vec<Vec<(u32, u8)>>)
1515
for j in 0..w.len() {
1616
ppp.push((
1717
w[j].before(":").force_usize() as u32,
18-
w[j].after(":").as_bytes()[0] as u8,
18+
w[j].after(":").as_bytes()[0],
1919
));
2020
}
2121
pp.push(ppp);

Diff for: enclone_denovo/src/mammalian_pwms.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn mammalian_pwms() -> Vec<(String, String, usize, Vec<Vec<(u32, u8)>>)> {
1515
for j in 0..w.len() {
1616
ppp.push((
1717
w[j].before(":").force_usize() as u32,
18-
w[j].after(":").as_bytes()[0] as u8,
18+
w[j].after(":").as_bytes()[0],
1919
));
2020
}
2121
pp.push(ppp);

Diff for: enclone_denovo/src/vdj_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ pub fn fr3_start(aa: &Vec<u8>, chain_type: &str, verbose: bool) -> Option<usize>
607607
if verbose {
608608
println!("j = {}, score = {}", j, score);
609609
}
610-
score_pos.push((score, -(j as isize)));
610+
score_pos.push((score, -j));
611611
}
612612
}
613613
reverse_sort(&mut score_pos);

Diff for: enclone_exec/src/bin/enclone.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
// zero. As far as we know, in all other cases where it is not run from the command line, it
55
// returns exit status zero.
66

7-
use chrono::prelude::*;
8-
use enclone_core::combine_group_pics::combine_group_pics;
97
use enclone_main::main_enclone::main_enclone;
108
use enclone_main::USING_PAGER;
11-
use flate2::write::GzEncoder;
12-
use flate2::Compression;
9+
1310
use io_utils::*;
14-
use itertools::Itertools;
11+
1512
#[cfg(not(target_os = "windows"))]
1613
use nix::sys::signal::{kill, SIGINT};
1714
#[cfg(not(target_os = "windows"))]
@@ -20,13 +17,12 @@ use nix::unistd::getppid;
2017
use nix::unistd::Pid;
2118

2219
use std::env;
23-
use std::io::Write;
20+
2421
use std::process::Command;
2522
use std::sync::atomic::Ordering::SeqCst;
2623
use std::thread;
2724
use std::time::Duration;
2825
use string_utils::*;
29-
use vector_utils::unique_sort;
3026

3127
#[tokio::main]
3228
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -57,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5753
home = value.clone();
5854
}
5955
}
60-
if home.len() == 0 {
56+
if home.is_empty() {
6157
eprintln!("Weird, unable to determine your home directory.\n");
6258
std::process::exit(1);
6359
}

0 commit comments

Comments
 (0)