+ 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?

18th Aug 2018, 10:54 AM
Symon
Symon - avatar
6 Respuestas
+ 3
You can use re module.re means regular expression.It is mostly used for search string,numbers or compare something etc.
18th Aug 2018, 12:07 PM
Maninder $ingh
Maninder $ingh - avatar
+ 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
18th Aug 2018, 1:27 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 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
18th Aug 2018, 1:36 PM
Symon
Symon - avatar
+ 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'))
18th Aug 2018, 2:20 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
Ulisses Thanks for that help.
18th Aug 2018, 2:24 PM
Symon
Symon - avatar
0
Anyone with different ideas on my gene sequence search code ? (like in the comments)?
18th Aug 2018, 4:30 PM
Symon
Symon - avatar