As a specific example, rev
is a useful tool to help reverse complement a DNA sequence, something often done in bioinformatics.
Remember that DNA is a double stranded polymer comprised of nucleotides. Generally DNA is modeled simply by the first letter of its nucleotides (A,C,G,T). If the "sequence" of one strand is known, the other strand is as well, since A always pairs with T, and C always pairs with G. Thus, a double stranded DNA sequence may be this:
ACGTGTCAT
TGCACAGTA
Another thing about DNA and the two strands - they have directionality, and are often "read" from the 5' end to the 3' end. The strands have antiparallel directionality, and so are read in opposite directions - see the diagram below.
5' ACGTGTCAT 3'
3' TGCACAGTA 5'
Now - it is often useful to determine one strand given the other, and since sequences can be quite long (thousands or millions of nucleotides in length), this is done programmatically. One convenient way to do this is using rev
(and tr
):
echo ACGTGTCAT | tr ACGT TGCA | rev
ATGACACGT