Skip to main content

Algorithm 3 Algorithm 3 Stem generation (independent of the alphabet size |Σ|)

From: Efficient motif finding algorithms for large-alphabet inputs

Input: pair of k-mers a, b
Output: set of stems (patterns with wildcards) shared by a and b
   if if d(a, b) ≤ m then
Set stem = a
Set i = 0 … d positions in the mismatch region of the stem as in b
Place j1 = 0 … di wildcards inside the mismatch region
Place j2 = 0 … m − max(di, j1 + i) wildcards outside the mismatch region
   end if
   if d(a, b) >m then
Set stem = a
Fix i = dmm positions in the mismatch region of the current stem as in b
Place j = 0 … mi wild-cards in the remaining di positions in the mismatch region
   end if
   Output resulting stems (patterns with wildcards)