How to swap fasta entrys in a fasta file?
2
0
Entering edit mode
22 months ago
SaltedPork ▴ 170

Hi, my files all have 2 fasta entries and they look like:

>ID.1
GTAACACGACATCCTGCAGGGTTAAAAAAGAAAAAATCAGTAAAAGTACTGGA
>ID.2
GGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGA

My desired output looks like:

>ID.2
GGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGA
>ID.1
GTAACACGACATCCTGCAGGGTTAAAAAAGAAAAAATCAGTAAAAGTACTGGA

I have looked into awk/sed and the only solutions involve cutting/pasting rows into a sperate file and then moving them back, is there an alternative way?

awk fasta bash sed • 620 views
ADD COMMENT
1
Entering edit mode
22 months ago

Seqkit answer for posterity.

seqkit sort -r in.fasta > out.fasta
ADD COMMENT
0
Entering edit mode
22 months ago
SaltedPork ▴ 170
awk -F'\n' '{print $3, $4, $1, $2}' OFS='\n' RS= ORS='\n\n' $i
ADD COMMENT

Login before adding your answer.

Traffic: 1590 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6