dna4_revcomp(3) - compute the reverse complement

LIBDNA, 2019-08-12

#include <kloetzl/dna.h>

char *dna4_revcomp(const char *begin, const char *end, char *dest);

Description

The dna4_revcomp() function efficiently computes the reverse complement. The input string is delimited by begin and end (exclusive). The result is stored at dest.

The result is undefined if the input string contains characters besides A, C, G and T. Lowercase letters are also not allowed.

Return Value

The return value points one byte past the last character written (i.e. dest + end - begin). You may want to write a null byte there.

Example

const char str[] = "ACGTACGTACGT";
char buffer[13];
char *end = dna4_revcomp(str, str + sizeof(str) - 1, buffer);
*end = '\\0';

assert(strncmp(str, buffer, 12) == 0);

See Also

dnax_revcomp