This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Alphabetizing fasta sequence

Hi everyone,

Can someone suggest a method to sort a fasta file by alphabetical order of the sequence (not the defline)?

Any advice will be appreciated.

fasta

Do you have a multi-line or single line fasta?

it it answer your question, please choose a green mark on the left to close this thead.

3 answers

Using the BBMap package:

shuffle.sh in=file.fasta out=sorted.fasta sequence

linearize and sort...

awk '/^>/ {printf("%s%s\t",(N>0?"\n":""),$0);N++;next;} {printf("%s",$0);} END {printf("\n");}'  roxan.fasta |LC_ALL=C sort -t $'\t' -k2,2 | tr "\t" "\n"
seqkit sort --quiet -s -i <fasta file>

i is ignore case s is sort by sequence

Log in to answer this question.