Skip to content

Instantly share code, notes, and snippets.

@tbrittoborges
Created February 23, 2018 12:54
Show Gist options
  • Select an option

  • Save tbrittoborges/8c231f9daf2c580a283f824bff576b64 to your computer and use it in GitHub Desktop.

Select an option

Save tbrittoborges/8c231f9daf2c580a283f824bff576b64 to your computer and use it in GitHub Desktop.
calculates the average and sd read length from https://www.biostars.org/p/243552/#243563
for f in raw_reads{39..50}.fq.gz
do
echo "$f "
gzip -cd $f | awk 'BEGIN { t=0.0;sq=0.0; n=0;} ;NR%4==2 {n++;L=length($0);t+=L;sq+=L*L;}END{m=t/n;printf("total %d avg=%f stddev=%f\n",n,m,sq/n-m*m);}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment