getPositions static method

List<int> getPositions(
  1. AminoAcidSequence seq,
  2. AminoAcidSequence target,
  3. bool compareOnlyType, {
  4. bool fuzzyComp = false,
})

(en) Returns a list of the indices of the beginning of the pattern where the specified pattern occurs.

(ja) 指定したパターンが出現する、パターンの先頭のインデックスをリストで返します。

  • seq : The sequence data.
  • target : The target pattern.
  • compareOnlyType : If true, compare only AminoAcid Type. If false, compare also AminoAcid.infoKey.
  • fuzzyComp : If true, Can contain B,Z,X,J.

Implementation

static List<int> getPositions(
    AminoAcidSequence seq, AminoAcidSequence target, bool compareOnlyType,
    {bool fuzzyComp = false}) {
  List<int> r = [];
  for (int i = 0; i <= seq.length() - target.length(); i++) {
    if (compareOnlyType) {
      if (UtilCompareAminoAcid.compareType(
          seq.subSeqNonInfo(i, i + target.length()), target, fuzzyComp)) {
        r.add(i);
      }
    } else {
      if (UtilCompareAminoAcid.compare(
          seq.subSeq(i, i + target.length()), target, fuzzyComp)) {
        r.add(i);
      }
    }
  }
  return r;
}