Skip to content

Instantly share code, notes, and snippets.

@tobigithub
Created March 25, 2019 00:55
Show Gist options
  • Select an option

  • Save tobigithub/f203df6f17104958fa976bc748dafb93 to your computer and use it in GitHub Desktop.

Select an option

Save tobigithub/f203df6f17104958fa976bc748dafb93 to your computer and use it in GitHub Desktop.
# requires input file HUMAN.fasta (or others) writes it sorted by sequence length to HUMAN-sort.fasta
# source https://www.biostars.org/p/153999/
awk '/^>/ {printf("%s%s\t",(N>0?"\n":""),$0);N++;next;} {printf("%s",$0);} END {printf("\n");}' HUMAN.fasta |\
awk -F '\t' '{printf("%d\t%s\n",length($2),$0);}' |\
sort -k1,1n | cut -f 2- | tr "\t" "\n" > HUMAN-sort.fasta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment