# written by Vaibhav Pant on 2 Dec, 2015 file=open('seq2.txt','r') file_line=file.readlines() sequence=file_line[1] #sequence='GACCATCAAAACTGATAAACTACTTAAAAATCAGT' # manually added sequence #sequence=raw_input('gcgcg') print sequence target=file_line[2] print 'Target sequence is, ', target #target='AAA' # manual target file.close() ##------------------------------------------------------------------ ## Important Only if reading from file and using read lines. It takes into account "enter" as one character so we need to remove that sequence=sequence[0:len(sequence)-1] target=target[0:len(target)-1] ##------------------------------------------------------------- # breaking seuence in individual alphabets #char=list(sequence) # no need for making list as the sequence is already in array seq_lim=len(sequence) tar_lim=len(target) print seq_lim,tar_lim count=0 for i in range(0,seq_lim-tar_lim+1): # 1 is added because we need to add take last string into account if target in (sequence[i:tar_lim+i]): count = count+1 #for j in range(0,tar_lim): # if target[j] print 'Total target sequence which match are : ', count