In DNA strings, symbols A and T are complements of each other, as are C and G. Given a nucleotide $$b$$, we denote its complementary nucleotide as $$\overline{b}$$. The reverse complement of a DNA string $$s = s_0s_1\ldots s_{n-1}$$ is the string $$\overline{s} = \overline{s_{n-1}}\,\overline{s_{n-2}}\ldots \overline{s_0}$$ formed by taking the complement of each nucleotide in $$s$$, then reversing the resulting string.

For example, the reverse complement of $$s$$ = GTCA is $$\bar{s}$$ = TGAC.

Assignment

Write a function reverse_complement that takes a DNA strings $$s$$. The function must return the reverse complement $$\overline{s}$$ of the string $$s$$.

Example

In the following interactive session, we assume the FASTA file data.fna1 to be located in the current directory.

>>> reverse_complement('GTCA')
'TGAC'
>>> reverse_complement('CGATATATCCATAG')
'CTATGGATATATCG'

>>> from Bio import SeqIO
>>> reverse_complement(*SeqIO.parse('data.fna', 'fasta'))
'ACCGGGTTTT'