get_pcr_product.py: allow 1 mismatch when evaluating primer amplification
pommevilla opened this issue · comments
Paul Villanueva commented
This SO answer should be informative, but I would like to avoid using BioPython to limit dependencies.
Also, while we're doing this, see about refactoring the lines below so that it uses a single re.finditer
expression instead of two:
MetaFunPrimer/src/get_pcr_product.py
Lines 66 to 86 in f1f6438
An example from the ISqPCR code I wrote for another app:
import re
forward_primer = replace_ambiguous_bases(forward_primer)
reverse_primer = reverse_complement(replace_ambiguous_bases(reverse_primer))
primer_pattern = re.compile('({}).*({})'.format(forward_primer, reverse_primer))
# for match in [match for match in re.finditer(primer_pattern, target_sequence)]:
for match in re.finditer(primer_pattern, target_sequence):
product = target_sequence[match.start():match.end()]
return '{}\t{}\t{}\t{}\t{}\t{}\n'.format(primer_name, target_name, match.start(), match.end(),
match.end() - match.start(), product)