Use UNIX reverse complement
2
1
Entering edit mode
7.2 years ago
avranarkin ▴ 10

I have downloaded the FASTA DNA sequence, how to use UNIX to reverse complement each line of the file using a single line of command?

sequencing • 3.5k views
ADD COMMENT
0
Entering edit mode

This looks like an assignment, what have you tried? UNIX is very diverse and not identical to GNU Linux or POSIX, which you are probably referring to.

ADD REPLY
5
Entering edit mode
7.2 years ago
$ perl -pe '/^>/ ? print "\n" : chomp' test.fa | while read -r line; do if [[ "$line" == ">"* ]]; then echo $line; else tr "[ATGCatgcNn]" "[TACGtacgNn]"; fi; done | awk '{ if ($0~/^>/) { printf("%s",$0); } else { for(i=length;i!=0;i--) x=(x substr($0,i,1)) } { printf("%s\n",x); x=""; } }'

Christ, that's awful. Just take the teacher's "F" and use seqkit or something. https://github.com/shenwei356/seqkit

ADD COMMENT
1
Entering edit mode
7.2 years ago
James Ashmore ★ 3.5k

Install bioawk and use the following command:

bioawk -c fastx '{print ">"$name;print revcomp($seq)}' seq.fa.gz
ADD COMMENT
0
Entering edit mode

Thank you, do you know how to solve this if I just use UNIX commands?

ADD REPLY

Login before adding your answer.

Traffic: 2676 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