Skip to main content

A Python wrapper for BBTools

Project description

bbmapy

A Python wrapper for BBTools.
Current BBMap version: 0.0.41

Installation

  1. Lazy way - Clone this repository, download bbmap, and install the package:

    git clone https://github.com/urineri/bbmapy.git
    cd bbmapy
    cd vendor
    rm bb* -rf
    wget https://sourceforge.net/projects/bbmap/files/latest/download -O bbtools.tar.gz
    tar -xf bbtools.tar.gz
    cd ..
    pip install -e .
    generate-bbmapy-commands
    

    The above should be automatically done or just not needed if you are installing from pip (pypi)

  2. Unlazy way - is commented out below this line, that's how much it isn't suggested.

Dependencies

  • Java
  • BBmap (the above steps should download it to the vendor subdirectory...).
    If you rather this to use your own bbmap etc, go to the base.py script and comment out line 51, then uncomment line 52.
  • rich (for pretty printing)

Usage

After installation, you can use bbmapy in your Python scripts like this:

from bbmapy import bbduk

# Basic usage
bbduk(
    in_file="input.fastq",
    out="output.fastq",
    ktrim="r",
    k="23",
    mink="11",
    hdist="1",
    tbo=True,
    tpe=True,
    minlen="45",
    ref="adapters",
    ftm="5",
    maq="6",
    maxns="1",
    ordered=True,
    threads="4",
    overwrite="t",
    stats="stats.txt"
)

Using Java flags alongside other arguments

bbduk(
    Xmx="2g",  # Set maximum heap size
    da=True,   # Enable assertions
    eoom=True, # Enable out-of-memory termination
    in_file="input.fastq",
    out="output.fastq",
    ktrim="r",
    k="23"
)

To capture output

You need to set capture_output=True in the function call, AND out="stdout.fastq" (or any other file format you like).

stdout, stderr = bbduk(
    capture_output=True,
    Xmx="2g",
    in_file="input.fastq",
    out="stdout.fastq",
    # ... other parameters ...
)

Notes:

  • in can be a protected word in python and other code, it is replaced by in_file in function calls. in1, in2 are still valid.
  • Java flags (such as Xmx, Xms, da, ea, eoom) are automatically recognized and handled appropriately. Include them in your function calls just like any other argument.
  • the capture_output argument might be switched (stderr --> out and vice verse).
  • Flags (i.e. argument that do not take value in the OG bbmap version) are set with Boolean values. e.g.:
flag : True

Not to be mistaken for lower case, fouble qouted "true" and "false" for boolian arguments to be passed to bbtools, e.g.:

argument : "true"

Citation

BBMerge manuscript: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0185056 Please cite this paper if you use bbmap in your work.

License

This project is only a wrapper, please see the actual bbtools repository for (license)[https://bitbucket.org/berkeleylab/jgi-bbtools/src/master/license.txt] etc.
Neither the developers of bbtools nor of bbmapy take any responsibility for how you use this code. All accountability is on you.

Acknowledgments

This project only (crudely) wraps BBTools (a.k.a bbmap), which is developed by Brian Bushnell.
If you use bbmapy and things don't quite work like you'd like, don't expect the developer of bbmap to help you with this whacky python wrapper.
If Please see the BBTools website for more information about the underlying tools.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bbmapy-0.0.41.tar.gz (13.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bbmapy-0.0.41-py3-none-any.whl (15.0 MB view details)

Uploaded Python 3

File details

Details for the file bbmapy-0.0.41.tar.gz.

File metadata

  • Download URL: bbmapy-0.0.41.tar.gz
  • Upload date:
  • Size: 13.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for bbmapy-0.0.41.tar.gz
Algorithm Hash digest
SHA256 644c82be4c70deb8469829653b6e768a483820378b2b2469762e220de12713c2
MD5 494f799b2688ad3a2660976715b698ec
BLAKE2b-256 b2fee9f15ad12152194c7a62c479a4380407c010176f2863e551d2be15474fff

See more details on using hashes here.

File details

Details for the file bbmapy-0.0.41-py3-none-any.whl.

File metadata

  • Download URL: bbmapy-0.0.41-py3-none-any.whl
  • Upload date:
  • Size: 15.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for bbmapy-0.0.41-py3-none-any.whl
Algorithm Hash digest
SHA256 87fb80167a3489ec05ae0964db0242d8cb2a935a7e6fa1b247c50dd3aa2784b8
MD5 97d3a58228d0dbb9b17cb6741d4f5912
BLAKE2b-256 d3e6f5fe90423a407174c75a360316816444b7e4a975c7c41be245092e50a869

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page