IGEM:Harvard/2006/Container Design 4/Python Code/Pickle Scripts
From OpenWetWare
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 their 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()