#this is just a script that generates a file with all the primers in it
import xlrd

#extract columns: primer_number, primer_description, primer_sequence
wb = xlrd.open_workbook("/Users/susanychen/Documents/pythonPC204/FinalProject/JSO_MasterList_121212.xls")
sh = wb.sheet_by_name(u'Primers')
primer_number = sh.col_values(0)
primer_number.pop(0) #float
primer_desc = sh.col_values(1)
primer_desc.pop(0) #unicode
primer_seq = sh.col_values(7)
primer_seq.pop(0) #unicode

#take the spaces out of all three columns and make new lists
primernum = []
primerdesc = []
primerseq = []
for value in primer_desc:
	if value != '':
		primerdesc.append(value) #type = unicode
		index = primer_desc.index(value)
		primernum.append(primer_number[index]) #type = float
		primerseq.append(primer_seq[index]) #type = unicode and some type = string

def safe_str(obj):
    """ return the byte string representation of obj """
        return str(obj)
    except UnicodeEncodeError:
        # obj is unicode
        return unicode(obj).encode('unicode_escape')

#make the merged list with all three fields
merged_list = []
for item in primernum:
	index = primernum.index(item)
	desc = safe_str(primerdesc[index])
	seq = safe_str(primerseq[index])
	temp = [item , desc, seq]

#print merged_list[0]	

#this writes this information stored in a list to a csv file
import csv
resultfile = open("compiled_info_primer.txt", "wb")
wr = csv.writer(resultfile, dialect = "excel")

for item in merged_list: