[Tutor] How to create a dictionary for ount elements
jarod_v6 at libero.it
jarod_v6 at libero.it
Tue Jun 3 18:24:30 CEST 2014
HI there!!!
I have afile like this:
file.txt
programs sample gene
program1 sample1 TP53
program1 sample1 TP53
program1 sample2 PRNP
program1 sample2 ATF3
program2 sample1 TP53
program2 sample1 PRNP
program2 sample2 TRIM32
program2 sample2 TLK1
program2 sample2 KIT
with open("prova.csv") as p:
for i in p:
...: lines = i.rstrip("\n").split("\t")
...: print lines
...:
['programs ', 'sample', 'gene', 'values']
['program1', 'sample1', 'TP53', '2']
['program1', 'sample1', 'TP53', '3']
['program1', 'sample2', 'PRNP', '4']
['program1', 'sample2', 'ATF3', '3']
['program2', 'sample1', 'TP53', '2']
['program2', 'sample1', 'PRNP', '5']
['program2', 'sample2', 'TRIM32', '4']
['program2', 'sample2', 'TLK1', '4']
I want to create a dictionary with set data with the names of the genes:
example:
dic = {}
dic['program1-sample1] = set(TP53)
dic['program1-sample2] = set(TP53,PRNP,ATF3)
So If I have a dictionary like that I can compare two set I will compare the
capacity of the programs in function of the gene show.
Thanks in advance for your help!
More information about the Tutor
mailing list