-
Notifications
You must be signed in to change notification settings - Fork 3
chore: upstream cigar #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
flying-sheep
wants to merge
4
commits into
main
Choose a base branch
from
pa/cigar-to-st
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -323,7 +323,6 @@ pub fn align_read( | |
| } else { | ||
| "unknown" | ||
| }; | ||
| let cigar_str: String = t.cigar.iter().map(|op| format!("{}", op)).collect(); | ||
| eprintln!( | ||
| " transcript[{}]: chr={}:{}-{} ({}) score={} mm={} junctions={} cigar={}", | ||
| ti, | ||
|
|
@@ -334,7 +333,7 @@ pub fn align_read( | |
| t.score, | ||
| t.n_mismatch, | ||
| t.n_junction, | ||
| cigar_str | ||
| t.cigar_string() | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -356,14 +355,14 @@ pub fn align_read( | |
| a.genome_start, | ||
| a.genome_end, | ||
| a.is_reverse, | ||
| &a.cigar, | ||
| //&a.cigar, | ||
| ) | ||
| .cmp(&( | ||
| b.chr_idx, | ||
| b.genome_start, | ||
| b.genome_end, | ||
| b.is_reverse, | ||
| &b.cigar, | ||
| //&b.cigar, | ||
| )) | ||
| .then_with(|| b.score.cmp(&a.score)) | ||
| }); | ||
|
|
@@ -467,13 +466,13 @@ pub fn align_read( | |
|
|
||
| // Absolute matched bases | ||
| let n_matched = t.n_matched(); | ||
| if n_matched < params.out_filter_match_nmin { | ||
| if n_matched < params.out_filter_match_nmin as usize { | ||
| *filter_reasons.entry("match_min").or_insert(0) += 1; | ||
| return false; | ||
| } | ||
|
|
||
| // Relative matched bases: STAR casts to uint (u32) | ||
| if n_matched < (params.out_filter_match_nmin_over_lread * lread_m1) as u32 { | ||
| if (n_matched as f64) < params.out_filter_match_nmin_over_lread * lread_m1 { | ||
| *filter_reasons.entry("match_min_relative").or_insert(0) += 1; | ||
| return false; | ||
| } | ||
|
|
@@ -519,7 +518,6 @@ pub fn align_read( | |
| match motif.implied_strand() { | ||
| Some('+') => has_plus = true, | ||
| Some('-') => has_minus = true, | ||
| None => {} | ||
| _ => {} | ||
| } | ||
| } | ||
|
|
@@ -633,7 +631,6 @@ pub fn align_read( | |
| } else { | ||
| "unknown" | ||
| }; | ||
| let cigar_str: String = t.cigar.iter().map(|op| format!("{}", op)).collect(); | ||
| eprintln!( | ||
| " FINAL[{}]: chr={}:{}-{} ({}) score={} mm={} junctions={} cigar={}", | ||
| i, | ||
|
|
@@ -644,7 +641,7 @@ pub fn align_read( | |
| t.score, | ||
| t.n_mismatch, | ||
| t.n_junction, | ||
| cigar_str | ||
| t.cigar_string() | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -987,10 +984,9 @@ pub fn align_paired_read( | |
| if pos_cmp != std::cmp::Ordering::Equal { | ||
| return pos_cmp; | ||
| } | ||
| b.combined_wt_score | ||
| .cmp(&a.combined_wt_score) | ||
| .then_with(|| a.mate1_transcript.cigar.cmp(&b.mate1_transcript.cigar)) | ||
| .then_with(|| a.mate2_transcript.cigar.cmp(&b.mate2_transcript.cigar)) | ||
| b.combined_wt_score.cmp(&a.combined_wt_score) | ||
| //.then_with(|| a.mate1_transcript.cigar.cmp(&b.mate1_transcript.cigar)) | ||
| //.then_with(|| a.mate2_transcript.cigar.cmp(&b.mate2_transcript.cigar)) | ||
| }); | ||
| joint_pairs.dedup_by(|a, b| { | ||
| a.mate1_transcript.chr_idx == b.mate1_transcript.chr_idx | ||
|
|
@@ -1416,18 +1412,18 @@ fn extract_junctions_from_cigar(t: &Transcript) -> Vec<(u64, u64)> { | |
| let mut junctions = Vec::new(); | ||
| let mut genome_pos = t.genome_start; | ||
| for op in &t.cigar { | ||
| use crate::align::transcript::CigarOp; | ||
| match op { | ||
| CigarOp::Match(n) | CigarOp::Equal(n) | CigarOp::Diff(n) | CigarOp::Del(n) => { | ||
| genome_pos += *n as u64; | ||
| use noodles::sam::alignment::record::cigar::op::Kind; | ||
| match op.kind() { | ||
| Kind::Match | Kind::SequenceMatch | Kind::SequenceMismatch | Kind::Deletion => { | ||
| genome_pos += op.len() as u64; | ||
| } | ||
| CigarOp::RefSkip(n) => { | ||
| Kind::Skip => { | ||
| let donor = genome_pos; | ||
| let acceptor = genome_pos + *n as u64; | ||
| let acceptor = genome_pos + op.len() as u64; | ||
| junctions.push((donor, acceptor)); | ||
| genome_pos = acceptor; | ||
| } | ||
| CigarOp::Ins(_) | CigarOp::SoftClip(_) | CigarOp::HardClip(_) => {} | ||
| Kind::Insertion | Kind::SoftClip | Kind::HardClip | Kind::Pad => {} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added |
||
| } | ||
| } | ||
| junctions | ||
|
|
@@ -1479,6 +1475,7 @@ mod tests { | |
| use crate::index::sa_index::SaIndex; | ||
| use crate::index::suffix_array::SuffixArray; | ||
| use clap::Parser; | ||
| use noodles::sam::alignment::record::cigar; | ||
|
|
||
| fn make_test_params() -> Parameters { | ||
| // Parse empty args to get default parameters | ||
|
|
@@ -1537,8 +1534,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn combined_transcript_for_projection_rewrites_mate2_ifrag() { | ||
| use crate::align::transcript::CigarOp; | ||
|
|
||
| use cigar::op::{Kind, Op}; | ||
| let make_tr = |gs: u64, ge: u64, rs: usize, re: usize| Transcript { | ||
| chr_idx: 0, | ||
| genome_start: gs, | ||
|
|
@@ -1551,7 +1547,7 @@ mod tests { | |
| read_end: re, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match((ge - gs) as u32)], | ||
| cigar: vec![Op::new(Kind::Match, (ge - gs) as usize)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1654,7 +1650,8 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_check_proper_pair_distance() { | ||
| use crate::align::transcript::{CigarOp, Exon}; | ||
| use crate::align::transcript::Exon; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| let params = make_test_params(); | ||
|
|
||
|
|
@@ -1671,7 +1668,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1693,7 +1690,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1709,7 +1706,8 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_check_proper_pair_too_far() { | ||
| use crate::align::transcript::{CigarOp, Exon}; | ||
| use crate::align::transcript::Exon; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| let mut params = make_test_params(); | ||
| params.align_mates_gap_max = 100; | ||
|
|
@@ -1726,7 +1724,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1748,7 +1746,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1764,7 +1762,8 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_calculate_insert_size_positive() { | ||
| use crate::align::transcript::{CigarOp, Exon}; | ||
| use crate::align::transcript::Exon; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| // Mate1 is leftmost | ||
| let t1 = Transcript { | ||
|
|
@@ -1779,7 +1778,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1801,7 +1800,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1817,8 +1816,9 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_strand_consistency_filter() { | ||
| use crate::align::transcript::{CigarOp, Exon, Transcript}; | ||
| use crate::align::transcript::{Exon, Transcript}; | ||
| use crate::params::IntronStrandFilter; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| // Create a transcript with conflicting strand motifs (mixed + and - within one transcript) | ||
| let t_inconsistent = Transcript { | ||
|
|
@@ -1833,7 +1833,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1856,7 +1856,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1917,7 +1917,8 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_calculate_insert_size_negative() { | ||
| use crate::align::transcript::{CigarOp, Exon}; | ||
| use crate::align::transcript::Exon; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| // RF pair: mate1 reverse (right side), mate2 forward (left side). | ||
| // STAR reverse cluster: tlen = mate1.genome_end - mate2.genome_start = 1300 - 1000 = 300. | ||
|
|
@@ -1934,7 +1935,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1956,7 +1957,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -1973,7 +1974,8 @@ mod tests { | |
| #[test] | ||
| fn test_noncanonical_unannotated_filter() { | ||
| use crate::align::score::SpliceMotif; | ||
| use crate::align::transcript::{CigarOp, Exon, Transcript}; | ||
| use crate::align::transcript::{Exon, Transcript}; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| // Helper: check if a transcript would be filtered by RemoveNoncanonicalUnannotated | ||
| // (mirrors the logic in the retain closure) | ||
|
|
@@ -1996,7 +1998,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
@@ -2067,7 +2069,8 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_paired_alignment_result_enum_variants() { | ||
| use crate::align::transcript::{CigarOp, Exon}; | ||
| use crate::align::transcript::Exon; | ||
| use cigar::op::{Kind, Op}; | ||
|
|
||
| let transcript = Transcript { | ||
| chr_idx: 0, | ||
|
|
@@ -2081,7 +2084,7 @@ mod tests { | |
| read_end: 100, | ||
| i_frag: 0, | ||
| }], | ||
| cigar: vec![CigarOp::Match(100)], | ||
| cigar: vec![Op::new(Kind::Match, 100)], | ||
| score: 100, | ||
| n_mismatch: 0, | ||
| n_gap: 0, | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and another
cmpfarther down) are the only casualties: why is this here? Can a vector of cigar ops be “greater” or “less” than another? (other than length)