# pybarrnap: Python implementation of barrnap
![Python3](https://img.shields.io/badge/Language-Python3-steelblue)
![OS](https://img.shields.io/badge/OS-_Mac_|_Linux-steelblue)
![License](https://img.shields.io/badge/license-GPLv3-blue)
[![Latest PyPI version](https://img.shields.io/pypi/v/pybarrnap.svg)](https://pypi.python.org/pypi/pybarrnap)
[![Bioconda](https://img.shields.io/conda/vn/bioconda/pybarrnap.svg?color=green)](https://anaconda.org/bioconda/pybarrnap)
[![CI](https://github.com/moshi4/pybarrnap/actions/workflows/ci.yml/badge.svg)](https://github.com/moshi4/pybarrnap/actions/workflows/ci.yml)
## Table of contents
- [Overview](#overview)
- [Installation](#installation)
- [CLI Usage](#cli-usage)
- [API Usage](#api-usage)
- [LICENSE](#license)
## Overview
pybarrnap is a python implementation of [barrnap](https://github.com/tseemann/barrnap) (Bacterial ribosomal RNA predictor).
pybarrnap provides a CLI compatible with barrnap and also provides a python API for running rRNA prediction and retrieving predicted rRNA.
pybarrnap default mode depends only on the python library and not on the external command-line tools nhmmer and bedtools.
As an additional feature from barrnap, accurate mode is available by installing the external command-line tool cmscan([infernal](http://eddylab.org/infernal/)).
> [!NOTE]
> Barrnap v0.9 uses the HMM profile database created from older releases of Rfam and SILVA.
> On the other hand, pybarrnap default mode uses the HMM profile database created from the Rfam(14.10).
> Therefore, there will be some differences in results between Barrnap v0.9 and pybarrnap default mode.
## Installation
`Python 3.8 or later` is required for installation.
pybarrnap depends on [pyhmmer](https://github.com/althonos/pyhmmer) and [biopython](https://github.com/biopython/biopython) python library.
If accurate mode is required, please install [infernal](http://eddylab.org/infernal/) additionally.
**Install PyPI package:**
pip install pybarrnap
**Install bioconda package:**
conda install -c conda-forge -c bioconda pybarrnap
**Use Docker ([Image Registry](https://github.com/moshi4/pybarrnap/pkgs/container/pybarrnap)):**
docker run -it --rm ghcr.io/moshi4/pybarrnap:latest pybarrnap -h
## CLI Usage
### Basic Command
pybarrnap genome.fna > genome_rrna.gff
### Options
$ pybarrnap --help
usage: pybarrnap [options] genome.fna[.gz] > genome_rrna.gff
Python implementation of barrnap (Bacterial ribosomal RNA predictor)
positional arguments:
fasta Input fasta file (or stdin)
optional arguments:
-e , --evalue E-value cutoff (default: 1e-06)
-l , --lencutoff Proportional length threshold to label as partial (default: 0.8)
-r , --reject Proportional length threshold to reject prediction (default: 0.25)
-t , --threads Number of threads (default: 1)
-k , --kingdom Target kingdom [bac|arc|euk|all] (default: 'bac')
kingdom='all' is available only when set with `--accurate` option
-o , --outseq Output rRNA hit seqs as fasta file (default: None)
-i, --incseq Include FASTA input sequences in GFF output (default: OFF)
-a, --accurate Use cmscan instead of pyhmmer.nhmmer (default: OFF)
-q, --quiet No print log on screen (default: OFF)
-v, --version Print version information
-h, --help Show this help message and exit
> [!TIP]
> If `--accurate` option is set, cmscan(infernal) is used for rRNA search instead of pyhmmer.nhmmer.
> Although cmscan is slower than pyhmmer.nhmmer, it is expected to give more accurate results because it performs rRNA searches using RNA secondary structure profiles.
### CLI Example
Click [here](https://github.com/moshi4/pybarrnap/raw/main/examples/examples.zip) to download examples dataset.
#### CLI Example 1
Print rRNA prediction result on screen
pybarrnap examples/bacteria.fna
#### CLI Example 2
Output rRNA predition result to file
pybarrnap examples/archaea.fna -k arc --outseq rrna.fna --incseq > rrna_incseq.gff
#### CLI Example 3
With pipe stdin
cat examples/fungus.fna | pybarrnap -q -k euk | grep 28S
## API Usage
pybarrnap provides simple API for running rRNA prediction and retrieving predicted rRNA.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/moshi4/pybarrnap/blob/main/notebooks/pybarrnap.ipynb)
```python
from pybarrnap import Barrnap
from pybarrnap.utils import load_example_fasta_file
# Get example fasta file path
fasta_file = load_example_fasta_file("bacteria.fna")
# Run pybarrnap rRNA prediction
barrnap = Barrnap(
fasta_file,
evalue=1e-6,
lencutoff=0.8,
reject=0.25,
threads=1,
kingdom="bac",
accurate=False,
quiet=False,
)
result = barrnap.run()
# Output rRNA GFF file
result.write_gff("bacteria_rrna.gff")
# Output rRNA GFF file (Include input fasta sequence)
result.write_gff("bacteria_rrna_incseq.gff", incseq=True)
# Output rRNA fasta file
result.write_fasta("bacteria_rrna.fna")
# Get rRNA GFF text and print
print("\n========== Print rRNA GFF ==========")
print(result.get_gff_text())
# Get rRNA features and print
print("\n========== Print rRNA features ==========")
for rec in result.seq_records:
for feature in rec.features:
print(feature.id, feature.type, feature.location, feature.qualifiers)
# Get rRNA sequences and print
print("\n========== Print rRNA sequences ==========")
for rec in result.get_rrna_seq_records():
print(f">{rec.id}\n{rec.seq}")
```
## LICENSE
pybarrnap was reimplemented in python based on the perl implementation of Barrnap v0.9.
HMM(Hidden Marcov Model) and CM(Covariance Model) profile database for pybarrnap was created from Rfam(14.10).
- pybarrnap: [GPLv3](https://github.com/moshi4/pybarrnap/blob/main/LICENSE)
- Barrnap([v0.9](https://github.com/tseemann/barrnap/tree/0.9)): [GPLv3](https://github.com/moshi4/pybarrnap/blob/main/src/pybarrnap/db/LICENSE.Barrnap)
- Rfam([14.10](https://ftp.ebi.ac.uk/pub/databases/Rfam/14.10/)): [CC0](https://github.com/moshi4/pybarrnap/blob/main/src/pybarrnap/db/LICENSE.Rfam)
Raw data
{
"_id": null,
"home_page": "https://github.com/moshi4/pybarrnap/",
"name": "pybarrnap",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "bioinformatics",
"author": "moshi4",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/2b/54/fae14445524cb6ed75dda5f0cd7f82047cf87d80adbd486e75c908002df6/pybarrnap-0.5.0.tar.gz",
"platform": null,
"description": "# pybarrnap: Python implementation of barrnap\n\n![Python3](https://img.shields.io/badge/Language-Python3-steelblue)\n![OS](https://img.shields.io/badge/OS-_Mac_|_Linux-steelblue)\n![License](https://img.shields.io/badge/license-GPLv3-blue)\n[![Latest PyPI version](https://img.shields.io/pypi/v/pybarrnap.svg)](https://pypi.python.org/pypi/pybarrnap)\n[![Bioconda](https://img.shields.io/conda/vn/bioconda/pybarrnap.svg?color=green)](https://anaconda.org/bioconda/pybarrnap)\n[![CI](https://github.com/moshi4/pybarrnap/actions/workflows/ci.yml/badge.svg)](https://github.com/moshi4/pybarrnap/actions/workflows/ci.yml)\n\n## Table of contents\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [CLI Usage](#cli-usage)\n- [API Usage](#api-usage)\n- [LICENSE](#license)\n\n## Overview\n\npybarrnap is a python implementation of [barrnap](https://github.com/tseemann/barrnap) (Bacterial ribosomal RNA predictor).\npybarrnap provides a CLI compatible with barrnap and also provides a python API for running rRNA prediction and retrieving predicted rRNA.\npybarrnap default mode depends only on the python library and not on the external command-line tools nhmmer and bedtools.\nAs an additional feature from barrnap, accurate mode is available by installing the external command-line tool cmscan([infernal](http://eddylab.org/infernal/)).\n\n> [!NOTE]\n> Barrnap v0.9 uses the HMM profile database created from older releases of Rfam and SILVA.\n> On the other hand, pybarrnap default mode uses the HMM profile database created from the Rfam(14.10).\n> Therefore, there will be some differences in results between Barrnap v0.9 and pybarrnap default mode.\n\n## Installation\n\n`Python 3.8 or later` is required for installation.\npybarrnap depends on [pyhmmer](https://github.com/althonos/pyhmmer) and [biopython](https://github.com/biopython/biopython) python library.\nIf accurate mode is required, please install [infernal](http://eddylab.org/infernal/) additionally.\n\n**Install PyPI package:**\n\n pip install pybarrnap\n\n**Install bioconda package:**\n\n conda install -c conda-forge -c bioconda pybarrnap\n\n**Use Docker ([Image Registry](https://github.com/moshi4/pybarrnap/pkgs/container/pybarrnap)):**\n\n docker run -it --rm ghcr.io/moshi4/pybarrnap:latest pybarrnap -h\n\n## CLI Usage\n\n### Basic Command\n\n pybarrnap genome.fna > genome_rrna.gff\n\n### Options\n\n $ pybarrnap --help\n usage: pybarrnap [options] genome.fna[.gz] > genome_rrna.gff\n\n Python implementation of barrnap (Bacterial ribosomal RNA predictor)\n\n positional arguments:\n fasta Input fasta file (or stdin)\n\n optional arguments:\n -e , --evalue E-value cutoff (default: 1e-06)\n -l , --lencutoff Proportional length threshold to label as partial (default: 0.8)\n -r , --reject Proportional length threshold to reject prediction (default: 0.25)\n -t , --threads Number of threads (default: 1)\n -k , --kingdom Target kingdom [bac|arc|euk|all] (default: 'bac')\n kingdom='all' is available only when set with `--accurate` option\n -o , --outseq Output rRNA hit seqs as fasta file (default: None)\n -i, --incseq Include FASTA input sequences in GFF output (default: OFF)\n -a, --accurate Use cmscan instead of pyhmmer.nhmmer (default: OFF)\n -q, --quiet No print log on screen (default: OFF)\n -v, --version Print version information\n -h, --help Show this help message and exit\n\n> [!TIP]\n> If `--accurate` option is set, cmscan(infernal) is used for rRNA search instead of pyhmmer.nhmmer.\n> Although cmscan is slower than pyhmmer.nhmmer, it is expected to give more accurate results because it performs rRNA searches using RNA secondary structure profiles.\n\n### CLI Example\n\nClick [here](https://github.com/moshi4/pybarrnap/raw/main/examples/examples.zip) to download examples dataset.\n\n#### CLI Example 1\n\nPrint rRNA prediction result on screen\n\n pybarrnap examples/bacteria.fna\n\n#### CLI Example 2\n\nOutput rRNA predition result to file\n\n pybarrnap examples/archaea.fna -k arc --outseq rrna.fna --incseq > rrna_incseq.gff\n\n#### CLI Example 3\n\nWith pipe stdin\n\n cat examples/fungus.fna | pybarrnap -q -k euk | grep 28S\n\n## API Usage\n\npybarrnap provides simple API for running rRNA prediction and retrieving predicted rRNA.\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/moshi4/pybarrnap/blob/main/notebooks/pybarrnap.ipynb)\n\n```python\nfrom pybarrnap import Barrnap\nfrom pybarrnap.utils import load_example_fasta_file\n\n# Get example fasta file path\nfasta_file = load_example_fasta_file(\"bacteria.fna\")\n\n# Run pybarrnap rRNA prediction\nbarrnap = Barrnap(\n fasta_file,\n evalue=1e-6,\n lencutoff=0.8,\n reject=0.25,\n threads=1,\n kingdom=\"bac\",\n accurate=False,\n quiet=False,\n)\nresult = barrnap.run()\n\n# Output rRNA GFF file\nresult.write_gff(\"bacteria_rrna.gff\")\n# Output rRNA GFF file (Include input fasta sequence)\nresult.write_gff(\"bacteria_rrna_incseq.gff\", incseq=True)\n# Output rRNA fasta file\nresult.write_fasta(\"bacteria_rrna.fna\")\n\n# Get rRNA GFF text and print\nprint(\"\\n========== Print rRNA GFF ==========\")\nprint(result.get_gff_text())\n\n# Get rRNA features and print\nprint(\"\\n========== Print rRNA features ==========\")\nfor rec in result.seq_records:\n for feature in rec.features:\n print(feature.id, feature.type, feature.location, feature.qualifiers)\n\n# Get rRNA sequences and print\nprint(\"\\n========== Print rRNA sequences ==========\")\nfor rec in result.get_rrna_seq_records():\n print(f\">{rec.id}\\n{rec.seq}\")\n```\n\n## LICENSE\n\npybarrnap was reimplemented in python based on the perl implementation of Barrnap v0.9.\nHMM(Hidden Marcov Model) and CM(Covariance Model) profile database for pybarrnap was created from Rfam(14.10).\n\n- pybarrnap: [GPLv3](https://github.com/moshi4/pybarrnap/blob/main/LICENSE) \n- Barrnap([v0.9](https://github.com/tseemann/barrnap/tree/0.9)): [GPLv3](https://github.com/moshi4/pybarrnap/blob/main/src/pybarrnap/db/LICENSE.Barrnap)\n- Rfam([14.10](https://ftp.ebi.ac.uk/pub/databases/Rfam/14.10/)): [CC0](https://github.com/moshi4/pybarrnap/blob/main/src/pybarrnap/db/LICENSE.Rfam)\n",
"bugtrack_url": null,
"license": "GPL-3.0-only",
"summary": "Python implementation of barrnap (Bacterial ribosomal RNA predictor)",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://github.com/moshi4/pybarrnap/",
"Repository": "https://github.com/moshi4/pybarrnap/"
},
"split_keywords": [
"bioinformatics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "adf47b631a63b4f72fa6053925ac189a415706336b7af1653bff6360311af135",
"md5": "2181d1b37e74f8f6c46c4c2baaddd674",
"sha256": "b449d1409ea0cd90d23c1751f092dc5b4d6febd62a96297b1d90e7afa28d3841"
},
"downloads": -1,
"filename": "pybarrnap-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2181d1b37e74f8f6c46c4c2baaddd674",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 11718648,
"upload_time": "2024-03-13T15:25:45",
"upload_time_iso_8601": "2024-03-13T15:25:45.158882Z",
"url": "https://files.pythonhosted.org/packages/ad/f4/7b631a63b4f72fa6053925ac189a415706336b7af1653bff6360311af135/pybarrnap-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2b54fae14445524cb6ed75dda5f0cd7f82047cf87d80adbd486e75c908002df6",
"md5": "5a06560e259ec7a92b37aec949d6e581",
"sha256": "9578c1677c60dfe7f12bccfd1613048918068289b0dc04b3d0396e699fd09073"
},
"downloads": -1,
"filename": "pybarrnap-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "5a06560e259ec7a92b37aec949d6e581",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 11462216,
"upload_time": "2024-03-13T15:25:47",
"upload_time_iso_8601": "2024-03-13T15:25:47.588565Z",
"url": "https://files.pythonhosted.org/packages/2b/54/fae14445524cb6ed75dda5f0cd7f82047cf87d80adbd486e75c908002df6/pybarrnap-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-13 15:25:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "moshi4",
"github_project": "pybarrnap",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pybarrnap"
}