The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

1. Motivation

Rtwobitlib is an R package that provides the 2bit C Library from the UCSC Genome Browser. See this page on the UCSC Genome Browser website for a quick overview of the 2bit format.

The Rtwobitlib package is primarily useful to developers of other R packages who wish to use the 2bit C library in their own C code.

2. Using the 2bit C library in the C code of your package

Find the header files

In order for the C/C++ compiler to find the 2bit header files during compilation of your package, you must add Rtwobitlib to the LinkingTo field of its DESCRIPTION file, e.g.,

LinkingTo: Rtwobitlib

Note that as of R 3.0.2 LinkingTo values can include version specifications, e.g., LinkingTo: Rtwobitlib (>= 0.3.6).

In C or C++ code files, use standard techniques, e.g., #include <kent/twoBit.h>. Header files are available for perusal at (enter in an R session)

inc_path <- system.file(package="Rtwobitlib", "include")
list.files(inc_path, recursive=TRUE)
##  [1] "kent/bits.h"     "kent/cheapcgi.h" "kent/common.h"   "kent/dnaseq.h"  
##  [5] "kent/dnautil.h"  "kent/errAbort.h" "kent/hash.h"     "kent/linefile.h"
##  [9] "kent/localmem.h" "kent/obscure.h"  "kent/sig.h"      "kent/twoBit.h"

Notes

Rtwobitlib provides both static and dynamic versions of the 2bit library on Linux, but only the static version on Windows and macOS. The procedure above will link against the static version of the 2bit library on all platforms.

3. R functions defined in Rtwobitlib

Rtwobitlib provides the following R functions: twobit_read, twobit_write, twobit_seqlengths, twobit_seqstats.

These functions are implemented in C on top of the 2bit library bundled in the package.

Please refer to their man pages (e.g. with ?twobit_seqlengths) for more information and some examples.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.