Primer matching with sequence using biopython
1
I have two primers forward and reverse and i also have a gene sequence file. I want to match the primer with the sequence and then chopped the bases that comes between the primers. Can anyone help me out this?
I need a script that i can perform on jupyternote book and by using biopython.
Thank you
primers
Biopython
alignment
• 1.4k views
I presume what you want to do is extract the sequence encapsulated by your primers?
Here's a little function that'll help.
You'll need the re
and random
modules for this.
#Function definition.
def ext_primer_seq(seq, fwd, rev):
regstr = r"(?<=" + fwd + r")" + r"[ATGCN\.\*]*" + r"(?=" + rev + r")"
myregex = re.compile(regstr)
return(myregex.findall(seq))
#Example run.
fwd = "GTACC"
rev = "CAGGG"
seq = ''.join(random.choices(['A', 'T', 'G', 'C'], k = 50)) + fwd + ''.join(random.choices(['A', 'T', 'G', 'C'], k = 10)) + rev + ''.join(random.choices(['A', 'T', 'G', 'C'], k = 25))
print(seq)
#'GAGTAGCAAGCCACGCGCGTTCTCGACCATCCATAACAAAGCCAAGACGGGTACCCGATACTTTTCAGGGCAGCAAAAGCACGTATCCGCCGGGC'
ext_primer_seq(seq, fwd, rev)
#['CGATACTTTT']
Does this help?
Login before adding your answer.
Traffic: 2601 users visited in the last hour