Last active
February 25, 2019 14:41
-
-
Save yousfiSaad/00b50db1aa973a71144443a73290b549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Input: Strings Genome and symbol | |
# Output: SymbolArray(Genome, symbol) | |
def SymbolArray(Genome, symbol): | |
n = len(Genome) | |
ns = len(symbol) | |
ext = Genome + Genome[ 0 : (n // 2) ] | |
tarray = [] | |
tmpsum = 0 | |
for i in range(n + n//2): | |
tmpsum = tmpsum + SymbolCompare(ext[i:i+ns], symbol) | |
tarray.append(tmpsum) | |
array = {} | |
for i in range(n): | |
array[i] = tarray[i + n//2 - ns] - tarray[i] + SymbolCompare(ext[i:i+ns], symbol) | |
return array | |
def SymbolCompare(Base, symbol): | |
if Base == symbol: | |
return 1 | |
else: | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment