import re from string import * cut_site = [None, None, None, None, None]; #will be populated with [restriction, location] sites = [None,None,None,None,None]; #will be populated with restrictions found in the plasmid res_name = ["EcoRI", "XbaI", "PvuI", "NdeI", "PstI"]; #Current catalog of restriction sites restrictions = ["GAATTC", "CTGCAG", "CGATCG", "CATATG", "CTGCAG"]; print ("Welcome to mgem 2016/17's plasmid search and design application!"); print ("The current list of available restrictions:"); print (res_name); plasmid = input("Enter the plasmid sequence:") #check plasmid contains restriction #if restriction not in plasmid: # print ("The restriction site provided is not present in the plasmid sequence provided. Please enter an alternative restriction site or plasmid."); insertion = input("Enter the insertion sequence:") #check insertion doesn't contain restriction #if restriction in insertion: # print ("The insertion provided contains the restriction site. Please enter an alternative restriction site or insertion."); promotor = input("Please enter the promotor sequence:") terminator = input("Please enter the terminator sequence:") #---------------------------------------------DONE #make sure all strings are all caps plasmid = plasmid.upper(); insert_seq = insertion.upper(); promotor = promotor.upper(); terminator = terminator.upper(); #find restriction sites and store in list. (format: [restriction, index]) i = 0; j = 0; for restriction in restrictions: sites[i] = re.search(restriction, plasmid); if sites[i] is not None: cut_site[j] = [res_name[i], sites[0].start()] j = j + 1; i = i + 1; #---------------------------------------------DONE # print a list of cut sites from the array, and number them options = 0 for i in cut_site: options += 1 #print (options) # shows how many options there are for i in range(options): if cut_site[i] is not None: print(str(i+1) + ". " + cut_site[i][0]) #----------------------------------------------DONE # user selects desired cut site - scan for the number that they indicate, subtract 1 to get place in string choice = input("Which cut site would you like to use? ") #----------------------------------------------DONE restriction = res_name[res_name.index(cut_site[int(choice)-1][0])]; # split plasmid at cut site # insert the insert sequence and restriction between both plasmid segments # merge to one string hybrid = plasmid[:(cut_site[int(choice)-1][1])+1] + promotor + insert_seq + terminator + restriction + plasmid[(cut_site[int(choice)-1][1])+1:] print("5'", hybrid, "3'") #-----------------------------------------------DONE # create complement # provide user with track string, and complement in 5'-3' reverse = "" for baseH in hybrid: if baseH == "A": baseC = "T" elif baseH == "T": baseC = "A" elif baseH == "C": baseC = "G" elif baseH == "G": baseC = "C" reverse = baseC + reverse print("5' ", reverse, "3'")