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
13 changes: 4 additions & 9 deletions src/align/read_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub fn align_read(

if seeds.is_empty() {
if debug_read {
eprintln!("[DEBUG {}] No seeds found — unmapped", read_name);
eprintln!("[DEBUG {read_name}] No seeds found — unmapped");
}
return Ok((Vec::new(), Vec::new(), 0, Some(UnmappedReason::Other)));
}
Expand Down Expand Up @@ -266,7 +266,7 @@ pub fn align_read(

if clusters.is_empty() {
if debug_read {
eprintln!("[DEBUG {}] No clusters — unmapped", read_name);
eprintln!("[DEBUG {read_name}] No clusters — unmapped");
}
return Ok((Vec::new(), Vec::new(), 0, Some(UnmappedReason::Other)));
}
Expand Down Expand Up @@ -525,11 +525,7 @@ pub fn align_read(
if pre_filter_count > transcripts.len() {
let filtered = pre_filter_count - transcripts.len();
log::debug!(
"Read {}: Filtered {}/{} transcripts: {:?}",
read_name,
filtered,
pre_filter_count,
filter_reasons
"Read {read_name}: Filtered {filtered}/{pre_filter_count} transcripts: {filter_reasons:?}"
);
}

Expand Down Expand Up @@ -2165,8 +2161,7 @@ mod tests {
}
assert!(
firsts.len() >= 2,
"expected different seeds to pick different primaries, got {:?}",
firsts
"expected different seeds to pick different primaries, got {firsts:?}"
);
}

Expand Down
5 changes: 2 additions & 3 deletions src/align/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ mod tests {
fn make_test_index(sequence: &str) -> GenomeIndex {
let mut file = NamedTempFile::new().unwrap();
writeln!(file, ">chr1").unwrap();
writeln!(file, "{}", sequence).unwrap();
writeln!(file, "{sequence}").unwrap();

let dir = tempfile::tempdir().unwrap();

Expand Down Expand Up @@ -888,8 +888,7 @@ mod tests {
// R→L search should find seeds because RC(read) = AACCTTGG matches genome
assert!(
!rc_seeds.is_empty(),
"R→L search should find seeds (RC of read matches genome). All seeds: {:?}",
seeds
"R→L search should find seeds (RC of read matches genome). All seeds: {seeds:?}"
);

// Verify R→L seeds have valid read positions
Expand Down
10 changes: 5 additions & 5 deletions src/chimeric/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ impl<'a> ChimericDetector<'a> {
}

let donor_seg = transcript_to_segment(tr_donor)
.map_err(|e| Error::Chimeric(format!("soft-clip donor: {}", e)))?;
.map_err(|e| Error::Chimeric(format!("soft-clip donor: {e}")))?;
let acceptor_seg = transcript_to_segment(tr_acceptor)
.map_err(|e| Error::Chimeric(format!("soft-clip acceptor: {}", e)))?;
.map_err(|e| Error::Chimeric(format!("soft-clip acceptor: {e}")))?;

let (repeat_len_donor, repeat_len_acceptor) = calculate_repeat_length(
&index.genome,
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<'a> ChimericDetector<'a> {
};

let new_seg = transcript_to_segment(&clip_tr)
.map_err(|e| Error::Chimeric(format!("tier3 segment: {}", e)))?;
.map_err(|e| Error::Chimeric(format!("tier3 segment: {e}")))?;

// Donor / acceptor ordered by read position
let (donor_seg, acceptor_seg): (&ChimericSegment, &ChimericSegment) =
Expand Down Expand Up @@ -897,9 +897,9 @@ pub fn detect_chimeric_old(

// Build chimeric segments
let donor_seg = transcript_to_segment(tr_donor)
.map_err(|e| Error::Chimeric(format!("chimeric donor segment: {}", e)))?;
.map_err(|e| Error::Chimeric(format!("chimeric donor segment: {e}")))?;
let acceptor_seg = transcript_to_segment(tr_acceptor)
.map_err(|e| Error::Chimeric(format!("chimeric acceptor segment: {}", e)))?;
.map_err(|e| Error::Chimeric(format!("chimeric acceptor segment: {e}")))?;

// Minimum segment length check
if !donor_seg.meets_min_length(params.chim_segment_min)
Expand Down
26 changes: 6 additions & 20 deletions src/chimeric/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,9 @@ impl ChimericJunctionWriter {
// Write line
writeln!(
self.writer,
"{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}",
donor_chr,
donor_bp,
donor_strand,
acceptor_chr,
acceptor_bp,
acceptor_strand,
junction_type,
repeat_donor,
repeat_acceptor,
read_name,
donor_start,
donor_cigar,
acceptor_start,
acceptor_cigar,
"{donor_chr}\t{donor_bp}\t{donor_strand}\t{acceptor_chr}\t{acceptor_bp}\t{acceptor_strand}\t{junction_type}\t{repeat_donor}\t{repeat_acceptor}\t{read_name}\t{donor_start}\t{donor_cigar}\t{acceptor_start}\t{acceptor_cigar}",
)
.map_err(|e| Error::Chimeric(format!("Failed to write chimeric junction: {}", e)))?;
.map_err(|e| Error::Chimeric(format!("Failed to write chimeric junction: {e}")))?;

Ok(())
}
Expand All @@ -109,7 +95,7 @@ impl ChimericJunctionWriter {
pub fn flush(&mut self) -> Result<(), Error> {
self.writer
.flush()
.map_err(|e| Error::Chimeric(format!("Failed to flush chimeric junction file: {}", e)))
.map_err(|e| Error::Chimeric(format!("Failed to flush chimeric junction file: {e}")))
}
}

Expand Down Expand Up @@ -200,7 +186,7 @@ fn build_segment_record(
let pos = (seg.genome_start - chr_start + 1) as usize;
*record.alignment_start_mut() = Some(
pos.try_into()
.map_err(|e| Error::Chimeric(format!("invalid chimeric position {}: {}", pos, e)))?,
.map_err(|e| Error::Chimeric(format!("invalid chimeric position {pos}: {e}")))?,
);

*record.mapping_quality_mut() = MappingQuality::new(mapq);
Expand Down Expand Up @@ -549,7 +535,7 @@ mod tests {
// Donor record's SA tag should point to acceptor
let sa_tag = Tag::new(b'S', b'A');
let donor_sa = records[0].data().get(&sa_tag).unwrap();
let donor_sa_str = format!("{:?}", donor_sa);
let donor_sa_str = format!("{donor_sa:?}");
// SA tag: chr22,89,-,37M,255,1; (pos = 600-512+1=89, strand=-, nm=1)
assert!(
donor_sa_str.contains("chr22"),
Expand All @@ -566,7 +552,7 @@ mod tests {

// Acceptor record's SA tag should point to donor
let acceptor_sa = records[1].data().get(&sa_tag).unwrap();
let acceptor_sa_str = format!("{:?}", acceptor_sa);
let acceptor_sa_str = format!("{acceptor_sa:?}");
assert!(
acceptor_sa_str.contains("chr9"),
"SA tag must name donor chr"
Expand Down
10 changes: 5 additions & 5 deletions src/genome/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,30 +210,30 @@ impl Genome {
let chr_name_path = dir.join("chrName.txt");
let mut f = fs::File::create(&chr_name_path).map_err(|e| Error::io(e, &chr_name_path))?;
for name in &self.chr_name {
writeln!(f, "{}", name).map_err(|e| Error::io(e, &chr_name_path))?;
writeln!(f, "{name}").map_err(|e| Error::io(e, &chr_name_path))?;
}

// Write chrLength.txt
let chr_length_path = dir.join("chrLength.txt");
let mut f =
fs::File::create(&chr_length_path).map_err(|e| Error::io(e, &chr_length_path))?;
for &len in &self.chr_length {
writeln!(f, "{}", len).map_err(|e| Error::io(e, &chr_length_path))?;
writeln!(f, "{len}").map_err(|e| Error::io(e, &chr_length_path))?;
}

// Write chrStart.txt (includes the extra n_genome entry)
let chr_start_path = dir.join("chrStart.txt");
let mut f = fs::File::create(&chr_start_path).map_err(|e| Error::io(e, &chr_start_path))?;
for &start in &self.chr_start {
writeln!(f, "{}", start).map_err(|e| Error::io(e, &chr_start_path))?;
writeln!(f, "{start}").map_err(|e| Error::io(e, &chr_start_path))?;
}

// Write chrNameLength.txt (tab-separated)
let chr_name_length_path = dir.join("chrNameLength.txt");
let mut f = fs::File::create(&chr_name_length_path)
.map_err(|e| Error::io(e, &chr_name_length_path))?;
for (name, &len) in self.chr_name.iter().zip(&self.chr_length) {
writeln!(f, "{}\t{}", name, len).map_err(|e| Error::io(e, &chr_name_length_path))?;
writeln!(f, "{name}\t{len}").map_err(|e| Error::io(e, &chr_name_length_path))?;
}

// Write genomeParameters.txt — byte-for-byte matching STAR's
Expand Down Expand Up @@ -319,7 +319,7 @@ impl Genome {
.sjdb_gtf_file
.as_ref()
.map_or_else(|| "-".to_string(), |p| p.display().to_string());
writeln!(f, "sjdbGTFfile\t{}", gtf_str).map_err(|e| Error::io(e, &path))?;
writeln!(f, "sjdbGTFfile\t{gtf_str}").map_err(|e| Error::io(e, &path))?;
writeln!(f, "sjdbGTFchrPrefix\t-").map_err(|e| Error::io(e, &path))?;
writeln!(f, "sjdbGTFfeatureExon\texon").map_err(|e| Error::io(e, &path))?;
writeln!(f, "sjdbGTFtagExonParentTranscript\ttranscript_id")
Expand Down
2 changes: 1 addition & 1 deletion src/index/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn load_genome(genome_dir: &Path, _params: &Parameters) -> Result<Genome, Error>
let chr_name_path = genome_dir.join("chrName.txt");
let chr_name_contents =
std::fs::read_to_string(&chr_name_path).map_err(|e| Error::io(e, &chr_name_path))?;
let chr_name: Vec<String> = chr_name_contents.lines().map(|s| s.to_string()).collect();
let chr_name: Vec<String> = chr_name_contents.lines().map(ToString::to_string).collect();

let chr_length_path = genome_dir.join("chrLength.txt");
let chr_length_contents =
Expand Down
13 changes: 4 additions & 9 deletions src/index/sa_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ impl SaIndex {
let num_indices = Self::calculate_num_indices(nbases);

log::info!(
"Building SA index: nbases={}, num_indices={}, word_length={}",
nbases,
num_indices,
word_length
"Building SA index: nbases={nbases}, num_indices={num_indices}, word_length={word_length}"
);

// Initialize packed array with "absent" markers
Expand Down Expand Up @@ -258,7 +255,7 @@ mod tests {
fn make_test_index_with_sa(sequence: &str, bin_nbits: u32, sa_nbases: u32) -> (SaIndex, usize) {
let mut file = NamedTempFile::new().unwrap();
writeln!(file, ">test").unwrap();
writeln!(file, "{}", sequence).unwrap();
writeln!(file, "{sequence}").unwrap();

let bin_nbits_str = bin_nbits.to_string();
let sa_nbases_str = sa_nbases.to_string();
Expand Down Expand Up @@ -423,13 +420,11 @@ mod tests {
let (new_sa_start, _, matched_level, _) = new_result.unwrap();
assert_eq!(
new_sa_start, old_sa_pos as usize,
"SA start should match for k-mer {}",
kmer_idx
"SA start should match for k-mer {kmer_idx}"
);
assert_eq!(
matched_level, 2,
"Should match at full level for k-mer {}",
kmer_idx
"Should match at full level for k-mer {kmer_idx}"
);
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/index/suffix_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ impl SuffixArray {

let sa_length = suffixes.len();
log::info!(
"Building suffix array with {} entries (gstrand_bit={}, word_length={})",
sa_length,
gstrand_bit,
word_length
"Building suffix array with {sa_length} entries (gstrand_bit={gstrand_bit}, word_length={word_length})"
);

// Sort suffixes using custom comparator
Expand Down Expand Up @@ -218,7 +215,7 @@ mod tests {
fn make_test_genome(sequence: &str, bin_nbits: u32) -> Genome {
let mut file = NamedTempFile::new().unwrap();
writeln!(file, ">test").unwrap();
writeln!(file, "{}", sequence).unwrap();
writeln!(file, "{sequence}").unwrap();

let bin_nbits_str = bin_nbits.to_string();
let args = vec![
Expand Down
5 changes: 2 additions & 3 deletions src/io/bam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ fn write_bam_header_lenient<W: Write>(
.map_err(|_| Error::Index("BAM reference count exceeds i32::MAX".into()))?;
writer.write_i32::<LittleEndian>(n_ref)?;
for (name, rs) in refs {
let c_name = CString::new(name.to_vec()).map_err(|e| {
Error::Index(format!("reference name contains interior NUL byte: {}", e))
})?;
let c_name = CString::new(name.to_vec())
.map_err(|e| Error::Index(format!("reference name contains interior NUL byte: {e}")))?;
let name_bytes = c_name.as_bytes_with_nul();
let l_name = u32::try_from(name_bytes.len()).map_err(|_| {
Error::Index(format!(
Expand Down
6 changes: 3 additions & 3 deletions src/io/fastq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl FastqReader {
.map_err(|e| {
Error::from(std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("invalid UTF-8 in read name: {}", e),
format!("invalid UTF-8 in read name: {e}"),
))
})?
.to_string();
Expand Down Expand Up @@ -672,7 +672,7 @@ mod tests {
fn test_paired_batch_reading() {
let mut tmpfile1 = NamedTempFile::new().unwrap();
for i in 1..=5 {
writeln!(tmpfile1, "@read{}/1", i).unwrap();
writeln!(tmpfile1, "@read{i}/1").unwrap();
writeln!(tmpfile1, "ACGT").unwrap();
writeln!(tmpfile1, "+").unwrap();
writeln!(tmpfile1, "IIII").unwrap();
Expand All @@ -681,7 +681,7 @@ mod tests {

let mut tmpfile2 = NamedTempFile::new().unwrap();
for i in 1..=5 {
writeln!(tmpfile2, "@read{}/2", i).unwrap();
writeln!(tmpfile2, "@read{i}/2").unwrap();
writeln!(tmpfile2, "GGCC").unwrap();
writeln!(tmpfile2, "+").unwrap();
writeln!(tmpfile2, "JJJJ").unwrap();
Expand Down
Loading
Loading