DaehwanKimLab / hisat2

Graph-based alignment (Hierarchical Graph FM index)
GNU General Public License v3.0
464 stars 113 forks source link

hisat2_read_statistics.py: Syntax Error in reads_stat() #236

Open afaranda opened 4 years ago

afaranda commented 4 years ago

I've been getting the following error message when running alignments:


File "/home/username/hisat2-2.2.0/hisat2_read_statistics.py", line 182
    length_map = sorted(length_map.iteritems(), key=lambda (k,v):(v,k), reverse=True)

I found that in python3, iteritems() is deprecated for 'dict' objects and tuple unpacking is deprecated for lambdas. The following syntax works, but I couldn't tell from the original code whether 'length_map' should be sorted by its key (read length) or value (number of reads with length 'l').

To sort by length:

sorted(length_map.items())
Out[42]: [(96, 1), (97, 2), (98, 1), (99, 1), (100, 1), (101, 94)]

To sort by "number of reads with length l":

sorted(length_map.items(), key=lambda x: x[1])
Out[39]: [(100, 1), (99, 1), (98, 1), (96, 1), (97, 2), (101, 94)]
parkchanhee commented 4 years ago

@afaranda Thank you for your suggestion. Python script in hisat2 only works on python2. We are converting these scripts to python3 and will release in July.