I have multiple sequences in a fasta file and I want to divide it into sliding window with window size 90 and step size 10. I have a python script as follows:
from Bio import SeqIO
with open("my90_out.txt","w") as f:
for seq_record in SeqIO.parse("myseq.fasta", "fasta"):
for i in range(len(seq_record.seq) - 9) :
f.writestrseq_record.id) + "\n")
f.write(str(seq_record.seq[i:i+90]) + "\n")
i
The code produces sequences with window size 90 but step size 1. I need to change the step size to 10. I know I have made a blunder in the for loop. Thanks in advance for the help.
See this script, try to change your step size accordingly:
How to extract short sequence from FASTA file with certain step size?