This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Locate for pattern in protein sequence with Biopython

Hello,

I am trying to find sequences that has a tripeptide. The tripeptide can have any other amino acids following it, except 'P'. I extracted them with the following way.

from Bio import SeqIO
RGD = [] 
for record in SeqIO.parse("input.fasta", "fasta"):
    rgd_count = record.seq.count('RGD')
    if rgd_count >= 1:
        RGD.append(record) 
SeqIO.write(RGD, "RGD_Proteins.fasta", "fasta")

How can I introduce regex in this such that, RGD(N) is fine except, RGDP ?

Thanks in advance.

AP

biopython fasta pattern matching

1 answer

You need the re module, see here for the documentation.

Log in to answer this question.