Skip to content

Commit

Permalink
man: add manpage for dna4_revcomp
Browse files Browse the repository at this point in the history
  • Loading branch information
kloetzl committed Aug 14, 2019
1 parent 1f3d84e commit a49ee16
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
37 changes: 37 additions & 0 deletions man/dna4_revcomp.3
@@ -0,0 +1,37 @@
.TH DNA4_REVCOMP 3 2019-08-12 "LIBDNA" "LIBDNA"

.SH NAME
dna4_revcomp \- compute the reverse complement

.SH SYNOPSIS
.nf
.B #include <dna.h>
.PP
.BI "char *dna4_revcomp(const char *" begin ", const char *" end ", const char *" dest ");"
.fi

.SH DESCRIPTION
The \fBdna4_revcomp\fR() function efficiently computes the reverse complement. The input string is delimited by \fIbegin\fR and \fIend\fR (exclusive). The result is stored at \fIdest\fR.

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

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

.SH EXAMPLE
.in +4
.EX
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);
.SH SEE ALSO
.BR dnax_revcomp (3)
7 changes: 7 additions & 0 deletions test/Tdna4_revcomp.cxx
Expand Up @@ -22,6 +22,13 @@ repeat(std::string in, int count)

TEST_CASE("Basic revcomp checks")
{
const char str[] = "ACGTACGTACGT";
char buf[13];
char *end = dna4_revcomp(str, str + sizeof(str) - 1, buf);
*end = (unsigned char)'\0';

REQUIRE(strncmp(str, buf, 12) == 0);

auto forward = repeat("ACGT", 10);

auto buffer = new char[forward.size() + 1];
Expand Down

0 comments on commit a49ee16

Please sign in to comment.