from Bio import motifs
from Bio.Seq import Seq
data = [line.strip('\n') for line in open('sampledata.txt')]
instances =[Seq(data[1])]
m = motifs.create(instances)
sequence = Seq(data[0])
positions = ''
for pos, seq in m.instances.search(sequence):
positions += str(pos+1) + ' '
print(positions)
The function returns all the positions of the motifs, but it seems to have a different definition of the position than Rosalind. In order to receive the correct result I had to add 1 to all the positions, as you can see in line 9. I also added a blank space in this step to achieve the correct formatting.
No comments:
Post a Comment