Skip to content

Commit a337bff

Browse files
committed
fix clippy warnings
1 parent 2373620 commit a337bff

7 files changed

Lines changed: 11 additions & 92 deletions

File tree

src/derep.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn derep_and_write_fasta(
5858
let mut w = fasta::open_writer(out_fasta)?;
5959
let mut rep_to_members: HashMap<String, Vec<String>> = HashMap::with_capacity(unique);
6060

61-
for (_key, (rep_id, rep_seq, members)) in &groups {
61+
for (rep_id, rep_seq, members) in groups.values() {
6262
fasta::write_fasta_record(&mut w, rep_id, rep_seq)?;
6363
rep_to_members.insert(rep_id.clone(), members.clone());
6464
}

src/fasta.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ impl FastaReader {
5252
return Ok(None);
5353
}
5454
let line = self.buf.trim_end();
55-
if line.starts_with('>') {
56-
let header = line[1..].trim();
55+
if let Some(stripped) = line.strip_prefix('>') {
56+
let header = stripped.trim();
5757
let id = header
5858
.split_whitespace()
5959
.next()
@@ -76,8 +76,8 @@ impl FastaReader {
7676
break;
7777
}
7878
let line = self.buf.trim_end();
79-
if line.starts_with('>') {
80-
let header = line[1..].trim();
79+
if let Some(stripped) = line.strip_prefix('>') {
80+
let header = stripped.trim();
8181
let next_id = header
8282
.split_whitespace()
8383
.next()

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl AnchorHitOut {
290290
}
291291
}
292292

293+
#[allow(clippy::too_many_arguments)]
293294
fn write_anchor_tsv_row<W: Write>(
294295
w: &mut W,
295296
rid: &str,
@@ -328,6 +329,7 @@ fn write_anchor_tsv_row<W: Write>(
328329
Ok(())
329330
}
330331

332+
#[allow(clippy::too_many_arguments)]
331333
fn write_anchor_jsonl_row<W: Write>(
332334
w: &mut W,
333335
rid: &str,

src/report.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,13 @@ pub struct SkipCounter {
8888
}
8989

9090
impl SkipCounter {
91-
pub fn new() -> Self {
92-
Self::default()
93-
}
94-
9591
pub fn record(&mut self, reason: &SkipReason) {
9692
*self.counts.entry(reason.code().to_string()).or_insert(0) += 1;
9793
}
9894

9995
pub fn to_map(&self) -> HashMap<String, usize> {
10096
self.counts.clone()
10197
}
102-
103-
pub fn total(&self) -> usize {
104-
self.counts.values().sum()
105-
}
10698
}
10799

108100
// ---------------------------------------------------------------------------

src/select.rs

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn to_anchor_hits(hits: &[TblHit]) -> Vec<HitIvl> {
122122
}
123123

124124
/// Sort by score desc, then evalue asc, keep top K
125-
fn top_k<'a>(mut v: Vec<&'a HitIvl>, k: usize) -> Vec<&'a HitIvl> {
125+
fn top_k(mut v: Vec<&HitIvl>, k: usize) -> Vec<&HitIvl> {
126126
v.sort_by(|a, b| {
127127
b.score
128128
.partial_cmp(&a.score)
@@ -470,82 +470,6 @@ fn count_anchors(ah: &[HitIvl]) -> AnchorCounts {
470470
c
471471
}
472472

473-
/// Public: explain why a read likely failed to yield bounds.
474-
pub fn diagnose(
475-
hits: &[TblHit],
476-
region: Region,
477-
max_per_anchor: usize,
478-
constraints: Constraints,
479-
) -> String {
480-
let ah = to_anchor_hits(hits);
481-
if ah.is_empty() {
482-
return "no classified anchor hits (none of SSU_end/58S/LSU matched)".to_string();
483-
}
484-
485-
let counts = count_anchors(&ah);
486-
487-
let missing = {
488-
let mut v = Vec::new();
489-
let has_ssu = counts.ssu_p + counts.ssu_m > 0;
490-
let has_s58s = counts.s58s_p + counts.s58s_m > 0;
491-
let has_s58e = counts.s58e_p + counts.s58e_m > 0;
492-
let has_lsu = counts.lsu_p + counts.lsu_m > 0;
493-
494-
if !has_ssu {
495-
v.push(anchor_name(Anchor::SsuEnd));
496-
}
497-
if !has_s58s {
498-
v.push(anchor_name(Anchor::S58Start));
499-
}
500-
if !has_s58e {
501-
v.push(anchor_name(Anchor::S58End));
502-
}
503-
if !has_lsu {
504-
v.push(anchor_name(Anchor::LsuStart));
505-
}
506-
v
507-
};
508-
509-
let counts_str = format!(
510-
"counts(+/-): SSU_end {}/{} 58S_start {}/{} 58S_end {}/{} LSU_start {}/{}",
511-
counts.ssu_p,
512-
counts.ssu_m,
513-
counts.s58s_p,
514-
counts.s58s_m,
515-
counts.s58e_p,
516-
counts.s58e_m,
517-
counts.lsu_p,
518-
counts.lsu_m
519-
);
520-
521-
if !missing.is_empty() {
522-
return format!("missing anchors: {} | {}", missing.join(","), counts_str);
523-
}
524-
525-
// anchors exist; do we have a valid chain under constraints?
526-
let chain = compute_chain(hits, max_per_anchor, constraints);
527-
if chain.is_none() {
528-
return format!(
529-
"anchors present but no valid SSU_end→58S_start→58S_end→LSU_start chain under constraints | {}",
530-
counts_str
531-
);
532-
}
533-
534-
let chain = chain.unwrap();
535-
if bounds_from_chain(&chain, region).is_none() {
536-
return format!(
537-
"chain found, but requested region {:?} bounds invalid (start>end) | {}",
538-
region, counts_str
539-
);
540-
}
541-
542-
// If we reach here, bounds *should* exist; this typically means downstream trimming failed (seq shorter than bounds).
543-
format!(
544-
"bounds exist logically but trimming failed (likely bounds exceed sequence length) | {}",
545-
counts_str
546-
)
547-
}
548-
549473
/// Structured version of `diagnose` returning a machine-readable `SkipReason`.
550474
pub fn diagnose_structured(
551475
hits: &[TblHit],

src/trim.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ struct RegionOutput {
170170
// Skip handling
171171
// ---------------------------------------------------------------------------
172172

173+
#[allow(clippy::too_many_arguments)]
173174
fn handle_skip(
174175
rec: &Record,
175176
topk_map: &HashMap<String, TopKHits>,

tests/extract_subset_from_tblout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ fn read_fasta_as_map(path: &std::path::Path) -> HashMap<String, String> {
4242
let mut seq = String::new();
4343

4444
for line in text.lines() {
45-
if line.starts_with('>') {
45+
if let Some(stripped) = line.strip_prefix('>') {
4646
if let Some(id) = cur_id.take() {
4747
map.insert(id, seq.clone());
4848
}
4949
seq.clear();
5050
// output header is like "READ|region:..." -> store by READ
51-
let header = line[1..].split_whitespace().next().unwrap();
51+
let header = stripped.split_whitespace().next().unwrap();
5252
let rid = header.split('|').next().unwrap().to_string();
5353
cur_id = Some(rid);
5454
} else {

0 commit comments

Comments
 (0)