khyox / recentrifuge

Recentrifuge: robust comparative analysis and contamination removal for metagenomics
http://www.recentrifuge.org
Other
86 stars 7 forks source link

update kraken.py to support compressed input #20

Closed XiaoJianfeng closed 4 years ago

XiaoJianfeng commented 4 years ago

The kraken output file could be very large (hundreds of Mb or even larger), so I think it could be more disk efficient if recentrifuge could read compressed as well as uncompressed kraken outputs.

So I just use fileinput to read compressed as well as uncompressed kraken output files, the code is simple:

import library fileinput in the beginning

import fileinput

use fileinput to read kraken output file by using openhook=fileinput.hook_compressed

with fileinput.input(output_file, openhook=fileinput.hook_compressed) as file: