+ 1
Boyer Moore Search Algorithms
I have this code. https://code.sololearn.com/chkag9A6n5oy/?ref=app I want the code to find the Pattern (P) from the Text (T). When the program finds a match, it should print the match. What function do I need to add or remove or modify?
6 Réponses
+ 3
You can use re module.re means regular expression.It is mostly used for search string,numbers or compare something etc.
+ 1
To search for a string inside another string you do not need regular expression.
You can just do:
T = 'abacaabadcabacabaabb'
P = 'abacab'
def in_str(P, T):
if P in T: return P
return -1
EDITED:
But I guess that is not the answer you are looking for.
Here is a link to wikipedia explaining the algorithm:
https://en.m.wikipedia.org/wiki/Boyer–Moore_string-search_algorithm
+ 1
You have been of great help.
I have another code in the link below, to search for genes in a genome in two reading frames: forward and reverse strand. the length of the sequence should be divisible by 3. a gene sequence starts from start codon "ATG" and ends with stop codons "TAG" or "TAA" or "TGA".
I used regular expressions but am having trouble to extract the sequence
https://code.sololearn.com/cI5EsEAEHGcq/?ref=app
+ 1
Symon if you want to see the matches us the print function:
import re
pattern = re.compile(r'ATG((?:[ATG]{3})+?)(?:TAG|TAA|TGA)')
print(pattern.findall ('TTATGTTTTAAGGATGGGGCGTTAGTT'))
print(pattern.findall ('TGTGTGTATAT'))
+ 1
Ulisses Thanks for that help.
0
Anyone with different ideas on my gene sequence search code ? (like in the comments)?