def cyclic_find(subseq, alphabet=string.ascii_lowercase, n=None):
 if isinstance(subseq, (int, long)):
  width = ('all' if (n is None) else (n * 8))
  subseq = packing.pack(subseq, width, 'little', False)
 if ((n is None) and (len(subseq) != 4)):
  log.warn_once(((('cyclic_find() expects 4-byte subsequences by default, you gave %r\n' % subseq) + ('Unless you specified cyclic(..., n=%i), you probably just want the first 4 bytes.\n' % len(subseq))) + ('Truncating the data at 4 bytes.  Specify cyclic_find(..., n=%i) to override this.' % len(subseq))))
  subseq = subseq[:4]
 if any(((c not in alphabet) for c in subseq)):
  return (-1)
 n = (n or len(subseq))
 return _gen_find(subseq, de_bruijn(alphabet, n))

def cyclic_find ( subseq , alphabet = string . ascii_lowercase , n = None ) : if isinstance ( subseq , ( int , long ) ) : width = ( 'all' if ( n is None ) else ( n * 8 ) ) subseq = packing . pack ( subseq , width , 'little' , False ) if ( ( n is None ) and ( len ( subseq ) != 4 ) ) : log . warn_once ( ( ( ( 'cyclic_find() expects 4-byte subsequences by default, you gave %r\n' % subseq ) + ( 'Unless you specified cyclic(..., n=%i), you probably just want the first 4 bytes.\n' % len ( subseq ) ) ) + ( 'Truncating the data at 4 bytes.  Specify cyclic_find(..., n=%i) to override this.' % len ( subseq ) ) ) ) subseq = subseq [ : 4 ] if any ( ( ( c not in alphabet ) for c in subseq ) ) : return ( - 1 ) n = ( n or len ( subseq ) ) return _gen_find ( subseq , de_bruijn ( alphabet , n ) )
cyclic_find -> int calculates the position of a substring into a de bruijn sequence .