#NEWLINE# def orthoCoding( strs , grams = 2 , sep = None ) : #NEWLINE# #INDENT# if ( not np . iterable ( grams ) ) : #NEWLINE# #INDENT# grams = [ grams ] #NEWLINE# #UNINDENT# result = [ ] #NEWLINE# for str in strs : #NEWLINE# #INDENT# cues = [ ] #NEWLINE# str = list ( str ) #NEWLINE# for n in grams : #NEWLINE# #INDENT# if ( n > 1 ) : #NEWLINE# #INDENT# seq = ( ( [ '#' ] + str ) + [ '#' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# seq = str #NEWLINE# #UNINDENT# count = max ( 0 , ( ( len ( seq ) - n ) + 1 ) ) #NEWLINE# cues . extend ( ( '' . join ( seq [ i : ( i + n ) ] ) for i in xrange ( count ) ) ) #NEWLINE# #UNINDENT# if sep : #NEWLINE# #INDENT# result . append ( sep . join ( cues ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result . append ( tuple ( cues ) ) #NEWLINE# #UNINDENT# #UNINDENT# return result