I am using Biopython to process an alignment in fasta format. I need to slice the sequences where there is the first stop codon. So I divided my alignment in codons and found the stop.
I then found the first codon position using enumerate().
But I found the minimum for each row. However I need to find the minimum (storing it where it won't be reset when it does the next row), determine which of those is smallest. So that I can slice all the sequences in the same place.
from Bio import AlignIO
stop = ["TAA"]
alignment = AlignIO.read('/Users/....', 'fasta')
for row in alignment:
codons=[]
codons = [str(row.seq[i:i+3]) for i in range(0,len(row.seq),3)]
pstop = min([x for x,y in enumerate(codons) if y in stop])
print pstop
pstop gives me the min for each row and I want to get the min of those min
to slice everything according to that min.
Thanks you very much for your help!