Here's an awk
one-liner that works as intended, unlike the bioawk
answer.
This removes all instances of fastq records in which the length of the seq and qual fields do not match. Again, append | gzip > filtered.fastq.gz
to gzip the output.
zcat bad_file.fq.gz | awk '{ pos = NR%4; if ( pos == 1) {h=$0} else if (pos == 2) \
{s=$0} else if (pos==3){c=$0} else if ( pos==0 ) \
{q=$0; if ( length(q) == length(s) ){printf("%s\n%s\n%s\n%s\n", h, s, c, q)}}}'
Delete the \
characters at the end of the first two lines to make it easy to paste into your terminal.
Here is a shorter version of the same thing thanks to @terdon
zcat file.fastq.gz | awk '{ record[++k]=$0; if(NR%4==2){slen=length($0)} else if(NR%4==0){if(length($0) == slen){ for(i in record){print record[i]}} k=0; }}'
tail
on your FASTQ file. If a job aborted while writing to disk, this read will be the last line. This error message likely means the file is truncated and missing reads. That read is not as much of a concern as the rest of the data. It’s best to run your data processing again to make sure the file is complete. $\endgroup$