gtfparse
Read GTF (gene transfer format) annotations into a pandas DataFrame, with one row per feature and attribute values such as gene and transcript IDs expanded into columns.
Install
python -m pip install gtfparse
Python 3.11 or later is required. For optional Polars output, install
gtfparse[polars].
Read an annotation and find genes
This small artificial GTF runs without a download. Replace the stream with your annotation filename when working with a real dataset.
from io import StringIO
from gtfparse import read_gtf
annotation = StringIO(
'1\texample\tgene\t101\t200\t.\t+\t.\tgene_id "g1"; gene_name "EXAMPLE";\n'
'1\texample\texon\t101\t150\t.\t+\t.\tgene_id "g1"; transcript_id "t1";\n'
)
features = read_gtf(annotation)
genes = features.loc[features["feature"] == "gene"]
print(genes["gene_name"].tolist())
for row in features.itertuples():
print(row.feature, row.seqname, row.start, row.end, row.gene_id)
['EXAMPLE']
gene 1 101 200 g1
exon 1 101 150 g1
feature identifies the row type. seqname is the chromosome or contig name;
it is not the gene ID. The ninth GTF field supplies attributes such as
gene_id, gene_name and transcript_id.
Documentation
- Filter features, select chromosomes, write GTF and read numeric attributes
- Progress callbacks
- Version 3 migration and optional Polars output
- Complete API reference
To build the documentation locally, run
python -m pip install -r requirements-docs.txt and ./docs.sh.
python scripts/check_docs_examples.py checks the printed example output.
Metadata
Release files for gtfparse 3.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gtfparse-3.0.5.tar.gz | 142.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gtfparse-3.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 165.3 kB
Release files / gtfparse-3.0.5.tar.gz
| Download URL | gtfparse-3.0.5.tar.gz |
|---|---|
| Size | 142.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fde8c2048eda59f47f1d088a0cf1572bd88dd14db2554c44fe8b5f87722ad427
|
|
BLAKE2b-256 checksum How to use checksums |
31d37e026c1102fa5ab529d320d77d02697b90f99dc90b42dde85f7d4b5f3b9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.12
|
Release files / gtfparse-3.0.5-py3-none-any.whl
| Download URL | gtfparse-3.0.5-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5d3c0174affebbaa69183709db66b40e5e4be94f183543b55c3f17259d39f1b
|
|
BLAKE2b-256 checksum How to use checksums |
16a9661d5b08aebbd352ca826e91902a262739d988fc51b8b90b5fb2b3a5bfda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.12
|
Security for gtfparse 3.0.5
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.