MCPcopy Create free account
hub / github.com/alignoth/alignoth / match_bases

Function match_bases

src/plot.rs:533–558  ·  view source on GitHub ↗

Matches a given read sequence against a given reference sequence and returning the result as Vec

(read_seq: &[char], ref_seq: &[char])

Source from the content-addressed store, hash-verified

531
532/// Matches a given read sequence against a given reference sequence and returning the result as Vec<InnerPlotCigar>
533fn 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
560fn clip_read(
561 mut record: rust_htslib::bam::record::Record,

Callers 2

from_cigarMethod · 0.85
test_matching_basesFunction · 0.85

Calls 2

into_iterMethod · 0.80
mapMethod · 0.45

Tested by 1

test_matching_basesFunction · 0.68