I have a list of patterns:
['transcript/123', 'transcript/127', 'transcript/344', 'transcript/346', 'transcript/245', 'transcript/129', ]
I need to loop over all the patterns and look if those patterns match with key names of a dict:
defaultdict(<type 'list'>, {'transcript/129 full_length_coverage=3;length=1108': ['ATTATATATAAAGATTAAAAGTATTACATTTTT'], 'transcript/344 full_length_coverage=2;length=1652': ['CAAGGGAAAGAAAGATAAAAAGTCC'], 'transcript/764 full_length_coverage=19;length=1388': ['CGACGCTTT'], 'transcript/67 full_length_coverage=5;length=1411': ['GAAGATATTTATTATAGGCTTATTAAAGAATATTTT']})
I need to remove items of the dict if the patterns of the list match with the keys of the defaultdict.
I'd like something like that:
for i in my_list:
for key in my_dict:
l=key.split(' ')
if i in key[0]:
my_dict.pop(key)
Thanks
I think you can just go
for i in my_list:
for key in my_dict:
if i in key:
del my_dict[key]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.