Entering edit mode
22 months ago
kristenammons2
▴
10
Hello everyone, I am trying to implement this method but failed to have the output answer. Can someone help me take a look what I could be missing? So basically, we have a string Genome, a Pattern, and integer of Overlap. We need to find number of matching occurrences of Pattern in Genome but with at most number of overlap. So the overlap between the Pattern can only be <= number of overlap to count.
I have attached the sample input and output, which is 2 but I lost at how to check for overlap within the string. Thank you for the feedback!
def PatternCountOverlap(Text, Pattern, overlap):
n = len(Text)
k = len(Pattern)
count = 0
for i in range(n-k+1): #iterate through the text
if Pattern == Text[i:i+k]:
count +=1 #count number of matching
##how to find with restriction of overlapping?
return count
print(PatternCountOverlap("GATATATATAC","ATATA",1)) #this would return 2, 1 is number of overlap restriction
Please do not paste screenshots of plain text content, it is counterproductive. You can copy paste the content directly here (using the code formatting option shown below), or use a GitHub Gist if the content volume exceeds allowed length here.
oh thanks, i will update it!
Also, there is no need for the
bioinformatics
tag (I've removed it) - every question on the site is related to bioinformatics.kristenammons2 : Please do not delete posts once they have received an answer or a comment. If the answer below solved your problem then accept it (green check mark) to provide closure for this thread.