text: user6537: Note: this question was also asked on biostars
  are you aware of any tool that is able to perform error-tolerant pattern-matching search on protein FASTA files?
  For example, I want to know, which proteins in my fasta file to matchADNG..C.G regexp (which represents ADNGCG pattern). However, I want to be tolerant to matching errors, meaning that I'm good with any protein that differs in any 1 letter in the motif: ADNG..C.D, ADNG..D.G, MDNG..C.G, etc are all good. Running all possible variants through grep is possible, but exponentially long for longer patterns (I usually have 15-20 letters in pattern, and scan ~10e6-7 sequences).
  I am aware of the tool agrep (docs. As far as I know, it's not supported anymore, and also does not distinguish letters in which it's allowed to make error. Also, it does not support long enough patterns (with more than 9 errors -- and yes, I tried to recompile it with myself from here and could not get it work). Also, it's not designed for proteins specifically.
  I am also aware of ScanProsite and Protein Pattern Find services. The first one is not error-prone, the second one is seems to be a web interface for grep.
  
  user6343: Python solution:
  e<=2 will allow up to 2 insertions, 2 deletions, or 2 SNPs in any 2 combinations
  import regex
  seq_list=["GGGAGGG", "GGGAAGGG", "GGGAAAGGG", "TTTATTT", "TTTAATTT", "TTTAAATTT", "GGGG", "GGG"]
  for sequence in seq_list:
      if regex.search("(GGGGGG|TTTTTT){e<=2}", sequence):
          print(sequence)
  
  GGGAGGG
  GGGAAGGG
  TTTATTT
  TTTAATTT
  GGGG  
  Can also include a wildcard
  seq_list=["GGGAAAAAGGG", "GGGAAAAATGG", "GGGAAAAATTG", "GGGAAAAATTT"]
  for sequence in seq_list:
      if regex.search("(GGG.*GGG|TTTTTT){e<=2}", sequence):
          print(sequence)
  
  GGGAAAAAGGG
  GGGAAAAATGG
  GGGAAAAATTG
  
original_text: 6537: <p><em>Note: this question was also asked on <a href="https://www.biostars.org/p/409111/#409142" rel="nofollow noreferrer">biostars</a></em></p>
  
  <p>are you aware of any tool that is able to perform error-tolerant pattern-matching search on protein FASTA files?</p>
  
  <p>For example, I want to know, which proteins in my fasta file to match<code>ADNG..C.G</code> regexp (which represents <code>ADNGCG</code> pattern). However, I want to be tolerant to matching errors, meaning that I'm good with any protein that differs in any 1 letter in the motif: <code>ADNG..C.D</code>, <code>ADNG..D.G</code>, <code>MDNG..C.G</code>, etc are all good. Running all possible variants through <code>grep</code> is possible, but exponentially long for longer patterns (I usually have <code>15-20</code> letters in pattern, and scan <code>~10e6-7</code> sequences).</p>
  
  <p>I am aware of the tool <code>agrep</code> (<a href="https://en.wikipedia.org/wiki/Agrep" rel="nofollow noreferrer">docs</a>. As far as I know, it's not supported anymore, and also does not distinguish letters in which it's allowed to make error. Also, it does not support long enough patterns (with more than 9 errors -- and yes, I tried to recompile it with myself from <a href="https://github.com/Wikinaut/agrep" rel="nofollow noreferrer">here</a> and could not get it work). Also, it's not designed for proteins specifically.</p>
  
  <p>I am also aware of <a href="https://prosite.expasy.org/scanprosite/" rel="nofollow noreferrer">ScanProsite</a> and <a href="https://www.bioinformatics.org/sms2/protein_pattern.html" rel="nofollow noreferrer">Protein Pattern Find</a> services. The first one is not error-prone, the second one is seems to be a web interface for <code>grep</code>.</p>
   6343: <p>Python solution:<br>
  e&lt;=2 will allow up to 2 insertions, 2 deletions, or 2 SNPs in any 2 combinations</p>
  
  <pre><code>import regex
  seq_list=["GGGAGGG", "GGGAAGGG", "GGGAAAGGG", "TTTATTT", "TTTAATTT", "TTTAAATTT", "GGGG", "GGG"]
  for sequence in seq_list:
      if regex.search("(GGGGGG|TTTTTT){e&lt;=2}", sequence):
          print(sequence)
  </code></pre>
  
  <p>GGGAGGG<br>
  GGGAAGGG<br>
  TTTATTT<br>
  TTTAATTT<br>
  GGGG  </p>
  
  <p>Can also include a wildcard</p>
  
  <pre><code>seq_list=["GGGAAAAAGGG", "GGGAAAAATGG", "GGGAAAAATTG", "GGGAAAAATTT"]
  for sequence in seq_list:
      if regex.search("(GGG.*GGG|TTTTTT){e&lt;=2}", sequence):
          print(sequence)
  </code></pre>
  
  <p>GGGAAAAAGGG<br>
  GGGAAAAATGG<br>
  GGGAAAAATTG</p>
  