Matches a given read sequence against a given reference sequence and returning the result as Vec
(read_seq: &[char], ref_seq: &[char])
| 531 | |
| 532 | /// Matches a given read sequence against a given reference sequence and returning the result as Vec<InnerPlotCigar> |
| 533 | fn match_bases(read_seq: &[char], ref_seq: &[char]) -> Vec<InnerPlotCigar> { |
| 534 | let mut inner_plot_cigars = Vec::new(); |
| 535 | for (is_match, group) in &read_seq |
| 536 | .iter() |
| 537 | .zip_eq(ref_seq.iter()) |
| 538 | .chunk_by(|(read, reference)| read == reference) |
| 539 | { |
| 540 | if is_match { |
| 541 | inner_plot_cigars.push(InnerPlotCigar { |
| 542 | cigar_type: CigarType::Match, |
| 543 | bases: None, |
| 544 | length: Some(group.count() as u32), |
| 545 | }); |
| 546 | } else { |
| 547 | let substitutions = group.into_iter().map(|(r, _)| *r).collect_vec(); |
| 548 | for (length, base) in substitutions.iter().dedup_with_count() { |
| 549 | inner_plot_cigars.push(InnerPlotCigar { |
| 550 | cigar_type: CigarType::Sub, |
| 551 | bases: Some(vec![*base]), |
| 552 | length: Some(length as u32), |
| 553 | }) |
| 554 | } |
| 555 | }; |
| 556 | } |
| 557 | inner_plot_cigars |
| 558 | } |
| 559 | |
| 560 | fn clip_read( |
| 561 | mut record: rust_htslib::bam::record::Record, |