8 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.
Needletail
Needletail is a MIT-licensed, minimal-copying FASTA/FASTQ parser and k-mer processing library for Rust.
The goal is to write a fast and well-tested set of functions that more specialized bioinformatics programs can use. Needletail's goal is to be as fast as the readfq C library at parsing FASTX files and much (i.e. 25 times) faster than equivalent Python implementations at k-mer counting.
Example
extern crate needletail;
use needletail::{parse_fastx_file, Sequence, FastxReader};
fn main() {
let filename = "tests/data/28S.fasta";
let mut n_bases = 0;
let mut n_valid_kmers = 0;
let mut reader = parse_fastx_file(&filename).expect("valid path/file");
while let Some(record) = reader.next() {
let seqrec = record.expect("invalid record");
// keep track of the total number of bases
n_bases += seqrec.num_bases();
// normalize to make sure all the bases are consistently capitalized and
// that we remove the newlines since this is FASTA
let norm_seq = seqrec.normalize(false);
// we make a reverse complemented copy of the sequence first for
// `canonical_kmers` to draw the complemented sequences from.
let rc = norm_seq.reverse_complement();
// now we keep track of the number of AAAAs (or TTTTs via
// canonicalization) in the file; note we also get the position (i.0;
// in the event there were `N`-containing kmers that were skipped)
// and whether the sequence was complemented (i.2) in addition to
// the canonical kmer (i.1)
for (_, kmer, _) in norm_seq.canonical_kmers(4, &rc) {
if kmer == b"AAAA" {
n_valid_kmers += 1;
}
}
}
println!("There are {} bases in your file.", n_bases);
println!("There are {} AAAAs in your file.", n_valid_kmers);
}
Installation
Needletail requires rust and cargo to be installed.
Please use either your local package manager (homebrew, apt-get, pacman, etc) or install these via rustup.
Once you have Rust set up, you can include needletail in your Cargo.toml file like:
[dependencies]
needletail = "0.4"
To install needletail itself for development:
git clone https://github.com/onecodex/needletail
cargo test # to run tests
Python
Documentation
For a real example, you can refer to test_python.py.
The python library only raise one type of exception: NeedletailError.
There are 2 ways to parse a FASTA/FASTQ: one if you have a string (parse_fastx_string(content: str)) or a path to a file
(parse_fastx_file(path: str)). Those functions will raise if the file is not found or if the content is invalid and will return
an iterator.
from needletail import parse_fastx_file, NeedletailError, reverse_complement, normalize_seq
try:
for record in parse_fastx_file("myfile.fastq"):
print(record.id)
print(record.seq)
print(record.qual)
except NeedletailError:
print("Invalid Fastq file")
A record has the following shape:
class Record:
id: str
seq: str
qual: Optional[str]
def is_fasta(self) -> bool
def is_fastq(self) -> bool
def normalize(self, iupac: bool)
Note that normalize (see https://docs.rs/needletail/0.4.1/needletail/sequence/fn.normalize.html for what it does) will mutate self.seq.
It is also available as the normalize_seq(seq: str, iupac: bool) function which will return the normalized sequence in this case.
Lastly, there is also a reverse_complement(seq: str) that will do exactly what it says. This will not raise an error if you pass some invalid
characters.
Building
To work on the Python library on a Mac OS X/Unix system (requires Python 3):
pip install maturin
# finally, install the library in the local virtualenv
maturin develop --cargo-extra-args="--features=python"
To build the binary wheels and push to PyPI
# The Mac build requires switching through a few different python versions
maturin build --features python --release --strip
# The linux build is automated through cross-compiling in a docker image
docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin:main build --features=python --release --strip -f
twine upload target/wheels/*
Getting Help
Questions are best directed as GitHub issues. We plan to add more documentation soon, but in the meantime "doc" comments are included in the source.
Contributing
Please do! We're happy to discuss possible additions and/or accept pull requests.
Acknowledgements
Starting from 0.4, the parsers algorithms is taken from seq_io. While it has been slightly modified, it is mainly
coming from that library. Links to the original files are available in src/parser/fast{a,q}.rs.
Metadata
Release files for needletail 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Files added late
8 files were uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Built distributions (wheels)
Total release size: 5.4 MB
Release files / needletail-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.6 kB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
39d20c445d4e2e54e35de47cccff199332ac6e65f335dd6c087b5c073dbe64a7
|
|
BLAKE2b-256 checksum How to use checksums |
ab49f656ecaae8565ebcd2ad822ed6662303535f7023e392d86f4198f9f5e121
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.2 kB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
ee204f731c82b6c0efcde8d5c8e8bca233c680b5c255cb837a2dafbce533453a
|
|
BLAKE2b-256 checksum How to use checksums |
50a05abd6a9a2a6345c5a083423e05b73b3995ff25ef006d11a5699e5aca1489
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.8 kB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
1ac331a1c73e1862f1ed640d73fd25020813672a3ca7c81875a915dff035224e
|
|
BLAKE2b-256 checksum How to use checksums |
3292e1b8fb6fc15d79ad018eca21183eae4ceec85e4b6d8098afe359343cf52f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.2 kB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
9666dd7fa76b63fb6d48a59f97e177f3f20734d3a93b459367da962f9d63b646
|
|
BLAKE2b-256 checksum How to use checksums |
04e09bb72c0a586558a74f16707bf3bc2b15e7ce70173b0d4d471d1c9cdd1bf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 311.0 kB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.7 PyPy 3.7 7.3 |
|
SHA-256 checksum How to use checksums |
05c77bba1f5f7611df65ec1fa4ed3536844b46e92928b3d18abd27e1d0f0e7c6
|
|
BLAKE2b-256 checksum How to use checksums |
ed138c6df6aefae088ae528d5ebae394f018cfb27ba6cf2f8bbeb34d7bab926b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 292.8 kB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.7 PyPy 3.7 7.3 |
|
SHA-256 checksum How to use checksums |
21b283f39915d0354d69b99efb8cbfc9d4619190226ef5ebf2a1aae6b655d982
|
|
BLAKE2b-256 checksum How to use checksums |
f98de3da1bac76f8e3c2fcaaab78bf130fd3656807be715fa8d766f365481d33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.3 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
0f805e6d3d2e402d836182e20cbd29b883fb3759e7909bd943c670169be9a700
|
|
BLAKE2b-256 checksum How to use checksums |
b0c2c390d7fce818902cfd92d983a3d6a5d60d2abb5c076de465108593944b37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.0 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
c548b702dffe2ad871576ed39521e322f85db1b2851f639b98fd0ae2341a937d
|
|
BLAKE2b-256 checksum How to use checksums |
27104a9ecc2179d37f5ea737a1a7a07fe40bd3a6e157a6b8a896fd6a6ecda18f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bb9eeb478545ff41752a583056913e6df8f2a7e30e12d05b62a9b6c29258ea18
|
|
BLAKE2b-256 checksum How to use checksums |
ad0b4f583f25eb98987a0b69d203d70b9dc364a42dedcd934f447efa18b5a807
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.0 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
8c960065a1f663433edf49cd892640684fcc2d30c617026265b87256db669025
|
|
BLAKE2b-256 checksum How to use checksums |
1c924302ef787725d547bf191e5163191e6f0e5c6ae4614981ea28dc93733130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | needletail-0.5.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 284.9 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
531a12fbe688161bd26441dbcf167970ad211dc8c27b4d80b8bf82106e853f5b
|
|
BLAKE2b-256 checksum How to use checksums |
9ed5406421878da7e35ac6fbfa41f1c50901ced7d25e871dd686ec689b992533
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-cp310-cp310-macosx_10_7_x86_64.whl
| Download URL | needletail-0.5.0-cp310-cp310-macosx_10_7_x86_64.whl |
|---|---|
| Size | 274.6 kB |
| Tags | CPython 3.10 macOS 10.7+ x86-64 |
|
SHA-256 checksum How to use checksums |
7a6829308ff66c9e865927609ed2bae2eca14049a9963b79fc77dd061a3198d5
|
|
BLAKE2b-256 checksum How to use checksums |
5fcfdf837654474cc2d4a7d8b167944e377c0c33e8f4a53c4f31c52edc4ddafe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.3 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b9b2b9570bf2062a99bf0429f4ba7bcecda2d3ee954d34a4fa928f44aeb0444e
|
|
BLAKE2b-256 checksum How to use checksums |
ad487f3b88fbb22eb23d30278f306ade6cba34488372b954c7c912d635b3c927
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
06886a45991e1567ccc271c18b28185b7de0740a078742d6393315d708c3e9ab
|
|
BLAKE2b-256 checksum How to use checksums |
bb0afa8fc0559189dd41c09bc8971c8160749325697ea43edf1c49720c23793a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.6 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
457c4b13f7661e74bb2e625bc6d6b1b59997ac3983c7dc36e9bffd9248b80627
|
|
BLAKE2b-256 checksum How to use checksums |
3fc8b69b2a0263a27cc15201aecab58ea555b2f600ddadba8e909e011f2e09dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.2 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
9132b325ffe111607eed06bc86313037ce6be0001e94da7c90e46d642e489eeb
|
|
BLAKE2b-256 checksum How to use checksums |
38bf4032407b4d4f361e49218ef2b2ba80c667a9f25ef9066cb80f4d54f55433
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / needletail-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | needletail-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 308.6 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5c93c89aeadd141b076d377d1d23a0e01162af4753c11628d5e18fe84e9344b6
|
|
BLAKE2b-256 checksum How to use checksums |
4c89479c5980a696c2884e58706995a60fd37ee9d6cd11c84699f5619da45fac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / needletail-0.5.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | needletail-0.5.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 290.2 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
892e7b9c301c64f48c8cb841ebe7e91ce62c070e60f3faeeedd41120468868af
|
|
BLAKE2b-256 checksum How to use checksums |
4bd737767b76129fb481e33fac0b041d1b8ed579026ef2eac1a6ce86dcffbcf3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Security for needletail 0.5.0
Upload timing
Release files added late
8 files were uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.