I found here this awk script:
BEGIN {
headertype="";
}
{
if($0 ~ "^@") {
countread++;
headertype="@";
}
else if($0 ~ "^+") {
headertype="+";
}
else if(headertype="@") { # This is a nuc sequence
len=length($0);
if (len>4) {
readlength[len]++;
}
}
}
END {
for (i in readlength){
countstored+=readlength[i];
lensum+=readlength[i]*i;
print i, readlength[i];
}
print "reads read = "countread > "/dev/stderr";
print "reads stored = "countstored > "/dev/stderr";
print "read average length = "lensum/countstored > "/dev/stderr";
}
and I just wonder if it is possible to shorten it with bioawk?