In a large file the following being part of it, I need to add 1 in a loop to the second value (now set to 0) of certain keys, but I have not been able to find a way to do it:
[{'TCGA-KL-8331-01A-11D-2310-10': ('T>G ATG', 0)},
{'TCGA-KL-8331-01A-11D-2310-10': ('T>C CTA', 0)},
{'TCGA-KL-8343-01A-11D-2310-10': ('T>G TTG', 0)},
{'TCGA-KL-8343-01A-11D-2310-10': ('T>G GTC', 0)},
{'TCGA-KO-8417-01A-11D-2310-10': ('T>G TTA', 0)},
{'TCGA-KO-8417-01A-11D-2310-10': ('C>G GCA', 0)}]
If each dictionary is d, the code d.values()[1]+=1
gives the error 'dict_values' object does not support indexing
and by list(d.values())[0][1]+=1
I get 'tuple' object does not support item assignment
. Is there a way forward?
edit
Input file is tsv and this list is generated earlier in the script. I write, for example:
for m in linesList:
for n in patMutsList:
if m.keys()==n.keys() and list(m.values())[0][2]==list(n.values())[0][0]:
list(n.values())[0][1]+=1