Advertisement
DeaD_EyE

silly_generator_subseq_matching

Aug 16th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. def find_subseq(seq, subseq, idx=0, end=None):
  2.     subseq_len = len(subseq)
  3.     while True:
  4.         idx = seq.find(subseq, idx)
  5.         if idx == -1:
  6.             break
  7.         if end is not None and idx > (end - subseq_len):
  8.             break
  9.         yield idx
  10.         idx +=1
  11.  
  12. seq = 'ACAATGGGAGAGTCCATTCTACAATGGGAGAGTCCATTCT'
  13. subseq1 = 'AC'
  14. subseq2 = 'AT'
  15.  
  16. match1 = list(find_subseq(seq,subseq1))
  17. match2 = list(find_subseq(seq,subseq2))
  18. match3 = list(find_subseq(seq,subseq2, 3, 25))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement