Guest User

Untitled

a guest
Jun 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. from string import *
  2. def stringgen():## Calling function.
  3.     target1 = 'atgacatgcacaagtatgcat'
  4.     target2 = 'atgaatgcatggatgtaaatgcag'
  5.     print target1,target2
  6.     a=find(target1,"atgc")
  7.     print a
  8.     countSubStringMatch(target1,"atgc")
  9.    
  10. def countSubStringMatch(target,key):
  11.                     ''' Finds the count for the number of matches of a substring'''
  12.      count=0
  13.      pointer=0
  14.      pointerlist=[]
  15.      print len(target)
  16.      
  17.      while(pointer<len(target)):
  18.          pointer=find(target[pointer:],key)# initially pointer zero, and then takes slices off the input string for further comparison
  19.          if pointer==-1:# No match scenario
  20.              break
  21.          if pointer!=-1:# Match scenario
  22.              pointerlist.append(pointer)# create a list of match locations
  23.              print pointer
  24.              count+=1
  25.              print target[pointer:]
  26.              raw_input()
  27.          pointer+=1# End of while loop , supposed to  cycle through input string but not happening, going into infinite loop , any idea why this could be happening? :?
  28.  
  29.      ## To print the list of locations with a match and the number of instances of match    
  30.      for i in pointerlist:
  31.          print 'List elements',i
  32.      print 'Count',count
Add Comment
Please, Sign In to add comment