bioawk icon indicating copy to clipboard operation
bioawk copied to clipboard

bioawk does not stop parsing a file on `nextfile`

Open RamRS opened this issue 2 years ago • 1 comments

Scenario: I have 4 FASTQ files in my current directory, and I want to print the first 10 seq names of each file. Ideally, the following command should work very quickly:

bioawk -c fastx 'FNR<11 {print $name} FNR==11{nextfile}' *.fastq

For example, with regular awk, the following works extremely fast:

awk 'FNR==1{print} FNR>1{nextfile}' *.fastq

But bioawk does not stop processing the file when it encounters nextfile. Instead, it seems to continue parsing the whole file, which is crazy when dealing with gigantic files. Plus, it seems to skip a file when running into the nextfile command, which is weird.

RamRS avatar Feb 27 '23 19:02 RamRS

Agreed. I concur. Calling nextfile as in the example above causes every other .fastq file to be processed (e.g. files in even positions in ARGV will be skipped).

This is rather troublesome.

Might this be the consequence of stated Potential limitations @lh3 ?

bioawk --version
awk version 20110810

malcook avatar Oct 11 '23 16:10 malcook