FASTA file parsing written in C++ with Python bindings
Installation
pip install pyfastatools
Usage
The pyfastatools.Parser object is the primary API that parses FASTA files and yields pyfastatools.Record objects.
If you have a FASTA file called proteins.faa that looks like this:
>seq_1
MSKFKKIPL
>seq_2
MQSSSKTCN
>seq_3
MEDNMITIY
Then you can parse this file in python like this:
from pyfastatools import Parser
for record in Parser("proteins.faa"):
print(record.header.name, record.seq)
which will print:
>>> 'seq_1 MSKFKKIPL'
>>> 'seq_2 MQSSSKTCN'
>>> 'seq_3 MEDNMITIY'
API
This library has a very simple API that can be displayed in a few lines:
Parser
This is the main class that will satisfy 99% of user needs. While parsing FASTA files, it produces Record objects. Only the name of a FASTA file is needed:
pyfastatools.Parser("my_fasta.fasta")
The parser will attempt to auto-detect the RecordType of the file by checking the input file extension and the first 5 sequences.
However, the record type can optionally be specified:
pyfastatools.Parser("my_fasta.fasta", pyfastatools.RecordType.PROTEIN)
The parser can be iterated over to yield one Record at a time:
parser = pyfastatools.Parser("my_fasta.fasta")
for record in parser:
...
Methods
There are also other convenience methods:
all- Read all records into a list-like object.take- Take up to n records into a list-like object.filter- Keep/exclude sequences based on the sequence name.remove_stops- Yield sequences without a*stop codon character if the sequences are proteins.clean_header- Yield sequences while cleaning the header to not have a description.headers- YieldHeaderobjects only without parsing the sequence itself.all_headers- Return all headers into a list-like object.
Properties
num_records- Returns the number of sequences in the FASTA file. This is cached after the first time it is called. Note: This can also be computed usinglen(parser)format- Returns theRecordTypeenum that corresponds to the FASTA file's record typeextension- Returns the file extension based on theformat
Record
A single FASTA record. It has the following fields:
header- AHeaderobject that has the fieldsnameanddescseq- Astrstoring the entire sequence
Methods
empty- Checks if theHeaderand sequence are emptyclear- Sets theHeaderand sequence to empty stringsto_string- Returns the record as a string representation identical to what was parsed from the fileclean_header- Sets theHeaderdescription to an empty stringremove_stops- Removes*stop codon characters from the sequence if they are present
Release files for pyfastatools 2.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyfastatools-2.5.0.tar.gz | 62.0 kB | Details |
Built distributions (wheels)
Total release size: 7.4 MB
Release files / pyfastatools-2.5.0.tar.gz
| Download URL | pyfastatools-2.5.0.tar.gz |
|---|---|
| Size | 62.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9421963b45ac4daa24d3fca25fef5e8b4f11fcdc9d194ebd372a3590ee21a40
|
|
BLAKE2b-256 checksum How to use checksums |
0176266632d468f35b6bae1e68f114bd3345dd5b847a15b780215c44524184af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfastatools-2.5.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 166.7 kB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.10 PyPy 3.10 7.3 |
|
SHA-256 checksum How to use checksums |
35ce69e9009cdb51920c0c9ec2d1cd9dab3c1fa569cb5ba44ebc96f47b8be975
|
|
BLAKE2b-256 checksum How to use checksums |
6e709a6d34d4e756f0bba1562ee96ff49ba50f0f90bee454f0d5e63693fd3ef3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyfastatools-2.5.0-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 178.6 kB |
| Tags | Linux glibc 2.17+ x86-32 PyPy 3.10 PyPy 3.10 7.3 |
|
SHA-256 checksum How to use checksums |
5277cef87e0d0bd24b9bcbaa1215072d0aa442e7c3638ebbb37eb7bf5392ca07
|
|
BLAKE2b-256 checksum How to use checksums |
0aa105919e78bbe5528135496b1b50085247a9423673d26af4acea34176764e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfastatools-2.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 166.7 kB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
2f0323489fc0348c01255917aee6f5880efb3e901fd7b85393d7ea85e734c9a4
|
|
BLAKE2b-256 checksum How to use checksums |
32e8ede8063de725af7b3f232ccfabb0741eef44531556e0209828e0b48a6093
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyfastatools-2.5.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 178.6 kB |
| Tags | Linux glibc 2.17+ x86-32 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
dfd1aded4e119a97542fb4dda7d1e8966227857e3ba9a1a81728f972052c8378
|
|
BLAKE2b-256 checksum How to use checksums |
aa78a98fb290ed89bbe7546822fec86c4181676a10f28155beb47568184c440f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp312-abi3-musllinux_1_2_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp312-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 628.6 kB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
33feacd8f98ce5780e04a3a5dfa4253c1bbb265e3fc7ab6685a4033be749c1f2
|
|
BLAKE2b-256 checksum How to use checksums |
564cccac3f3d324ac2d567cf3a2ef757356cd683f124866a8b2f13012a0d2e9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp312-abi3-musllinux_1_2_i686.whl
| Download URL | pyfastatools-2.5.0-cp312-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 683.5 kB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
96eb1786002870142677b9e8bc58818dd37a9097c9b21db74996f38ad755c582
|
|
BLAKE2b-256 checksum How to use checksums |
1c68957ad61214d0ac0ad02bdfccf2bafef94e5b81545ee453d7b85fd7c7f11e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 169.6 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
39acfeb9305749aed4693e7cd39f0e65592368d302e0d719ffd6d55ff345a3f4
|
|
BLAKE2b-256 checksum How to use checksums |
0317cc50dcc9cf697c79982711f8222b540a86d49b62dc42d90c20350017267b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp312-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyfastatools-2.5.0-cp312-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 182.2 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
23d9d57da7f598485198c82ccd7c8a40b49996bcf63ecffcddd9a2d0aaec96aa
|
|
BLAKE2b-256 checksum How to use checksums |
b99130c47bc7fca6e2e462f46d7cd967acfc323d413f52059d15df8283b59347
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 629.1 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
780c7f8fa026dbb7c0a4c36c1ce835b0d8f05fe7e6d37f48db9775d9e2bac3a0
|
|
BLAKE2b-256 checksum How to use checksums |
bbe79f62bb8c7835e2b8c1827fe9a104d1cb1b2ef530905552357ffc269d58eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp311-cp311-musllinux_1_2_i686.whl
| Download URL | pyfastatools-2.5.0-cp311-cp311-musllinux_1_2_i686.whl |
|---|---|
| Size | 684.7 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-32 |
|
SHA-256 checksum How to use checksums |
4ab8bdb4fc965dc201d12b638a58d104755f1350be1507b6a1e6c4ea23283ae8
|
|
BLAKE2b-256 checksum How to use checksums |
5f4ce83df72c88e8eb3f01a89cf71013a6e22ececb4f59fb503abeb4c83c11be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 171.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
369af614fb68b70a9a84c7f84927efbecb7edb9da307a1b1e699da71c391bc2b
|
|
BLAKE2b-256 checksum How to use checksums |
b884b40899390144e1cf3e3bb1a52fd189f97454a69e18cea63bb99ef28ad9a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyfastatools-2.5.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 183.0 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
5e681ca8186317e8dd87a4594e2d825b2eb04967184a66f473e1c79204066096
|
|
BLAKE2b-256 checksum How to use checksums |
5668c48096116cbc7135baa3aee3d92c769c8f8dc98f453cab6e94ef7ae00b85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp310-cp310-musllinux_1_2_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp310-cp310-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 628.9 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
c81658256c4f4c9497ff1e93adbc91dbd18fc1f9ae7d77d409f12508632776e3
|
|
BLAKE2b-256 checksum How to use checksums |
045354dd5693c6aa17f24952f87004af701ebe51493f200d42e0e308c55d06e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp310-cp310-musllinux_1_2_i686.whl
| Download URL | pyfastatools-2.5.0-cp310-cp310-musllinux_1_2_i686.whl |
|---|---|
| Size | 684.0 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-32 |
|
SHA-256 checksum How to use checksums |
0074628866264071e925c844d949dc99148fcfe2174b65ff8c3bf11e9bd617d0
|
|
BLAKE2b-256 checksum How to use checksums |
83e48f852e1e8d9dc2d99fcf6f5f9226dd3c12ed4dd3b7500b5b57adda914081
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 170.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
76b3fc77e56f11fd3a9f9661964745fe9363b91ffe6e54e187956de8c139cd23
|
|
BLAKE2b-256 checksum How to use checksums |
cdde05c42d0d494662e3f002d0db428cb665b8d97bd16cc0233cb2583348413a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyfastatools-2.5.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 182.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
9c89f1752291c9e03b34e805c0e41c6d0cac80a6b7b9c2c6138ca543f06387d4
|
|
BLAKE2b-256 checksum How to use checksums |
f915553f63bc648aac220f7500144c12b850d3b7161f01d8710c8630828bf41e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp39-cp39-musllinux_1_2_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp39-cp39-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 629.1 kB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
9d6970d815188bfd8172cb0e006db1973a1cb3b51482e33a0f0d31e9ca077abc
|
|
BLAKE2b-256 checksum How to use checksums |
98866a92afeeb522ae496afb3c573d7197283603cee6a8e04a79e8452cb4a3d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp39-cp39-musllinux_1_2_i686.whl
| Download URL | pyfastatools-2.5.0-cp39-cp39-musllinux_1_2_i686.whl |
|---|---|
| Size | 684.3 kB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-32 |
|
SHA-256 checksum How to use checksums |
0c750eb7a67deb7b2e8a35998ae834086d293b106561d5a77142aa2873b02c17
|
|
BLAKE2b-256 checksum How to use checksums |
ca2dd10198940f4befe20e6a55f095ae54012f356c2acfe5c3277ccbb96db23d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfastatools-2.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 171.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
f6fa07ec16796be85e5e149bccc1a43f7fd5a60b7d8b08ff833d9aeb7da0376a
|
|
BLAKE2b-256 checksum How to use checksums |
0bcdbca08bb4c78f8ffc9d87ea194cc9351ebda4d88dc2a3a72b66350d742336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|
Release files / pyfastatools-2.5.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyfastatools-2.5.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 182.8 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
0b5dc93a48dffe4269f8c780f8a299fc3398d5f273189f8da13dc40bc1c2c06f
|
|
BLAKE2b-256 checksum How to use checksums |
be8dcf2299125145160bfa13bcf1c9f372ae41597585ad44d0001d9799c32741
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.19
|