Entering edit mode
2.9 years ago
pablo
▴
310
Hello,
I want to create a splicing window from the beginnin and from the end on a fasta sequence. I will save the results on two separate files.
I have :
from Bio import SeqIO
with open("splicing_window.beginning.fasta","w") as f1, open("splicing_window.end.fasta","w") as f2:
for seq_record in SeqIO.parse("my_sequence.test.fasta", "fasta"):
for i in range(len(seq_record.seq) - 9) :
f1.write(">" + str(seq_record.id) + "\n")
f1.write(str(seq_record.seq[i:i+10]) + "\n")
f2.write(">" + str(seq_record.id) + "\n")
f2.write(str(seq_record.seq[:-i+10]) + "\n")
The problem is for the splicing window from the end. For example, if I have that sequence : TCCGCCGGAAGG ; I'd like to get an output f2 fasta file (window of 10nts) like that :
>1
CGCCGGAAGG
>2
CCGCCGGAAG
>3
TCCGCCGGAA
Any help? Best
Thanks a lot.
Updated the code again for better understanding.