https://github.com/althonos/gb-io.py

A Python interface to gb-io, a fast GenBank parser written in Rust.

https://github.com/althonos/gb-io.py

Science Score: 33.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: ncbi.nlm.nih.gov
  • Committers with academic emails
    1 of 1 committers (100.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

A Python interface to gb-io, a fast GenBank parser written in Rust.

Basic Info
  • Host: GitHub
  • Owner: althonos
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 2.68 MB
Statistics
  • Stars: 19
  • Watchers: 3
  • Forks: 0
  • Open Issues: 3
  • Releases: 10
Created over 4 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License

README.md

🧬🏦 gb-io.py Stars

A Python interface to gb-io, a fast GenBank parser and serializer written in Rust.

Actions Coverage License PyPI Bioconda AUR Wheel Python Versions Python Implementations Source Mirror GitHub issues Changelog Downloads Docs

🗺️ Overview

gb-io.py is a Python package that provides an interface to gb-io, a very fast GenBank format parser implemented in Rust by David Leslie. It can reach much higher speed than the Biopython or the scikit-bio parsers.

This library has no external dependency and is available for all modern Python versions (3.7+).

To improve performance, the library implements a copy-on-access pattern, so that data is only copied on the Python heap when it is actually being accessed, rather than on object creation. For instance, if the consumer of the parser only requires the GenBank features and not the record sequence, the sequence will not be copied to a Python bytes object.

🔧 Installing

Install the gb-io package directly from PyPi which hosts pre-compiled wheels that can be installed with pip: console $ pip install gb-io

Wheels are provided for common platforms, such as x86-64 Linux, Windows and MacOS, as well as Aarch64 Linux and MacOS. If no wheel is available, the source distribution will be downloaded, and a local copy of the Rust compiler will be downloaded to build the package, unless it is already installed on the host machine.

📖 Documentation

A complete API reference can be found in the online documentation, or directly from the command line using pydoc: console $ pydoc gb_io

💡 Usage

Use the gb_io.load function to obtain a list of all GenBank records in a file: python records = gb_io.load("tests/data/AY048670.1.gb")

Reading from a file-like object is supported as well, both in text and binary mode: python with open("tests/data/AY048670.1.gb") as file: records = gb_io.load(file)

It is also possible to iterate over each record in the file without having to load the entirety of the file contents to memory with the gb_io.iter method, which returns an iterator instead of a list: python for record in gb_io.iter("tests/data/AY048670.1.gb"): print(record.name, record.sequence[:10])

You can use the gb_io.dump method to write one or more records to a file (either given as a path, or a file-like handle): python with open("tests/data/AY048670.1.gb", "wb") as file: gb_io.dump(records, file)

📝 Example

The following small script will extract all the CDS features from a GenBank file, and write them in FASTA format to an output file: ```python import gb_io

with open("tests/data/AY048670.1.faa", "w") as dst: for record in gb_io.iter("tests/data/AY048670.1.gb"): for feature in filter(lambda feat: feat.kind == "CDS", record.features): qualifiers = {q.key:q.value for q in feature.qualifiers} dst.write(">{}\n".format(qualifiers["protein_id"][0])) dst.write("{}\n".format(qualifiers["translation"][0])) ```

Compared to similar implementations using Bio.SeqIO.parse, Bio.GenBank.parse and Bio.GenBank.Scanner.GenBankScanner.parse_cds_features, the performance is the following:

| | gb_io.iter | GenBankScanner | GenBank.parse | SeqIO.parse | | ------------- | ------------- | ---------------- | --------------- | ------------- | | Time (s) | 2.264 | 7.982 | 15.259 | 19.351 | | Speed (MiB/s) | 136.5 | 37.1 | 20.5 | 16.2 | | Speedup | x8.55 | x2.42 | x1.27 | - |

💭 Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

🏗️ Contributing

Contributions are more than welcome! See CONTRIBUTING.md for more details.

⚖️ License

This library is provided under the MIT License. The gb-io Rust crate package was written by David Leslie and is licensed under the terms of the MIT License. This package vendors the source of several additional packages that are licensed under the Apache-2.0, MIT or BSD-3-Clause licenses; see the license file distributed with the source copy of each vendored dependency for more information.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the original gb-io authors. It was developed by Martin Larralde during his PhD project at the European Molecular Biology Laboratory in the Zeller team.

Owner

  • Name: Martin Larralde
  • Login: althonos
  • Kind: user
  • Location: Heidelberg, Germany
  • Company: EMBL / LUMC, @zellerlab

PhD candidate in Bioinformatics, passionate about programming, SIMD-enthusiast, Pythonista, Rustacean. I write poems, and sometimes they are executable.

GitHub Events

Total
  • Release event: 2
  • Watch event: 6
  • Delete event: 12
  • Issue comment event: 14
  • Push event: 23
  • Pull request event: 23
  • Create event: 10
Last Year
  • Release event: 2
  • Watch event: 6
  • Delete event: 12
  • Issue comment event: 14
  • Push event: 23
  • Pull request event: 23
  • Create event: 10

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 128
  • Total Committers: 1
  • Avg Commits per committer: 128.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 73
  • Committers: 1
  • Avg Commits per committer: 73.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Martin Larralde m****e@e****e 128
Committer Domains (Top 20 + Academic)
embl.de: 1

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 5
  • Total pull requests: 72
  • Average time to close issues: 3 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 3
  • Total pull request authors: 1
  • Average comments per issue: 2.2
  • Average comments per pull request: 1.33
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 72
Past Year
  • Issues: 0
  • Pull requests: 22
  • Average time to close issues: N/A
  • Average time to close pull requests: 14 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.73
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 22
Top Authors
Issue Authors
  • xapple (2)
  • nextgenusfs (2)
  • camilogarciabotero (1)
Pull Request Authors
  • dependabot[bot] (79)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels
dependencies (77) rust (13)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,903 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 12
  • Total maintainers: 1
pypi.org: gb-io

A Python interface to gb-io, a fast GenBank parser and serializer written in Rust.

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 1,903 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 17.1%
Average: 19.8%
Downloads: 20.5%
Dependent repos count: 21.6%
Forks count: 29.8%
Maintainers (1)
Last synced: 11 months ago

Dependencies

Cargo.lock cargo
  • autocfg 1.1.0
  • bitflags 1.3.2
  • built 0.5.1
  • cargo-lock 7.1.0
  • cfg-if 1.0.0
  • chrono 0.4.19
  • circular 0.3.0
  • either 1.6.1
  • err-derive 0.3.1
  • form_urlencoded 1.0.1
  • gb-io 0.7.1
  • getrandom 0.2.6
  • idna 0.2.3
  • indoc 1.0.6
  • itertools 0.10.3
  • lazy_static 1.4.0
  • libc 0.2.125
  • lock_api 0.4.7
  • log 0.4.17
  • matches 0.1.9
  • memchr 2.5.0
  • new_debug_unreachable 1.0.4
  • nom 4.2.3
  • num-integer 0.1.45
  • num-traits 0.2.15
  • once_cell 1.10.0
  • parking_lot 0.12.0
  • parking_lot_core 0.9.3
  • percent-encoding 2.1.0
  • phf_generator 0.10.0
  • phf_shared 0.10.0
  • ppv-lite86 0.2.16
  • precomputed-hash 0.1.1
  • proc-macro-error 1.0.4
  • proc-macro-error-attr 1.0.4
  • proc-macro2 1.0.38
  • pyo3 0.16.4
  • pyo3-build-config 0.16.4
  • pyo3-built 0.4.7
  • pyo3-ffi 0.16.4
  • pyo3-macros 0.16.4
  • pyo3-macros-backend 0.16.4
  • quote 1.0.18
  • rand 0.8.5
  • rand_chacha 0.3.1
  • rand_core 0.6.3
  • redox_syscall 0.2.13
  • rustversion 1.0.6
  • scopeguard 1.1.0
  • semver 1.0.9
  • serde 1.0.137
  • serde_bytes 0.11.6
  • serde_derive 1.0.137
  • siphasher 0.3.10
  • smallvec 1.8.0
  • string_cache 0.8.4
  • string_cache_codegen 0.5.2
  • syn 1.0.93
  • synstructure 0.12.6
  • target-lexicon 0.12.3
  • time 0.1.43
  • tinyvec 1.6.0
  • tinyvec_macros 0.1.0
  • toml 0.5.9
  • unicode-bidi 0.3.8
  • unicode-normalization 0.1.19
  • unicode-xid 0.2.3
  • unindent 0.1.9
  • url 2.2.2
  • version_check 0.1.5
  • version_check 0.9.4
  • wasi 0.10.2+wasi-snapshot-preview1
  • winapi 0.3.9
  • winapi-i686-pc-windows-gnu 0.4.0
  • winapi-x86_64-pc-windows-gnu 0.4.0
  • windows-sys 0.36.1
  • windows_aarch64_msvc 0.36.1
  • windows_i686_gnu 0.36.1
  • windows_i686_msvc 0.36.1
  • windows_x86_64_gnu 0.36.1
  • windows_x86_64_msvc 0.36.1
Cargo.toml cargo
  • lazy_static 1.4.0 development
  • gb-io 0.7.1
  • libc 0.2.62
  • pyo3 0.16.1
  • pyo3-built 0.4.6
.github/workflows/requirements.txt pypi
  • auditwheel *
  • requests *
  • setuptools >=41.0
  • setuptools-rust *
  • wheel *
.github/workflows/package.yml actions
  • actions-rs/toolchain v1 composite
  • actions/checkout v3 composite
  • actions/checkout v1 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v1 composite
  • actions/upload-artifact v3 composite
  • docker/setup-qemu-action v2 composite
  • pypa/cibuildwheel v2.11.3 composite
  • pypa/gh-action-pypi-publish master composite
  • rasmus-saks/release-a-changelog-action v1.0.1 composite
.github/workflows/test.yml actions
  • ATiltedTree/setup-rust v1 composite
  • actions-rs/tarpaulin v0.1 composite
  • actions-rs/toolchain v1 composite
  • actions/checkout v1 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v2 composite
pyproject.toml pypi
setup.py pypi
docs/requirements.txt pypi
  • ipython *
  • nbsphinx *
  • pygments *
  • pygments-style-monokailight *
  • recommonmark *
  • semantic_version *
  • setuptools >=46.4
  • setuptools-rust >=1.9.0
  • sphinx >=4.0