IGEM:Harvard/2006/Container Design 4/Python Code/Pickle Scripts

From OpenWetWare

Jump to: navigation, search

All of these scripts make use of pickle.dump() to move structs into main - in main use pickle.load() to essentially upload the struct. This way the lists of oligos to split or oligos to add aptamers or latches to etc can be seperated from the main program and double checked or modified more easily. These scripts can also be found on the page they're most related to (i.e. the oligo splitting pickle script is on the oligo splitting code page.)

Oligo Splitting

### split = [[oligo_num, num_tokens for oligo_1 - from 5prime], ... ]

import pickle

fout_barrel = None
fout_lid = None

try:
        fout_barrel = open("barrel_oligos_to_split.txt", "w")
        fout_lid = open("lid_oligos_to_split.txt", "w")
except IOError, e:
        print "Error in file IO: ", e

barrel_split = [[56, 2], [57, 3], [41, 3], [26, 3], [21, 4]]
lid_split = [[27, 4], [2, 4]]

pickle.dump(barrel_split, fout_barrel)
pickle.dump(lid_split, fout_lid)

# clean up if they're open
if fout_barrel:
        fout_barrel.close()
if fout_lid:
        fout_lid.close()

Add Latches

#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()

Add Aptamers

apt_list = [[oligo_num, type], ... ]
# note that 1 corresponds to in and 2 corresponds to out.

import pickle

fout_barrel = None

try:
        fout_barrel = open("barrel_apts_to_add.txt", "w")
except IOError, e:
        print "Error in file IO: ", e

barrel_apts = [[1, 1], [2, 2], [7, 2], [11, 1], [17, 2], [23, 2], [36, 1], [47, 1]]

pickle.dump(barrel_apts, fout_barrel)

if fout_barrel:
        fout_barrel.close()
Personal tools