Bioinformatics Technology Lab common code library in C++ with Python wrappers.
- Linux
- MacOS
The recommended way is to download using Conda package manager:
conda install -c bioconda -c conda-forge btllib
Alternatively, you can compile the code from source. Download btllib-$VERSION.tar.gz from the GitHub latest release where $VERSION is the latest btllib version and do the following:
tar xzf btllib-$VERSION.tar.gzto extract the source code.- Have the dependencies ready:
- GCC 6+ or Clang 5+ (with OpenMP and C++17 support)
- Python 3.9+
- Meson and Ninja Python3 packages, CMake (If not available, these will be automatically installed to a temporary directory.)
- Run
btllib/compile- This will install btllib in the
btllib/installdirectory. You can provide the--prefixparameter to change this. - The C++ compiler must be the same as the one used for compiling Python. E.g. if you installed Python using a package manager, you should use the C++ compiler from the same package manager. You can change the compiler by exporting the
CXXenvironment variable to point to the compiler before runningbtllib/compile. - You can optionally run
python3 -m pip install $PREFIX/lib/btllib/pythonafterwards to install the Python package. The Python wrappers are usable even without this step.$PREFIXis the path where btllib is installed.
- This will install btllib in the
- Run time dependencies:
- SAMtools for reading SAM, BAM, and CRAM files.
- gzip, tar, pigz, bzip2, xz, lrzip, zip, and/or 7zip for compressing/decompressing files. Not all of these are necessary, only the ones whose compressions you'll be using.
- Note that lrzip is not available on the btllib conda osx-arm64 build
- wget for downloading sequences from a URL.
- Building C++ code (
$PREFIXis the path where btllib is installed):- Link your code with
$PREFIX/lib/libbtllib.a(pass-L $PREFIX/lib -l btllibflags to the compiler).- You can do so by typing the following in your console:
export CPPFLAGS="-isystem /path/to/btllib/install/include $CPPFLAGS"export LDFLAGS="-L/path/to/btllib/install//lib -lbtllib $LDFLAGS"
- You can do so by typing the following in your console:
#includeany header from the$PREFIX/includedirectory (pass-I $PREFIX/includeflag to the compiler).btllibusesC++11features, so that standard should be enabled at a minimum.
- Link your code with
- Running Python code:
- The Python used to import btllib must be the same as the one used to compile the library. Specifically, btllib uses
python3-configto determine the flags used for compilation. Runningpython3-config --exec-prefixwill give the path to the Python installation that needs to be used. Thepython3executable can be found at$(python3-config --exec-prefix)/bin/python3. - The wrappers correspond one-to-one with C++ code so any functions and classes can be used under the same name. The only exceptions are nested classes which are prefixed with outer class name (e.g.
btllib::SeqReader::Flagin C++ versusbtllib.SeqReaderFlagin Python), and (Kmer)CountingBloomFilter which providesCountingBloomFilter8,CountingBloomFilter16,CountingBloomFilter32,KmerCountingBloomFilter8,KmerCountingBloomFilter16,CountingBloomFilter32with counters 8, 16, and 32 bits wide. - If you compiled btllib from source code and didn't install the Python wrappers, you can use
PYTHONPATHenvironment variable orsys.path.append()in your Python code to include$PREFIX/lib/btllib/python/btllibdirectory to make btllib available to the interpreter. - Include the library with
import btllib
- The Python used to import btllib must be the same as the one used to compile the library. Specifically, btllib uses
- Executables
- btllib generated executables can be found in
$PREFIX/bindirectory. Append that path to thePATHenvironment variable to make it available to your shell.
- btllib generated executables can be found in
- Initial setup:
git clone --recurse-submodules https://github.com/bcgsc/btllibin order to obtain all the code.- In
btllibdir, runmeson buildto create a build directory.
- Every time you want to run tests, in the
builddir:ninja wrapto regenerate wrappers.ninja testto build wrappers and tests, and run tests.
- Before making a pull request, in the
builddir:ninja quality-assuranceto make sure all CI tests pass.- Make a commit after the above step, in case it has made any changes to wrappers or formatting. Don't commit the changes made to the
sdsl-litesubproject. Meson config file adjusts thesdsl-liteconfig in order for it to work forbtllib, but this is done ad hoc and is not necessary to be committed. By doing it ad hoc we keep a list of differences compared to the upstream repository.
- Before making a release, in the
builddir:- Do the same as for a pull request and
ninja docsto regenerate docs to reflect the release and then commit the changes.meson dist --allow-dirtyto generate a self-contained package based on the last commit.--allow-dirtypermits making a distributable with uncommited changes. This is necessary assdsl-litedependency has ad hoc changes made during the build process. The resulting distributable will be compressed with xz. For easier use, decompress it and then compress with gzip. Attach the resulting file to the release.
The following are all the available ninja commands which can be run within build directory:
ninja clang-formatformats the whitespace in code (requires clang-format 8+).ninja wrapwraps C++ code for Python (requires SWIG ≥4.0 and <4.3).ninja clang-tidyruns clang-tidy on C++ code and makes sure it passes (requires clang-tidy 8+).ninjabuilds the tests and wrapper libraries / makes sure they compile.ninja testruns the tests.ninja code-coverageassures code coverage threshold is satisfied. (requires gcovr 3.3+)ninja sanitize-undefinedruns undefined sanitization.ninja test-wrapperstests whether wrappers work.ninja docsgenerates code documentation from comments (requires Doxygen).ninja quality-assurancerunsclang-format,wrap,clang-tidy,test,code-coverage,sanitize-undefined, andtest-wrappers. These are all checked at the CI test.
- Author: Vladimir Nikolic
- Components:
- Hamid Mohamadi and Parham Kazemi for ntHash
- Justin Chu for MIBloomFilter
- Johnathan Wong for aaHash
- Included dependencies:
- Chase Geigle for cpptoml
- Simon Gog, Timo Beller, Alistair Moffat, and Matthias Petri for sdsl-lite
If you use btllib in your research, please cite:
Nikolić et al., (2022). btllib: A C++ library with Python interface for efficient genomic sequence processing. Journal of Open Source Software, 7(79), 4720, https://doi.org/10.21105/joss.04720
If you use aaHash in your research, please cite:
Wong et al., (2023). aaHash: recursive amino acid sequence hashing. Bioinformatics Advances, vbad162, https://doi.org/10.1093/bioadv/vbad162.