Question: Use UNIX reverse complement
1
gravatar for avranarkin
2.2 years ago by
avranarkin10
avranarkin10 wrote:

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 • 1.6k views
ADD COMMENTlink modified 2.2 years ago by Alex Reynolds29k • written 2.2 years ago by avranarkin10

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 REPLYlink modified 2.2 years ago • written 2.2 years ago by Michael Dondrup46k
5
gravatar for Alex Reynolds
2.2 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:
$ 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 COMMENTlink modified 2.2 years ago • written 2.2 years ago by Alex Reynolds29k
1
gravatar for James Ashmore
2.2 years ago by
James Ashmore2.7k
UK/Edinburgh/MRC Centre for Regenerative Medicine
James Ashmore2.7k wrote:

Install bioawk and use the following command:

bioawk -c fastx '{print ">"$name;print revcomp($seq)}' seq.fa.gz
ADD COMMENTlink written 2.2 years ago by James Ashmore2.7k

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

ADD REPLYlink written 2.2 years ago by avranarkin10
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1761 users visited in the last hour