I found another way to check if the primer is unique.
for k in range(0,len(genome)):
while True:
mer=substring(genome[k])
if len(check(mer,genome))>1:
continue
elif check(mer,genome)[0]!=k:
continue
else:
break
primer.append(mer)
This new method to check uniqueness of the primer is quite different from the previous one.
I was always thinking in a way to search the substring (primer sequence) in other genome sequences and delete it if it is also present in other genomes. The flow were like this:
1. suggest a primer from genome[i]
2. store it in the primer list as primer[i]
3. check if primer[i] is present in other genomes except genome[i]
4. delete it if yes and go back to 1
while in the new method, the flow control were like this:
1.suggest a primer from genome[i]
2.assign the primer to a string(dose not store it in the primer list immediately)
3.search the string in the genome list including genome[i] and return the found index in a new list
4.if the length of index list is larger than 2, go back to 1
5.if the length of index list is 1, check if the only element is equal to i. if no, go back to 1. if yes, assign the primer to the primer list.
While there is problem in the new method, all the genomes must have unique perimers. If any of them does not, the program is endless. The solution could be that the program will check all genomes before suggesting the unique primer.