cbrueffer / tophat-recondition

Post-processor for TopHat unmapped.bam files making them usable by downstream software.
BSD 2-Clause "Simplified" License
7 stars 5 forks source link

Use iteritems() to iterate over a dictionary. #3

Closed roryk closed 8 years ago

roryk commented 8 years ago

Hi Christian,

iter(dictionary) doesn't work:

>>> x = {"foo": "bar"}
>>> for k, v in iter(x):
...     print k, v
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack

so I swapped this call with .iteritems() which should do the same thing.

cbrueffer commented 8 years ago

Argh, I'm sure I tested this... The code used iteritems() in the past, but since that method was dropped in Python 3 I was looking for something that works in both 2 and 3.

The following is cross-compatible (slightly pessimized on Python 2, but I don't expect that particicular dict to get very big):

for readname, readidx in unmapped_with_mapped_mate.items():

What do you think?

roryk commented 8 years ago

Thanks, I swapped it to use .items() instead.

cbrueffer commented 8 years ago

Fixed, thanks a lot!

roryk commented 8 years ago

Thanks!

roryk commented 8 years ago

What do you think about pushing a new release with the fix?

cbrueffer commented 8 years ago

On it right now :-)

cbrueffer commented 8 years ago

Done; the integration checks are running on an updated bioconda recipe. Should be updated there within the hour.

roryk commented 8 years ago

Awesome. Thanks!