Include deletions as well as substituions and inserts.

One mis-match checking substitutions and inserts only:

$ time samtools view 7261_6.bam | python blooming_reads.py -c all_mito.fas -k 20 -m 1 -f sam -o /dev/null
Hashing circular references in all_mito.fas
Have 63695 unique k-mers before consider mis-matches/inserts
Adding 1 mis-matches per k-mer, have 3558411 unique k-mers
Adding inserts brings this to 6657783 unique k-mers
Set and bloom filter of 20-mers created (95955 k-mers considered, 6657783 unique)
Using Bloom filter with capacity 6657783 and error rate 0.01
Building filters took 18.2s
Processed 100000 reads, kept 7526 (7.5%), taken 3.9s (of which 3.1s in filter)
Processed 200000 reads, kept 14756 (7.4%), taken 7.7s (of which 6.1s in filter)
Processed 300000 reads, kept 22024 (7.3%), taken 11.6s (of which 9.2s in filter)
Processed 400000 reads, kept 29232 (7.3%), taken 15.5s (of which 12.3s in filter)
Processed 500000 reads, kept 36520 (7.3%), taken 19.4s (of which 15.4s in filter)
Processed 600000 reads, kept 43758 (7.3%), taken 23.3s (of which 18.5s in filter)
Processed 700000 reads, kept 50996 (7.3%), taken 27.1s (of which 21.5s in filter)
Processed 800000 reads, kept 57962 (7.2%), taken 31.0s (of which 24.7s in filter)
Processed 900000 reads, kept 64926 (7.2%), taken 34.9s (of which 27.7s in filter)
Processed 1000000 reads, kept 72210 (7.2%), taken 38.8s (of which 30.8s in filter)
Processed 1100000 reads, kept 79296 (7.2%), taken 42.7s (of which 33.9s in filter)
...

Including single base deletions as well:

$ time samtools view 7261_6.bam | python blooming_reads.py -c all_mito.fas -k 20 -m 1 -f sam -o /dev/null
Hashing circular references in all_mito.fas
Have 63695 unique k-mers before consider fuzzy matches
Adding 1 mis-matches per k-mer, have 3558411 unique k-mers
Adding inserts brings this to 6657783 unique k-mers
Adding deletions brings this to 7058741 unique k-mers
Set and bloom filter of 20-mers created (95955 k-mers considered, 7058741 unique)
Using Bloom filter with capacity 7058741 and error rate 0.01
Building filters took 21.0s
Processed 100000 reads, kept 7738 (7.7%), taken 3.9s (of which 3.1s in filter)
Processed 200000 reads, kept 15198 (7.6%), taken 7.8s (of which 6.3s in filter)
Processed 300000 reads, kept 22680 (7.6%), taken 11.7s (of which 9.4s in filter)
Processed 400000 reads, kept 30090 (7.5%), taken 15.6s (of which 12.5s in filter)
Processed 500000 reads, kept 37574 (7.5%), taken 19.5s (of which 15.6s in filter)
Processed 600000 reads, kept 45030 (7.5%), taken 23.4s (of which 18.7s in filter)
Processed 700000 reads, kept 52462 (7.5%), taken 27.2s (of which 21.8s in filter)
Processed 800000 reads, kept 59648 (7.5%), taken 31.1s (of which 24.9s in filter)
Processed 900000 reads, kept 66818 (7.4%), taken 35.0s (of which 28.0s in filter)
Processed 1000000 reads, kept 74314 (7.4%), taken 38.9s (of which 31.1s in filter)
Processed 1100000 reads, kept 81572 (7.4%), taken 42.8s (of which 34.3s in filter)
...
Avoid scanning reference FASTA files twice for deletions.

Old code (double scan of FASTA):

$ time samtools view 7261_6.bam | python blooming_reads.py -c all_mito.fas -k 20 -m 1 -f sam -o ~/dev/null
Hashing circular references in all_mito.fas
Have 63695 unique k-mers before consider fuzzy matches
Adding 1 mis-matches per k-mer, have 3558411 unique k-mers
Adding inserts brings this to 6657783 unique k-mers
Adding deletions brings this to 7058741 unique k-mers
Set and bloom filter of 20-mers created (95955 k-mers considered, 7058741 unique)
Using Bloom filter with capacity 7058741 and error rate 0.01
Building filters took 20.3s
Processed 100000 reads, kept 7738 (7.7%), taken 4.0s (of which 3.2s in filter)
Processed 200000 reads, kept 15198 (7.6%), taken 7.9s (of which 6.3s in filter)
Processed 300000 reads, kept 22680 (7.6%), taken 11.9s (of which 9.5s in filter)
Processed 400000 reads, kept 30090 (7.5%), taken 15.9s (of which 12.7s in filter)
Processed 500000 reads, kept 37574 (7.5%), taken 19.8s (of which 15.8s in filter)
Processed 600000 reads, kept 45030 (7.5%), taken 23.7s (of which 19.0s in filter)
Processed 700000 reads, kept 52462 (7.5%), taken 27.7s (of which 22.1s in filter)
Processed 800000 reads, kept 59648 (7.5%), taken 34.8s (of which 25.3s in filter)
Processed 900000 reads, kept 66818 (7.4%), taken 39.0s (of which 28.7s in filter)
Processed 1000000 reads, kept 74314 (7.4%), taken 43.0s (of which 31.8s in filter)
Processed 1100000 reads, kept 81572 (7.4%), taken 46.9s (of which 35.0s in filter)
...

New code (single scan of FASTA files):

$ time samtools view 7261_6.bam | python blooming_reads.py -c all_mito.fas -k 20 -m 1 -f sam -o /dev/null
Hashing circular references in all_mito.fas
Have 63695 unique k-mers before consider fuzzy matches
Adding deletions brings this to 567965 unique k-mers
Adding 1 mis-matches per k-mer, have 3959400 unique k-mers
Adding inserts brings this to 7058737 unique k-mers
Set and bloom filter of 20-mers created (95955 k-mers considered, 7058737 unique)
Using Bloom filter with capacity 7058737 and error rate 0.01
Building filters took 20.0s
Processed 100000 reads, kept 7738 (7.7%), taken 3.9s (of which 3.2s in filter)
Processed 200000 reads, kept 15198 (7.6%), taken 7.9s (of which 6.3s in filter)
Processed 300000 reads, kept 22680 (7.6%), taken 11.8s (of which 9.5s in filter)
Processed 400000 reads, kept 30090 (7.5%), taken 15.7s (of which 12.6s in filter)
Processed 500000 reads, kept 37574 (7.5%), taken 19.6s (of which 15.7s in filter)
Processed 600000 reads, kept 45030 (7.5%), taken 23.5s (of which 18.9s in filter)
Processed 700000 reads, kept 52462 (7.5%), taken 27.4s (of which 22.0s in filter)
Processed 800000 reads, kept 59648 (7.5%), taken 31.4s (of which 25.2s in filter)
Processed 900000 reads, kept 66818 (7.4%), taken 35.3s (of which 28.3s in filter)
Processed 1000000 reads, kept 74314 (7.4%), taken 39.2s (of which 31.5s in filter)
Processed 1100000 reads, kept 81572 (7.4%), taken 43.2s (of which 34.7s in filter)
...

i.e. Same counts, practically same speed on this example. But still, seems more elegant.