Skip to content

Instantly share code, notes, and snippets.

@yousfiSaad
Last active February 25, 2019 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yousfiSaad/00b50db1aa973a71144443a73290b549 to your computer and use it in GitHub Desktop.
Save yousfiSaad/00b50db1aa973a71144443a73290b549 to your computer and use it in GitHub Desktop.
# 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