difference method

int difference({
  1. required Sequence oSeq,
})

Returns the number of monomer differences between this sequence and oSeq.

Implementation

int difference({required Sequence oSeq}) {
  if (this._len != oSeq.len) {
    Errors.unequalSeqLens(func: 'difference');
  }
  if (this._type != oSeq.type) {
    Errors.unequalSeqTypes(func: 'difference');
  }

  int differenceCount = 0;
  this._seq.split('').asMap().forEach((idx, mon) {
    if (mon != oSeq.seq[idx]) {
      differenceCount++;
    }
  });
  return differenceCount;
}