Fuzzy search

Finds a query in DNA or protein allowing mismatches, or insertions and deletions.

Hits

What is a fuzzy sequence search?

An exact search answers "is this string there". A fuzzy search answers the question people usually have: "is anything close to it there, and how close". A primer with one mismatch still anneals, an sgRNA with three mismatches still cuts, a peptide motif survives a conservative substitution, and a sequencing read rarely matches the reference letter for letter. This page scans the whole sequence and reports every window within the number of differences you allow, on both strands for DNA.

Mismatches or edit distance?

Hamming distance = positions where the query and an equally long window differ
Edit distance = fewest substitutions, insertions and deletions that turn one into the other
Identity = (matched length − differences) / matched length

Mismatches compares the query with every window of exactly its own length. It is the right model for primer and probe annealing, for off-target search of a fixed-length guide RNA, and whenever positions must stay aligned. Overlapping windows are all reported.

With indels uses the Sellers algorithm, which is the Needleman-Wunsch recurrence with a free start and a free end in the searched sequence. A hit may then be shorter or longer than the query, which is what you want for indel-prone reads, homopolymer runs and short motifs in a diverged homologue. One hit is reported per region: the end position with the lowest distance.

Worked example

The DNA example searches a 240 nt sequence for the 20 nt primerAAACTTACCCTTAAATTTAT with up to 2 mismatches on both strands, and finds3 hits: a perfect one at 121 to 140, one with a single mismatch at 21 to 40 (AAACTTACCCTTGAATTTAT), and one with two mismatches at 191 to 210 on the minus strand. Set "Maximum differences" to 1 and the minus strand hit drops out.

The protein example searches an 85 residue sequence for the peptide KPEALVRQLTDA with up to 2 differences and finds 4 hits: exact at 7, one difference at 29, two at 51, and at 65 a copy that counts as two mismatches. Switch "Count" to "With indels" and that last hit is recognised for what it is: one deleted residue, distance 1, shown as KPEALVRQLT-A.

How many differences should I allow?

TaskQueryUsual allowance
PCR primer, off-target check18 to 25 nt2 to 3 mismatches
CRISPR guide, off-target check20 nt3 to 4 mismatches
Restriction or TF site variant6 to 12 nt1 mismatch
Peptide motif in a homologue8 to 15 aa2 to 3, indels on
Adapter or barcode in reads8 to 30 nt1 to 2, indels on

A useful check: a random DNA sequence of length L contains roughly L × 4−m × (number of ways to place the differences) copies of an m-long query. Allowing 4 mismatches in a 20 nt query already gives thousands of chance hits in a mammalian genome, so keep the allowance tight and make the query longer rather than the other way round.

Reading the results

  • Position is 1-based on the plus strand of the record, both ends included.
  • Strand is + for the sequence as given and − for its reverse complement; a minus strand hit is written the way it reads 5' to 3' on that strand.
  • Differences is the mismatch count or the edit distance, depending on the mode.
  • In the matched text the letters that differ from the query are marked. A hyphen means the query has a residue the sequence does not, so it is a deletion.
  • Ambiguity codes in the query are honoured, so an N never counts as a difference.

For an exact motif with IUPAC or PROSITE syntax use pattern find; for a full alignment of two sequences useSmith-Waterman orNeedleman-Wunsch; for repeated units use thetandem repeat finder.

Frequently asked questions

How do I search a sequence allowing mismatches?

Type the query in the query field, paste the sequence to search or choose a FASTA file, and set how many differences you will accept. Every window that is close enough is listed with its position, strand, number of differences and the matched text, with the differing letters marked.

What is the difference between mismatches and edit distance?

Counting mismatches (the Hamming distance) compares the query with a window of exactly the same length, letter by letter, so only substitutions are allowed. Edit distance (the Sellers algorithm) also allows insertions and deletions, so the match can be shorter or longer than the query. Use mismatches for primers and probes, edit distance when a residue may be missing.

Can I use ambiguity codes in the query?

Yes. On the DNA tab the IUPAC codes work, so N matches any base and R matches A or G, and a position that the code covers is not counted as a mismatch. On the protein tab X matches any residue, B matches D or N, Z matches E or Q and J matches L or I.

Why are overlapping hits reported in mismatch mode but not with indels?

In mismatch mode every window that is close enough is a hit, so a repeat can produce several hits one position apart. With indels the alignment score is followed along the sequence and only the best end position of each run is reported, which keeps one hit per region rather than a cluster around it.

How large a sequence can it search?

A megabase with a 30 nt query takes well under a second, and everything runs in your browser, so nothing is uploaded. The work grows with the length of the sequence multiplied by the length of the query, so a very long query against a very long sequence is refused with a note rather than freezing the page.