Bad character rule: Upon mismatch ==> skip alignments until (a) the mismatch becomes a match or (b) pattern P moves past the mismatched char in text T Example 1: T: GCTTCTGCTACCTTTTGCGCGCGCGC P: CCTTTTGC ^ | mismatch T: GCTTCTGCTACCTTTTGCGCGCGCGC P: CCTTTTGC ^ | mismatch becomes a match Example 2: T: GCTTCTGCTACCTTTTGCGCGCGCGC P: CCTTTTGC ^ | mismatch (no A in P !) T: GCTTCTGCTACCTTTTGCGCGCGCGC P: CCTTTTGC ^ | P moves past the mismatched char in text T Bad suffix rule turns a mismatch into a match ======================================================================== Good suffix rule: Let t = substring matched by inned loop Upon mismatch ==> skip alignments until: (a) there are no mismatches between P and t or (You can use a SUFFIX of t in this match !) (b) P moves past t Example 1: t vvv T = CGTGCCTACTTACTTACTTACTTACGCGAA P = CTTACTTAC I.e.: shift P until you have another TAC vvv T = CGTGCCTACTTACTTACTTACTTACGCGAA P = CTTACTTAC ^^^ P and t match Example 2: t vvvvvvv T = CGTGCCTACTTACTTACTTACTTACGCGAA P = CTTACTTAC vvvvvvv T = CGTGCCTACTTACTTACTTACTTACGCGAA P = CTTACTTAC ^^^^^ P and t (suffix of t) match Good suffix rule tries to keep a match ============================================================================= How to use these rules: When you have a mismatch: (1) bad character rule tells you to shift k1 (2) good suffix rule tells you to shift k2 Shift max(k1, k2) Example 1: T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ^ mismatch Bad char rule: T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG Good suffix rule is void because t = EMPTY Example 2: t vvv T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ^ | mismatch Bad char rule: T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ^ | match, shift 1 Good suffix rule: t vvv T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ^^^ shift 3 Result: T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG We shift 3. Example 3: vvvvvv T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ^ | mismatch Bad char rule: T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ^ | mismatch Good suffix rule: vvvvvv T = GTTATAGCTGATCGCGGCGTAGCGGCGAA P = GTAGCGGCG ============================================================= ============================================================= Bad Match Table (BMT) P = kuyulayu ---> Unique: k u y l a 01234567 m = len(P) = 8 ^^^^^^^^ idx (use the LAST idx of a char) BMT: Char t (shift distance) = m - idx - 1 ================================ k 8-0-1=7 u 8-1-1=6, 8-3-1=4 y 8-2-1=5, 8-6-1=1 l 8-4-1=3 a 8-5-1=2 * m = 8 * = wild card, not char in table Last character shift distance: if (not exist before) t = m else (it exists) use the last computed shift value How to use the BMT: Bad Char Match shift distance d1: d1 = max{ 1, t(c) - k } t(c) in table k = # macthed characters before mismatch ===============================================================================