Creates a detailed PlotCigar from a given rust_htslib CigarStringView
(
cigar: CigarStringView,
read_seq: Vec<char>,
ref_seq: Vec<char>,
)
| 490 | impl PlotCigar { |
| 491 | /// Creates a detailed PlotCigar from a given rust_htslib CigarStringView |
| 492 | fn from_cigar( |
| 493 | cigar: CigarStringView, |
| 494 | read_seq: Vec<char>, |
| 495 | ref_seq: Vec<char>, |
| 496 | ) -> Result<PlotCigar> { |
| 497 | let mut inner_plot_cigars = Vec::new(); |
| 498 | let (mut read_index, mut ref_index) = (0, 0); |
| 499 | for c in &cigar { |
| 500 | match c { |
| 501 | Cigar::Match(length) | Cigar::SoftClip(length) => { |
| 502 | inner_plot_cigars.extend(match_bases( |
| 503 | &read_seq[read_index..read_index + *length as usize], |
| 504 | &ref_seq[ref_index..ref_index + *length as usize], |
| 505 | )); |
| 506 | read_index += *length as usize; |
| 507 | ref_index += *length as usize; |
| 508 | } |
| 509 | Cigar::Ins(length) => { |
| 510 | inner_plot_cigars.push(InnerPlotCigar { |
| 511 | cigar_type: CigarType::Ins, |
| 512 | bases: Some(read_seq[read_index..read_index + *length as usize].to_vec()), |
| 513 | length: None, |
| 514 | }); |
| 515 | read_index += *length as usize; |
| 516 | } |
| 517 | Cigar::Del(length) => { |
| 518 | inner_plot_cigars.push(InnerPlotCigar { |
| 519 | cigar_type: CigarType::Del, |
| 520 | bases: None, |
| 521 | length: Some(*length), |
| 522 | }); |
| 523 | ref_index += *length as usize; |
| 524 | } |
| 525 | _ => {} |
| 526 | } |
| 527 | } |
| 528 | Ok(PlotCigar(inner_plot_cigars)) |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | /// Matches a given read sequence against a given reference sequence and returning the result as Vec<InnerPlotCigar> |
nothing calls this directly
no test coverage detected