I have this data set:
Epitope,ID,Frequency,Assay
AVNIVGYSNAQGVDY,123431,27.0,Tetramer
DIKYTWNVPKI,887473,50.0,3H
LRQMRTVTPIRMQGG,34234,11.9,Elispot
AVNIVGYSNAQGVDY,3456,67.0,Tetramer
I would like to know how to obtain and output like this
d = {'AVNIVGYSNAQGVDY': [ID[123431,3456],Frequency[27.0,67.0],Assay['Tetramer']], 'DIKYTWNVPKI': [ID[887473],Frequency[50.0],Assay['3H']], 'LRQMRTVTPIRMQGG': [ID[34234],Frequency[11.9],Assay['Elispot']]}
This makes dictionary with every unique Epitope as key and their values are list with each category ID, Frequency and Assay as a list that have that appends the values for repetitions as you can see.
I can read the file with this code:
result = {}
for row in reader:
dictlist = []
key = row.pop('Epitope')
if key in result:
pass
result[key] = row
print result
but I am not sure how to handle the duplicates, I mean, how to append the ID, Frequency and Assay if there is a replicate.