/// Finds all contiguous ranges of private nucleotide deletions.
///
/// By contrast with nucleotide deletions (the `.deletions` field in the `AnalysisResult`), which are listed in the
/// form of ranges, private nucleotide deletions are listed
/// individually. We compute the ranges for private deletions here.
///
Finds all contiguous ranges of private nucleotide deletions.
By contrast with nucleotide deletions (the `.deletions` field in the `AnalysisResult`), which are listed in the
form of ranges, private nucleotide deletions are listed
individually. We compute the ranges for private deletions here.
Finds all contiguous ranges of private nucleotide deletions . By contrast with nucleotide deletions ( the ` . deletions ` field in the ` AnalysisResult ` ) which are listed in the form of ranges private nucleotide deletions are listed individually . We compute the ranges for private deletions here .
fn find_deletion_ranges(dels: &[NucDelMinimal]) -> Vec<NucRange> {
  if dels.is_empty() {
    return vec![];
  }
  let mut ranges = Vec::<NucRange>::new();
  let n_dels = dels.len();
  // if no gaps, return empty list of ranges
  if n_dels==0{
    return ranges
  }
  // init current range with length 1 and previous position at the first deletion
  let mut pos_prev = dels[0].pos as i64;
  let mut length = 1;
  // loop over all subsequent deletions
  for i in 1..n_dels {
    let pos_curr = dels[i].pos as i64;
    if pos_curr - pos_prev != 1 {
      // If the current position is not adjacent to the previous,
      // then close the current range (end is at previous gap+1)
      let begin = dels[i - length].pos;
      let end = dels[i - 1].pos + 1;
      ranges.push(NucRange {
        begin,
        end,
        letter: Nuc::Gap,
      });
      // Start a new range
      length = 1;
    } else {
      // Extend the current range
      length += 1;
    }
    pos_prev = pos_curr;
  }
  // close they last range
  let begin = dels[n_dels - length].pos;
  let end = dels[n_dels - 1].pos + 1;
  ranges.push(NucRange {
    begin,
    end,
    letter: Nuc::Gap,
  });
  ranges
}
fn find_deletion_ranges ( dels : & [ NucDelMinimal ] ) -> Vec < NucRange > { if dels . is_empty ( ) { return vec ! [ ] ; } let mut ranges = Vec :: < NucRange > :: new ( ) ; let n_dels = dels . len ( ) ; // if no gaps, return empty list of ranges if n_dels == 0 { return ranges } // init current range with length 1 and previous position at the first deletion let mut pos_prev = dels [ 0 ] . pos as i64 ; let mut length = 1 ; // loop over all subsequent deletions for i in 1 .. n_dels { let pos_curr = dels [ i ] . pos as i64 ; if pos_curr - pos_prev != 1 { // If the current position is not adjacent to the previous, // then close the current range (end is at previous gap+1) let begin = dels [ i - length ] . pos ; let end = dels [ i - 1 ] . pos + 1 ; ranges . push ( NucRange { begin , end , letter : Nuc :: Gap , } ) ; // Start a new range length = 1 ; } else { // Extend the current range length += 1 ; } pos_prev = pos_curr ; } // close they last range let begin = dels [ n_dels - length ] . pos ; let end = dels [ n_dels - 1 ] . pos + 1 ; ranges . push ( NucRange { begin , end , letter : Nuc :: Gap , } ) ; ranges }
Finds all contiguous ranges of private nucleotide deletions.
Finds all contiguous ranges of private nucleotide deletions .
dels
&[NucDelMinimal]