Skip to main content

Diamond Python bindings for sequence alignment

Project description

diamond4py

pypi license python

This is python binding for diamond--a sequence alignment BLAST software implements in C++. Current base version is diamond v2.1.0.

install

  • from source code
git clone https://github.com/GCS-ZHN/diamond4py.git
cd diamond4py
conda create -n diamond4py python=3.8
# zlib is required by diamond.
conda install -c anaconda zlib
pip install -v .
  • from pypi
pip install diamond4py

Usage

from diamond4py import Diamond

# create a object
diamond = Diamond(
    database="database.dmnd",
    n_threads=4
)

# make db if you don't create it or just download one from websites
diamond.makedb("database.fasta")
print(diamond.version)

# print database statistic info
diamond.dbinfo()

# run blast for proteins
diamond.blastp(
    query="test_proteins.fasta",
    out="test_output"
)

Advanced usage.

Some parameter options are not implemented in current release, You could directly use it like this.

diamond.blastp(
    query="test_proteins.fasta",
    out="test_blastp_output",
    outfmt=OutFormat.BLAST_TABULAR,
    sensitivity=Sensitivity.DEFAULT,
    top=5 # `--top` option is not directly defined
    block_size=2.0 # `--block-size` is not directly defined
)

and you can global change the tabular output with customed title by

OutFormat.BLAST_TABULAR.with_extra_option(
        "qseqid", "qstart",
        "qend", "qlen", "sseqid"
    ) # it will change it globally

# call this will reset to default
OutFormat.BLAST_TABULAR.reset()

In fact, you can call the original C++ main method like this:

from .libdiamond import main
args = ['bastp', '--query', 'data.fasta', '--db', 'db.dmnd']
main(*args)

But it is not recommended because the original C++ api lacks necessary interface encapsulation and parameter checking. At the same time, it is not pythonic enough, and there is no parameter reminder during programming unless you read the original parameter document.

How to contrib

The core of python wrap is to use custom python methods and Diamond._build_options to call the libdiamond.main method More convenient packaging. Therefore, anyone can make customized extensions through the above ideas. I maintains this project after work, so I cannot make it in time Keep up to date with all diamond developments. Everyone is welcome to submit PRs.

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

diamond4py-0.0.6.tar.gz (1.8 MB view hashes)

Uploaded Source

Built Distributions

diamond4py-0.0.6-cp310-cp310-win_amd64.whl (4.6 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

diamond4py-0.0.6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (5.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

diamond4py-0.0.6-cp39-cp39-win_amd64.whl (4.6 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

diamond4py-0.0.6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (5.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

diamond4py-0.0.6-cp38-cp38-win_amd64.whl (4.6 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

diamond4py-0.0.6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (5.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

diamond4py-0.0.6-cp37-cp37m-win_amd64.whl (4.6 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

Supported by

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