I've been struggling to figure out a way to get my sequence printed out with a 6-mer in the sequence on separate lines. As so (note the spacing of each line):
atgctagtcatc
tgctag
gctagt
ctagtc
tagtca
etc
So far, I've been able to get my sequence in string as shown:
from Bio import SeqIO
record = SeqIO.read(open("testSeq.fasta"), "fasta")
sequence = str(record.seq)
However, the only way I could seem to figure out to do the printing of the 6-mers is by:
print sequence
print sequence[0:5]
print "", sequence[1:6]
print "", "", sequence[2:7]
print "", "", "", sequence [3:8]
etc
I feel like there should be an easier way to do this. I've tried this, but it doesn't seem to work:
x = 0
y = 6
for sequence in sequence[x:y]
print sequence
x = x + 1
y = y + 1
Any opinions on how I should be attempting to accomplish this task would be greatly appreciated. I've only been using python for a couple days now and I'm sorry if my question seems simple.
Thank you!!
""does not occupy any space when printed