14
$\begingroup$

I have a DNA sequence for which I would like to quickly find the reverse complement. Is there a quick way of doing this on the bash command line using only GNU tools?

$\endgroup$

3 Answers 3

32
$\begingroup$

Thanks to Manu Tamminen for this solution:

echo ACCTTGAAA | tr ACGTacgt TGCAtgca | rev
$\endgroup$
3
  • $\begingroup$ And if I want to put it into a variable instead of echo it? $\endgroup$
    – Adi Ro
    Commented Jan 6, 2020 at 9:44
  • 1
    $\begingroup$ I would enclose the code in $() and assign to a variable assuming you are using a recent version of bash. $\endgroup$
    – winni2k
    Commented Jan 6, 2020 at 11:35
  • $\begingroup$ that works thanks! $\endgroup$
    – Adi Ro
    Commented Jan 9, 2020 at 9:29
7
$\begingroup$

Reverse complement FASTA/Q:

seqtk seq -r in.fa > out.fa

https://github.com/lh3/seqtk

$\endgroup$
2
$\begingroup$

You may either install the emboss package (http://emboss.sourceforge.net/download/) and use the revseq program. It contains many useful command-line programs such as the pairwise alignment tool needle.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.