## BioBrick compatibility tool v 0.9b 01.06.12 def readseq (f) : lseq = f.readlines() s = "" k = 0 while k < len(lseq) : if lseq[k][0] == ">" : lseq.remove(lseq[k]) lseq[k] = lseq[k].replace("\n", "") k += 1 #print lseq for i in lseq : s += i s = s.replace("\W", "") s = s.replace(" ", "") #print s return s def sites6 (s) : index = {} cons = ["GAATTC", "TCTAGA", "ACTAGT", "CTGCAG"] i=0 while i < (len(s)-5) : if s[i:i+6] in cons : index[s[i:i+6]] = i i += 1 return index def sites8 (s) : index8 = {} cons = ["GCGGCCGC"] i=0 while i < (len(s)-7) : if s[i:i+8] in cons : index8[s[i:i+8]] = i i += 1 return index8 def prefsuffix(seq) : pATG = "gaattcgcggccgcttctag" p = "gaattcgcggccgcttctagag" s = "tactagtagcggccgctgcag" s1 = "" if seq[0:3] == "ATG" : s1 = pATG + seq + s else : s1 = p + seq + s return s1 f = open("./seq.fasta") s = readseq(f) six = sites6(s) eight = sites8(s) f=open('./output.txt', 'w') restrictionsites = { "GAATTC":"EcoRI", "TCTAGA":"XbaI", "ACTAGT":"SpeI", "CTGCAG":"PstI", "GCGGCCGC":"NotI"} if (not six) and (not eight) : f.write(prefsuffix(s) + "\n") print "The sequence is OK. Prefix and suffix have been added. Check the output.txt file in the folder of this script to get the results. " else: for i in six.keys(): out = "There's a " + i +" ("+restrictionsites[i]+") at position " + str(six[i]) + ".\n" f.write(out) for i in eight.keys(): out = "There's a " + i +" ("+restrictionsites[i]+") at position " + str(eight[i]) + ".\n" f.write(out) print "There are some forbidden restriction sites. Check the output.txt file in the folder of this script to get the results. " f.close()