IGEM:Harvard/2006/Container Design 4/Python Code/Add Latches

From OpenWetWare

Jump to: navigation, search
#####
# Add latches   
#####
        
fin_barrel = None 
fin_lid1 = None
fin_lid2 = None
fin_barrel_design2 = None
fin_lid1_design2 = None
fin_lid2_design2 = None
                
try:
        fin_barrel = open("barrel_latches_to_add.txt", "r")
        fin_lid1 = open("lid1_latches_to_add.txt", "r")
        fin_lid2 = open("lid2_latches_to_add.txt", "r")
        fin_barrel_design2 = open("barrel_latches_to_add_design2.txt", "r")
        fin_lid1_design2 = open("lid1_latches_to_add_design2.txt", "r")
        fin_lid2_design2 = open("lid2_latches_to_add_design2.txt", "r")
except IOError, e:
        print "Error in file IO: ", e
        

if (shape == 1):
        latches_to_add = pickle.load(fin_barrel)
        latches_to_add_d2 = pickle.load(fin_barrel_design2)
elif (shape == 2):
        # Ask which lid is being run
        print 'What lid are you running?'
        type = int(raw_input('Enter 1 if lid1, 2 if lid2: '))
        if (type == 1):
                latches_to_add = pickle.load(fin_lid1)
                latches_to_add_d2 = pickle.load(fin_lid1_design2)
elif (shape == 2):
        # Ask which lid is being run
        print 'What lid are you running?'
        type = int(raw_input('Enter 1 if lid1, 2 if lid2: '))
        if (type == 1):
                latches_to_add = pickle.load(fin_lid1)
                latches_to_add_d2 = pickle.load(fin_lid1_design2)
        elif (type == 2):
                latches_to_add = pickle.load(fin_lid2) 
                latches_to_add_d2 = pickle.load(fin_lid2_design2)
        
        
# note: latch sequence includes any linker Ts already
for latch_specs in latches_to_add:
        oligo_num = latch_specs[0]   
        latch = latch_specs[1]
        oligo_ra[oligo_num] = oligo_ra[oligo_num] + latch

for latch_specs in latches_to_add_d2:
        oligo_num = latch_specs[0]
        latch = latch_specs[1]
        latch_2_oligo_ra[oligo_num] = latch_2_oligo_ra[oligo_num] + latch

Pickle script to generate structs of latches to add

#latch_list = [[oligo_num, sequence], ... ]

import pickle

fout_barrel = None
fout_lid1 = None
fout_lid2 = None
fout_barrel_design2 = None
fout_lid1_design2 = None
fout_lid2_design2 = None

try:
        fout_barrel = open("barrel_latches_to_add.txt", "w")
        fout_lid1 = open("lid1_latches_to_add.txt", "w")
        fout_lid2 = open("lid2_latches_to_add.txt", "w")
        fout_barrel_design2 = open("barrel_latches_to_add_design2.txt", "w")
        fout_lid1_design2 = open("lid1_latches_to_add_design2.txt", "w")
        fout_lid2_design2 = open("lid2_latches_to_add_design2.txt", "w")
except IOError, e:
        print "Error in file IO: ", e
barrel_latches = [[60, 'TTTTTTTGTAACGAAGTTGCACCACACAACGCTA'],  [43, 'TTTTTTTTTTTTTGTACGCATGGCAAATTACCACTCTAGC'], [21, 'TTTTTTTTTTTCGAGTTGACAAAGCTACCGGTTCAAG'],
[27, 'TTTTTTTTTTTTTTCAGGATACCATCATCTACTAACCGGTG']] lid1_latches = [[2, 'TTTTTTTGTGCAACTTCGTTACACGAGTAATGCG'], [29, 'TTTTTTTTTTTTTTATTTGCCATGCGTACCGGTTAGATAGC']]
lid2_latches = [[2, 'TTTTTTTTTTTGCTTTGTCAACTCGAACTGGCCCTTAA'], [29,'TTTTTTTTTTTTTTGATGATGGTATCCTGGTGGAGTAGTTG']]
barrel_design2_latches = [[60, 'TTTTTTTCCGGTGCAGAAGTTT'],  [43, 'TTTTTTTTTTTTTTGGATCGGTACATTGT'], [21, 'TTTTTTTTTTGGCACTCCTACAATT'], [27,
'TTTTTTTTTTTTTTGACGATAGGGAAACA']] lid1_design2_latches = [[2, 'TTTTTTTTAGAGACGACCATAC'], [29, 'TTTTTTTTTTTTTTAGGCAACTCGAATAC']]
lid2_design2_latches = [[2, 'TTTTTTTTTTTGTAGTAGAGACCAAC'], [29, 'TTTTTTTTTTTTTTCCTACGAGAAGATCA']]

pickle.dump(barrel_latches, fout_barrel)
pickle.dump(lid1_latches, fout_lid1)
pickle.dump(lid2_latches, fout_lid2)
pickle.dump(lid1_design2_latches, fout_lid1_design2)
pickle.dump(lid2_design2_latches, fout_lid2_design2)
pickle.dump(barrel_design2_latches, fout_barrel_design2)

if fout_barrel:
        fout_barrel.close()
        fout_lid1.close()
        fout_lid2.close()
        fout_barrel_design2.close()
        fout_lid1_design2.close()
        fout_lid2_design2.close()
Personal tools