gtfparse 3.0.2__tar.gz → 3.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gtfparse-3.0.4/PKG-INFO +101 -0
- gtfparse-3.0.4/README.md +68 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/__init__.py +1 -1
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/attribute_parsing.py +5 -2
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/create_missing_features.py +5 -2
- gtfparse-3.0.4/gtfparse.egg-info/PKG-INFO +101 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse.egg-info/SOURCES.txt +0 -1
- gtfparse-3.0.2/PKG-INFO +0 -157
- gtfparse-3.0.2/README.md +0 -124
- gtfparse-3.0.2/gtfparse.egg-info/PKG-INFO +0 -157
- {gtfparse-3.0.2 → gtfparse-3.0.4}/LICENSE +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/MANIFEST.in +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/benchmarks/README.md +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/benchmarks/compare_readers.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/benchmarks/compare_releases.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/benchmarks/optimization-results.json +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/benchmarks/optimization.md +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/benchmarks/results.json +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/_polars.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/_read_csv.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/parsing_error.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/read_gtf.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse/write_gtf.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse.egg-info/dependency_links.txt +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse.egg-info/requires.txt +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/gtfparse.egg-info/top_level.txt +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/lint.sh +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/pyproject.toml +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/requirements.txt +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/setup.cfg +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/test.sh +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/__init__.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data/B16.stringtie.head.gtf +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data/ensembl_grch37.head.gtf +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data/ensembl_grch37.head.gtf.gz +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data/gencode.head.gtf +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data/gencode.real.head.gtf +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data/refseq.ucsc.small.gtf +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/data.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_attribute_optimization.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_attribute_values.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_create_missing_features.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_ensembl_gtf.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_expand_attribute_column_false.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_expand_attributes.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_gencode_gtf.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_multiple_values_for_tag_attribute.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_parse_gtf_lines.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_polars_compatibility.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_progress.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_read_stringtie_gtf.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_reader.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_refseq_gtf.py +0 -0
- {gtfparse-3.0.2 → gtfparse-3.0.4}/tests/test_write_gtf.py +0 -0
gtfparse-3.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gtfparse
|
|
3
|
+
Version: 3.0.4
|
|
4
|
+
Summary: Parsing library for extracting data frames of genomic features from GTF files
|
|
5
|
+
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/openvax/gtfparse
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/openvax/gtfparse/issues
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: pyarrow>=18.0.0
|
|
24
|
+
Requires-Dist: pandas>=2.2.2
|
|
25
|
+
Provides-Extra: polars
|
|
26
|
+
Requires-Dist: polars>=0.20.31; extra == "polars"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff; extra == "dev"
|
|
31
|
+
Requires-Dist: coveralls; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
[](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
|
|
35
|
+
[](https://coveralls.io/github/openvax/gtfparse?branch=master)
|
|
36
|
+
<a href="https://pypi.python.org/pypi/gtfparse/">
|
|
37
|
+
<img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
|
|
38
|
+
</a>
|
|
39
|
+
|
|
40
|
+
gtfparse
|
|
41
|
+
========
|
|
42
|
+
Read GTF (gene transfer format) annotations into a pandas DataFrame, with one
|
|
43
|
+
row per feature and attribute values such as gene and transcript IDs expanded
|
|
44
|
+
into columns.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
python -m pip install gtfparse
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Python 3.9 or later is required. For optional Polars output, install
|
|
53
|
+
`gtfparse[polars]`.
|
|
54
|
+
|
|
55
|
+
## Read an annotation and find genes
|
|
56
|
+
|
|
57
|
+
This small artificial GTF runs without a download. Replace the stream with
|
|
58
|
+
your annotation filename when working with a real dataset.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from io import StringIO
|
|
62
|
+
from gtfparse import read_gtf
|
|
63
|
+
|
|
64
|
+
annotation = StringIO(
|
|
65
|
+
'1\texample\tgene\t101\t200\t.\t+\t.\tgene_id "g1"; gene_name "EXAMPLE";\n'
|
|
66
|
+
'1\texample\texon\t101\t150\t.\t+\t.\tgene_id "g1"; transcript_id "t1";\n'
|
|
67
|
+
)
|
|
68
|
+
features = read_gtf(annotation)
|
|
69
|
+
genes = features.loc[features["feature"] == "gene"]
|
|
70
|
+
print(genes["gene_name"].tolist())
|
|
71
|
+
for row in features.itertuples():
|
|
72
|
+
print(row.feature, row.seqname, row.start, row.end, row.gene_id)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
['EXAMPLE']
|
|
77
|
+
gene 1 101 200 g1
|
|
78
|
+
exon 1 101 150 g1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`feature` identifies the row type. `seqname` is the chromosome or contig name;
|
|
82
|
+
it is not the gene ID. The ninth GTF field supplies attributes such as
|
|
83
|
+
`gene_id`, `gene_name` and `transcript_id`.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<a id="version-3-migration"></a>
|
|
87
|
+
<a id="reporting-parsing-progress"></a>
|
|
88
|
+
<a id="example-usage"></a>
|
|
89
|
+
<a id="parsing-all-rows-of-a-gtf-file-into-a-pandas-dataframe"></a>
|
|
90
|
+
<a id="getting-gene-fpkm-values-from-a-stringtie-gtf-file"></a>
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
- [Filter features, select chromosomes, write GTF and read numeric attributes](docs/guides/annotations.md)
|
|
95
|
+
- [Progress callbacks](docs/guides/progress.md)
|
|
96
|
+
- [Version 3 migration and optional Polars output](docs/guides/migration.md)
|
|
97
|
+
- [Complete API reference](docs/reference.md)
|
|
98
|
+
|
|
99
|
+
To build the documentation locally, run
|
|
100
|
+
`python -m pip install -r requirements-docs.txt` and `./docs.sh`.
|
|
101
|
+
`python scripts/check_docs_examples.py` checks the printed example output.
|
gtfparse-3.0.4/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
|
|
2
|
+
[](https://coveralls.io/github/openvax/gtfparse?branch=master)
|
|
3
|
+
<a href="https://pypi.python.org/pypi/gtfparse/">
|
|
4
|
+
<img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
|
|
5
|
+
</a>
|
|
6
|
+
|
|
7
|
+
gtfparse
|
|
8
|
+
========
|
|
9
|
+
Read GTF (gene transfer format) annotations into a pandas DataFrame, with one
|
|
10
|
+
row per feature and attribute values such as gene and transcript IDs expanded
|
|
11
|
+
into columns.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
python -m pip install gtfparse
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Python 3.9 or later is required. For optional Polars output, install
|
|
20
|
+
`gtfparse[polars]`.
|
|
21
|
+
|
|
22
|
+
## Read an annotation and find genes
|
|
23
|
+
|
|
24
|
+
This small artificial GTF runs without a download. Replace the stream with
|
|
25
|
+
your annotation filename when working with a real dataset.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from io import StringIO
|
|
29
|
+
from gtfparse import read_gtf
|
|
30
|
+
|
|
31
|
+
annotation = StringIO(
|
|
32
|
+
'1\texample\tgene\t101\t200\t.\t+\t.\tgene_id "g1"; gene_name "EXAMPLE";\n'
|
|
33
|
+
'1\texample\texon\t101\t150\t.\t+\t.\tgene_id "g1"; transcript_id "t1";\n'
|
|
34
|
+
)
|
|
35
|
+
features = read_gtf(annotation)
|
|
36
|
+
genes = features.loc[features["feature"] == "gene"]
|
|
37
|
+
print(genes["gene_name"].tolist())
|
|
38
|
+
for row in features.itertuples():
|
|
39
|
+
print(row.feature, row.seqname, row.start, row.end, row.gene_id)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
['EXAMPLE']
|
|
44
|
+
gene 1 101 200 g1
|
|
45
|
+
exon 1 101 150 g1
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`feature` identifies the row type. `seqname` is the chromosome or contig name;
|
|
49
|
+
it is not the gene ID. The ninth GTF field supplies attributes such as
|
|
50
|
+
`gene_id`, `gene_name` and `transcript_id`.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<a id="version-3-migration"></a>
|
|
54
|
+
<a id="reporting-parsing-progress"></a>
|
|
55
|
+
<a id="example-usage"></a>
|
|
56
|
+
<a id="parsing-all-rows-of-a-gtf-file-into-a-pandas-dataframe"></a>
|
|
57
|
+
<a id="getting-gene-fpkm-values-from-a-stringtie-gtf-file"></a>
|
|
58
|
+
|
|
59
|
+
## Documentation
|
|
60
|
+
|
|
61
|
+
- [Filter features, select chromosomes, write GTF and read numeric attributes](docs/guides/annotations.md)
|
|
62
|
+
- [Progress callbacks](docs/guides/progress.md)
|
|
63
|
+
- [Version 3 migration and optional Polars output](docs/guides/migration.md)
|
|
64
|
+
- [Complete API reference](docs/reference.md)
|
|
65
|
+
|
|
66
|
+
To build the documentation locally, run
|
|
67
|
+
`python -m pip install -r requirements-docs.txt` and `./docs.sh`.
|
|
68
|
+
`python scripts/check_docs_examples.py` checks the printed example output.
|
|
@@ -56,8 +56,11 @@ def expand_attribute_strings(
|
|
|
56
56
|
the start, every 10,000 rows, and at completion. An empty input emits
|
|
57
57
|
one ``("attributes", 0, 0)`` event. Callback exceptions propagate.
|
|
58
58
|
|
|
59
|
-
Returns
|
|
60
|
-
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
collections.OrderedDict
|
|
62
|
+
Column-to-value-list mappings, in the order the columns appeared in
|
|
63
|
+
the attribute strings.
|
|
61
64
|
"""
|
|
62
65
|
n = len(attribute_strings)
|
|
63
66
|
|
|
@@ -44,8 +44,11 @@ def create_missing_features(dataframe, unique_keys={}, extra_columns={}, missing
|
|
|
44
44
|
missing_value : any
|
|
45
45
|
Which value to fill in for columns that we don't infer values for.
|
|
46
46
|
|
|
47
|
-
Returns
|
|
48
|
-
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
pandas.DataFrame
|
|
50
|
+
Original rows (converted to pandas if necessary) together with the
|
|
51
|
+
extra rows created for missing features.
|
|
49
52
|
"""
|
|
50
53
|
if hasattr(dataframe, "to_pandas"):
|
|
51
54
|
dataframe = dataframe.to_pandas()
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gtfparse
|
|
3
|
+
Version: 3.0.4
|
|
4
|
+
Summary: Parsing library for extracting data frames of genomic features from GTF files
|
|
5
|
+
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/openvax/gtfparse
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/openvax/gtfparse/issues
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: pyarrow>=18.0.0
|
|
24
|
+
Requires-Dist: pandas>=2.2.2
|
|
25
|
+
Provides-Extra: polars
|
|
26
|
+
Requires-Dist: polars>=0.20.31; extra == "polars"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff; extra == "dev"
|
|
31
|
+
Requires-Dist: coveralls; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
[](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
|
|
35
|
+
[](https://coveralls.io/github/openvax/gtfparse?branch=master)
|
|
36
|
+
<a href="https://pypi.python.org/pypi/gtfparse/">
|
|
37
|
+
<img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
|
|
38
|
+
</a>
|
|
39
|
+
|
|
40
|
+
gtfparse
|
|
41
|
+
========
|
|
42
|
+
Read GTF (gene transfer format) annotations into a pandas DataFrame, with one
|
|
43
|
+
row per feature and attribute values such as gene and transcript IDs expanded
|
|
44
|
+
into columns.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
python -m pip install gtfparse
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Python 3.9 or later is required. For optional Polars output, install
|
|
53
|
+
`gtfparse[polars]`.
|
|
54
|
+
|
|
55
|
+
## Read an annotation and find genes
|
|
56
|
+
|
|
57
|
+
This small artificial GTF runs without a download. Replace the stream with
|
|
58
|
+
your annotation filename when working with a real dataset.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from io import StringIO
|
|
62
|
+
from gtfparse import read_gtf
|
|
63
|
+
|
|
64
|
+
annotation = StringIO(
|
|
65
|
+
'1\texample\tgene\t101\t200\t.\t+\t.\tgene_id "g1"; gene_name "EXAMPLE";\n'
|
|
66
|
+
'1\texample\texon\t101\t150\t.\t+\t.\tgene_id "g1"; transcript_id "t1";\n'
|
|
67
|
+
)
|
|
68
|
+
features = read_gtf(annotation)
|
|
69
|
+
genes = features.loc[features["feature"] == "gene"]
|
|
70
|
+
print(genes["gene_name"].tolist())
|
|
71
|
+
for row in features.itertuples():
|
|
72
|
+
print(row.feature, row.seqname, row.start, row.end, row.gene_id)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
['EXAMPLE']
|
|
77
|
+
gene 1 101 200 g1
|
|
78
|
+
exon 1 101 150 g1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`feature` identifies the row type. `seqname` is the chromosome or contig name;
|
|
82
|
+
it is not the gene ID. The ninth GTF field supplies attributes such as
|
|
83
|
+
`gene_id`, `gene_name` and `transcript_id`.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<a id="version-3-migration"></a>
|
|
87
|
+
<a id="reporting-parsing-progress"></a>
|
|
88
|
+
<a id="example-usage"></a>
|
|
89
|
+
<a id="parsing-all-rows-of-a-gtf-file-into-a-pandas-dataframe"></a>
|
|
90
|
+
<a id="getting-gene-fpkm-values-from-a-stringtie-gtf-file"></a>
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
- [Filter features, select chromosomes, write GTF and read numeric attributes](docs/guides/annotations.md)
|
|
95
|
+
- [Progress callbacks](docs/guides/progress.md)
|
|
96
|
+
- [Version 3 migration and optional Polars output](docs/guides/migration.md)
|
|
97
|
+
- [Complete API reference](docs/reference.md)
|
|
98
|
+
|
|
99
|
+
To build the documentation locally, run
|
|
100
|
+
`python -m pip install -r requirements-docs.txt` and `./docs.sh`.
|
|
101
|
+
`python scripts/check_docs_examples.py` checks the printed example output.
|
gtfparse-3.0.2/PKG-INFO
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: gtfparse
|
|
3
|
-
Version: 3.0.2
|
|
4
|
-
Summary: Parsing library for extracting data frames of genomic features from GTF files
|
|
5
|
-
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
|
-
License-Expression: Apache-2.0
|
|
7
|
-
Project-URL: Homepage, https://github.com/openvax/gtfparse
|
|
8
|
-
Project-URL: Bug Tracker, https://github.com/openvax/gtfparse/issues
|
|
9
|
-
Classifier: Development Status :: 4 - Beta
|
|
10
|
-
Classifier: Environment :: Console
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Intended Audience :: Science/Research
|
|
13
|
-
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
-
Requires-Python: >=3.9
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
License-File: LICENSE
|
|
23
|
-
Requires-Dist: pyarrow>=18.0.0
|
|
24
|
-
Requires-Dist: pandas>=2.2.2
|
|
25
|
-
Provides-Extra: polars
|
|
26
|
-
Requires-Dist: polars>=0.20.31; extra == "polars"
|
|
27
|
-
Provides-Extra: dev
|
|
28
|
-
Requires-Dist: pytest; extra == "dev"
|
|
29
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
30
|
-
Requires-Dist: ruff; extra == "dev"
|
|
31
|
-
Requires-Dist: coveralls; extra == "dev"
|
|
32
|
-
Dynamic: license-file
|
|
33
|
-
|
|
34
|
-
[](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
|
|
35
|
-
[](https://coveralls.io/github/openvax/gtfparse?branch=master)
|
|
36
|
-
<a href="https://pypi.python.org/pypi/gtfparse/">
|
|
37
|
-
<img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
|
|
38
|
-
</a>
|
|
39
|
-
|
|
40
|
-
gtfparse
|
|
41
|
-
========
|
|
42
|
-
Parsing tools for GTF (gene transfer format) files.
|
|
43
|
-
|
|
44
|
-
## Version 3 migration
|
|
45
|
-
|
|
46
|
-
`read_gtf`, `parse_gtf`, and `parse_gtf_and_expand_attributes` now return pandas
|
|
47
|
-
DataFrames by default. GTF reading uses PyArrow; attribute processing and writing
|
|
48
|
-
use pandas. Polars is no longer a required dependency and is imported only for
|
|
49
|
-
explicit Polars conversion. Ordinary installations need only pandas and PyArrow.
|
|
50
|
-
|
|
51
|
-
```sh
|
|
52
|
-
pip install gtfparse
|
|
53
|
-
# Optional, for applications that still request Polars frames:
|
|
54
|
-
pip install 'gtfparse[polars]'
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```python
|
|
58
|
-
from gtfparse import read_gtf, write_gtf
|
|
59
|
-
|
|
60
|
-
df = read_gtf("gene_annotations.gtf") # pandas.DataFrame
|
|
61
|
-
write_gtf(df, "gene_annotations.gtf.gz")
|
|
62
|
-
|
|
63
|
-
# Requires the optional extra:
|
|
64
|
-
polars_df = read_gtf("gene_annotations.gtf", result_type="polars")
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Existing pandas and dictionary callers retain their output shape, fixed-column
|
|
68
|
-
dtypes, attribute handling, filters, converters and progress callbacks. Applications
|
|
69
|
-
that used the previous default Polars output should add `result_type="polars"`
|
|
70
|
-
and install the extra, or use pandas methods. `write_gtf` accepts either frame
|
|
71
|
-
type. The legacy `parse_with_polars_lazy` helper remains an optional adapter:
|
|
72
|
-
it reads the file eagerly and returns a Polars LazyFrame, as before.
|
|
73
|
-
|
|
74
|
-
Empty or malformed GTF fields now raise `gtfparse.ParsingError`, including wrong
|
|
75
|
-
field counts and invalid numeric fields. Whole comment lines are ignored;
|
|
76
|
-
literal `#` inside attributes is preserved. Text and binary streams stay open
|
|
77
|
-
after parsing, and gzip is detected from its contents.
|
|
78
|
-
|
|
79
|
-
## Reporting parsing progress
|
|
80
|
-
|
|
81
|
-
Pass `progress_callback(stage, completed, total)` to `read_gtf` to connect
|
|
82
|
-
parsing to your own progress UI. The callback runs synchronously; exceptions
|
|
83
|
-
from it stop parsing and propagate to the caller. Without a callback, gtfparse
|
|
84
|
-
does not display a progress bar or add a progress-library dependency.
|
|
85
|
-
|
|
86
|
-
| Stage | Reports |
|
|
87
|
-
| --- | --- |
|
|
88
|
-
| `read` | `(0, None)` before loading/filtering the file; `(rows, rows)` after it succeeds |
|
|
89
|
-
| `attributes` | `(0, rows)`, then every 10,000 rows, then `(rows, rows)` |
|
|
90
|
-
| `convert` | `(0, None)` before output conversion/transforms; `(rows, rows)` after success |
|
|
91
|
-
|
|
92
|
-
Counts refer to rows retained after `features` filtering, not bytes or overall
|
|
93
|
-
percentages. `None` means the total is unknown: loading and conversion expose
|
|
94
|
-
only stage boundaries, so use an indeterminate indicator during those steps.
|
|
95
|
-
Attribute expansion is omitted when `expand_attribute_column=False`. A stage
|
|
96
|
-
that fails does not emit completion. An empty filtered result is supported;
|
|
97
|
-
its attributes stage emits a single `(0, 0)` event. Empty input files raise `gtfparse.ParsingError`.
|
|
98
|
-
|
|
99
|
-
For example, with the optional `tqdm` package installed:
|
|
100
|
-
|
|
101
|
-
```python
|
|
102
|
-
from gtfparse import read_gtf
|
|
103
|
-
from tqdm.auto import tqdm
|
|
104
|
-
|
|
105
|
-
with tqdm(unit="rows") as bar:
|
|
106
|
-
def show_progress(stage, completed, total):
|
|
107
|
-
if stage != bar.desc:
|
|
108
|
-
bar.total = total
|
|
109
|
-
bar.reset()
|
|
110
|
-
bar.set_description_str(stage)
|
|
111
|
-
bar.total = total
|
|
112
|
-
bar.update(completed - bar.n)
|
|
113
|
-
bar.refresh()
|
|
114
|
-
|
|
115
|
-
df = read_gtf("gene_annotations.gtf", progress_callback=show_progress)
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
`parse_gtf` reports the `read` stage, `parse_gtf_and_expand_attributes` reports
|
|
119
|
-
`read` and `attributes`, `parse_gtf_pandas` reports `read` and `convert`, and
|
|
120
|
-
`expand_attribute_strings` reports only `attributes` using the same callback.
|
|
121
|
-
|
|
122
|
-
Quoted attribute values preserve spaces, semicolons, and apostrophes. Raw
|
|
123
|
-
attributes (`expand_attribute_column=False`) retain their original quote marks.
|
|
124
|
-
|
|
125
|
-
# Example usage
|
|
126
|
-
|
|
127
|
-
## Parsing all rows of a GTF file into a Pandas DataFrame
|
|
128
|
-
|
|
129
|
-
```python
|
|
130
|
-
from gtfparse import read_gtf
|
|
131
|
-
|
|
132
|
-
# returns GTF with essential columns such as "feature", "seqname", "start", "end"
|
|
133
|
-
# alongside the names of any optional keys which appeared in the attribute column
|
|
134
|
-
df = read_gtf("gene_annotations.gtf")
|
|
135
|
-
|
|
136
|
-
# filter DataFrame to gene entries on chrY
|
|
137
|
-
df_genes = df[df["feature"] == "gene"]
|
|
138
|
-
df_genes_chrY = df_genes[df_genes["seqname"] == "Y"]
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
## Getting gene FPKM values from a StringTie GTF file
|
|
143
|
-
|
|
144
|
-
```python
|
|
145
|
-
from gtfparse import read_gtf
|
|
146
|
-
|
|
147
|
-
df = read_gtf(
|
|
148
|
-
"Transcripts.gtf",
|
|
149
|
-
column_converters={"FPKM": float})
|
|
150
|
-
|
|
151
|
-
gene_fpkms = {
|
|
152
|
-
gene_name: fpkm
|
|
153
|
-
for (gene_name, fpkm, feature)
|
|
154
|
-
in zip(df["seqname"], df["FPKM"], df["feature"])
|
|
155
|
-
if feature == "gene"
|
|
156
|
-
}
|
|
157
|
-
```
|
gtfparse-3.0.2/README.md
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
[](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
|
|
2
|
-
[](https://coveralls.io/github/openvax/gtfparse?branch=master)
|
|
3
|
-
<a href="https://pypi.python.org/pypi/gtfparse/">
|
|
4
|
-
<img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
|
|
5
|
-
</a>
|
|
6
|
-
|
|
7
|
-
gtfparse
|
|
8
|
-
========
|
|
9
|
-
Parsing tools for GTF (gene transfer format) files.
|
|
10
|
-
|
|
11
|
-
## Version 3 migration
|
|
12
|
-
|
|
13
|
-
`read_gtf`, `parse_gtf`, and `parse_gtf_and_expand_attributes` now return pandas
|
|
14
|
-
DataFrames by default. GTF reading uses PyArrow; attribute processing and writing
|
|
15
|
-
use pandas. Polars is no longer a required dependency and is imported only for
|
|
16
|
-
explicit Polars conversion. Ordinary installations need only pandas and PyArrow.
|
|
17
|
-
|
|
18
|
-
```sh
|
|
19
|
-
pip install gtfparse
|
|
20
|
-
# Optional, for applications that still request Polars frames:
|
|
21
|
-
pip install 'gtfparse[polars]'
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
```python
|
|
25
|
-
from gtfparse import read_gtf, write_gtf
|
|
26
|
-
|
|
27
|
-
df = read_gtf("gene_annotations.gtf") # pandas.DataFrame
|
|
28
|
-
write_gtf(df, "gene_annotations.gtf.gz")
|
|
29
|
-
|
|
30
|
-
# Requires the optional extra:
|
|
31
|
-
polars_df = read_gtf("gene_annotations.gtf", result_type="polars")
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Existing pandas and dictionary callers retain their output shape, fixed-column
|
|
35
|
-
dtypes, attribute handling, filters, converters and progress callbacks. Applications
|
|
36
|
-
that used the previous default Polars output should add `result_type="polars"`
|
|
37
|
-
and install the extra, or use pandas methods. `write_gtf` accepts either frame
|
|
38
|
-
type. The legacy `parse_with_polars_lazy` helper remains an optional adapter:
|
|
39
|
-
it reads the file eagerly and returns a Polars LazyFrame, as before.
|
|
40
|
-
|
|
41
|
-
Empty or malformed GTF fields now raise `gtfparse.ParsingError`, including wrong
|
|
42
|
-
field counts and invalid numeric fields. Whole comment lines are ignored;
|
|
43
|
-
literal `#` inside attributes is preserved. Text and binary streams stay open
|
|
44
|
-
after parsing, and gzip is detected from its contents.
|
|
45
|
-
|
|
46
|
-
## Reporting parsing progress
|
|
47
|
-
|
|
48
|
-
Pass `progress_callback(stage, completed, total)` to `read_gtf` to connect
|
|
49
|
-
parsing to your own progress UI. The callback runs synchronously; exceptions
|
|
50
|
-
from it stop parsing and propagate to the caller. Without a callback, gtfparse
|
|
51
|
-
does not display a progress bar or add a progress-library dependency.
|
|
52
|
-
|
|
53
|
-
| Stage | Reports |
|
|
54
|
-
| --- | --- |
|
|
55
|
-
| `read` | `(0, None)` before loading/filtering the file; `(rows, rows)` after it succeeds |
|
|
56
|
-
| `attributes` | `(0, rows)`, then every 10,000 rows, then `(rows, rows)` |
|
|
57
|
-
| `convert` | `(0, None)` before output conversion/transforms; `(rows, rows)` after success |
|
|
58
|
-
|
|
59
|
-
Counts refer to rows retained after `features` filtering, not bytes or overall
|
|
60
|
-
percentages. `None` means the total is unknown: loading and conversion expose
|
|
61
|
-
only stage boundaries, so use an indeterminate indicator during those steps.
|
|
62
|
-
Attribute expansion is omitted when `expand_attribute_column=False`. A stage
|
|
63
|
-
that fails does not emit completion. An empty filtered result is supported;
|
|
64
|
-
its attributes stage emits a single `(0, 0)` event. Empty input files raise `gtfparse.ParsingError`.
|
|
65
|
-
|
|
66
|
-
For example, with the optional `tqdm` package installed:
|
|
67
|
-
|
|
68
|
-
```python
|
|
69
|
-
from gtfparse import read_gtf
|
|
70
|
-
from tqdm.auto import tqdm
|
|
71
|
-
|
|
72
|
-
with tqdm(unit="rows") as bar:
|
|
73
|
-
def show_progress(stage, completed, total):
|
|
74
|
-
if stage != bar.desc:
|
|
75
|
-
bar.total = total
|
|
76
|
-
bar.reset()
|
|
77
|
-
bar.set_description_str(stage)
|
|
78
|
-
bar.total = total
|
|
79
|
-
bar.update(completed - bar.n)
|
|
80
|
-
bar.refresh()
|
|
81
|
-
|
|
82
|
-
df = read_gtf("gene_annotations.gtf", progress_callback=show_progress)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
`parse_gtf` reports the `read` stage, `parse_gtf_and_expand_attributes` reports
|
|
86
|
-
`read` and `attributes`, `parse_gtf_pandas` reports `read` and `convert`, and
|
|
87
|
-
`expand_attribute_strings` reports only `attributes` using the same callback.
|
|
88
|
-
|
|
89
|
-
Quoted attribute values preserve spaces, semicolons, and apostrophes. Raw
|
|
90
|
-
attributes (`expand_attribute_column=False`) retain their original quote marks.
|
|
91
|
-
|
|
92
|
-
# Example usage
|
|
93
|
-
|
|
94
|
-
## Parsing all rows of a GTF file into a Pandas DataFrame
|
|
95
|
-
|
|
96
|
-
```python
|
|
97
|
-
from gtfparse import read_gtf
|
|
98
|
-
|
|
99
|
-
# returns GTF with essential columns such as "feature", "seqname", "start", "end"
|
|
100
|
-
# alongside the names of any optional keys which appeared in the attribute column
|
|
101
|
-
df = read_gtf("gene_annotations.gtf")
|
|
102
|
-
|
|
103
|
-
# filter DataFrame to gene entries on chrY
|
|
104
|
-
df_genes = df[df["feature"] == "gene"]
|
|
105
|
-
df_genes_chrY = df_genes[df_genes["seqname"] == "Y"]
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## Getting gene FPKM values from a StringTie GTF file
|
|
110
|
-
|
|
111
|
-
```python
|
|
112
|
-
from gtfparse import read_gtf
|
|
113
|
-
|
|
114
|
-
df = read_gtf(
|
|
115
|
-
"Transcripts.gtf",
|
|
116
|
-
column_converters={"FPKM": float})
|
|
117
|
-
|
|
118
|
-
gene_fpkms = {
|
|
119
|
-
gene_name: fpkm
|
|
120
|
-
for (gene_name, fpkm, feature)
|
|
121
|
-
in zip(df["seqname"], df["FPKM"], df["feature"])
|
|
122
|
-
if feature == "gene"
|
|
123
|
-
}
|
|
124
|
-
```
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: gtfparse
|
|
3
|
-
Version: 3.0.2
|
|
4
|
-
Summary: Parsing library for extracting data frames of genomic features from GTF files
|
|
5
|
-
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
|
|
6
|
-
License-Expression: Apache-2.0
|
|
7
|
-
Project-URL: Homepage, https://github.com/openvax/gtfparse
|
|
8
|
-
Project-URL: Bug Tracker, https://github.com/openvax/gtfparse/issues
|
|
9
|
-
Classifier: Development Status :: 4 - Beta
|
|
10
|
-
Classifier: Environment :: Console
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Intended Audience :: Science/Research
|
|
13
|
-
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
-
Requires-Python: >=3.9
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
License-File: LICENSE
|
|
23
|
-
Requires-Dist: pyarrow>=18.0.0
|
|
24
|
-
Requires-Dist: pandas>=2.2.2
|
|
25
|
-
Provides-Extra: polars
|
|
26
|
-
Requires-Dist: polars>=0.20.31; extra == "polars"
|
|
27
|
-
Provides-Extra: dev
|
|
28
|
-
Requires-Dist: pytest; extra == "dev"
|
|
29
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
30
|
-
Requires-Dist: ruff; extra == "dev"
|
|
31
|
-
Requires-Dist: coveralls; extra == "dev"
|
|
32
|
-
Dynamic: license-file
|
|
33
|
-
|
|
34
|
-
[](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
|
|
35
|
-
[](https://coveralls.io/github/openvax/gtfparse?branch=master)
|
|
36
|
-
<a href="https://pypi.python.org/pypi/gtfparse/">
|
|
37
|
-
<img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
|
|
38
|
-
</a>
|
|
39
|
-
|
|
40
|
-
gtfparse
|
|
41
|
-
========
|
|
42
|
-
Parsing tools for GTF (gene transfer format) files.
|
|
43
|
-
|
|
44
|
-
## Version 3 migration
|
|
45
|
-
|
|
46
|
-
`read_gtf`, `parse_gtf`, and `parse_gtf_and_expand_attributes` now return pandas
|
|
47
|
-
DataFrames by default. GTF reading uses PyArrow; attribute processing and writing
|
|
48
|
-
use pandas. Polars is no longer a required dependency and is imported only for
|
|
49
|
-
explicit Polars conversion. Ordinary installations need only pandas and PyArrow.
|
|
50
|
-
|
|
51
|
-
```sh
|
|
52
|
-
pip install gtfparse
|
|
53
|
-
# Optional, for applications that still request Polars frames:
|
|
54
|
-
pip install 'gtfparse[polars]'
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```python
|
|
58
|
-
from gtfparse import read_gtf, write_gtf
|
|
59
|
-
|
|
60
|
-
df = read_gtf("gene_annotations.gtf") # pandas.DataFrame
|
|
61
|
-
write_gtf(df, "gene_annotations.gtf.gz")
|
|
62
|
-
|
|
63
|
-
# Requires the optional extra:
|
|
64
|
-
polars_df = read_gtf("gene_annotations.gtf", result_type="polars")
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Existing pandas and dictionary callers retain their output shape, fixed-column
|
|
68
|
-
dtypes, attribute handling, filters, converters and progress callbacks. Applications
|
|
69
|
-
that used the previous default Polars output should add `result_type="polars"`
|
|
70
|
-
and install the extra, or use pandas methods. `write_gtf` accepts either frame
|
|
71
|
-
type. The legacy `parse_with_polars_lazy` helper remains an optional adapter:
|
|
72
|
-
it reads the file eagerly and returns a Polars LazyFrame, as before.
|
|
73
|
-
|
|
74
|
-
Empty or malformed GTF fields now raise `gtfparse.ParsingError`, including wrong
|
|
75
|
-
field counts and invalid numeric fields. Whole comment lines are ignored;
|
|
76
|
-
literal `#` inside attributes is preserved. Text and binary streams stay open
|
|
77
|
-
after parsing, and gzip is detected from its contents.
|
|
78
|
-
|
|
79
|
-
## Reporting parsing progress
|
|
80
|
-
|
|
81
|
-
Pass `progress_callback(stage, completed, total)` to `read_gtf` to connect
|
|
82
|
-
parsing to your own progress UI. The callback runs synchronously; exceptions
|
|
83
|
-
from it stop parsing and propagate to the caller. Without a callback, gtfparse
|
|
84
|
-
does not display a progress bar or add a progress-library dependency.
|
|
85
|
-
|
|
86
|
-
| Stage | Reports |
|
|
87
|
-
| --- | --- |
|
|
88
|
-
| `read` | `(0, None)` before loading/filtering the file; `(rows, rows)` after it succeeds |
|
|
89
|
-
| `attributes` | `(0, rows)`, then every 10,000 rows, then `(rows, rows)` |
|
|
90
|
-
| `convert` | `(0, None)` before output conversion/transforms; `(rows, rows)` after success |
|
|
91
|
-
|
|
92
|
-
Counts refer to rows retained after `features` filtering, not bytes or overall
|
|
93
|
-
percentages. `None` means the total is unknown: loading and conversion expose
|
|
94
|
-
only stage boundaries, so use an indeterminate indicator during those steps.
|
|
95
|
-
Attribute expansion is omitted when `expand_attribute_column=False`. A stage
|
|
96
|
-
that fails does not emit completion. An empty filtered result is supported;
|
|
97
|
-
its attributes stage emits a single `(0, 0)` event. Empty input files raise `gtfparse.ParsingError`.
|
|
98
|
-
|
|
99
|
-
For example, with the optional `tqdm` package installed:
|
|
100
|
-
|
|
101
|
-
```python
|
|
102
|
-
from gtfparse import read_gtf
|
|
103
|
-
from tqdm.auto import tqdm
|
|
104
|
-
|
|
105
|
-
with tqdm(unit="rows") as bar:
|
|
106
|
-
def show_progress(stage, completed, total):
|
|
107
|
-
if stage != bar.desc:
|
|
108
|
-
bar.total = total
|
|
109
|
-
bar.reset()
|
|
110
|
-
bar.set_description_str(stage)
|
|
111
|
-
bar.total = total
|
|
112
|
-
bar.update(completed - bar.n)
|
|
113
|
-
bar.refresh()
|
|
114
|
-
|
|
115
|
-
df = read_gtf("gene_annotations.gtf", progress_callback=show_progress)
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
`parse_gtf` reports the `read` stage, `parse_gtf_and_expand_attributes` reports
|
|
119
|
-
`read` and `attributes`, `parse_gtf_pandas` reports `read` and `convert`, and
|
|
120
|
-
`expand_attribute_strings` reports only `attributes` using the same callback.
|
|
121
|
-
|
|
122
|
-
Quoted attribute values preserve spaces, semicolons, and apostrophes. Raw
|
|
123
|
-
attributes (`expand_attribute_column=False`) retain their original quote marks.
|
|
124
|
-
|
|
125
|
-
# Example usage
|
|
126
|
-
|
|
127
|
-
## Parsing all rows of a GTF file into a Pandas DataFrame
|
|
128
|
-
|
|
129
|
-
```python
|
|
130
|
-
from gtfparse import read_gtf
|
|
131
|
-
|
|
132
|
-
# returns GTF with essential columns such as "feature", "seqname", "start", "end"
|
|
133
|
-
# alongside the names of any optional keys which appeared in the attribute column
|
|
134
|
-
df = read_gtf("gene_annotations.gtf")
|
|
135
|
-
|
|
136
|
-
# filter DataFrame to gene entries on chrY
|
|
137
|
-
df_genes = df[df["feature"] == "gene"]
|
|
138
|
-
df_genes_chrY = df_genes[df_genes["seqname"] == "Y"]
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
## Getting gene FPKM values from a StringTie GTF file
|
|
143
|
-
|
|
144
|
-
```python
|
|
145
|
-
from gtfparse import read_gtf
|
|
146
|
-
|
|
147
|
-
df = read_gtf(
|
|
148
|
-
"Transcripts.gtf",
|
|
149
|
-
column_converters={"FPKM": float})
|
|
150
|
-
|
|
151
|
-
gene_fpkms = {
|
|
152
|
-
gene_name: fpkm
|
|
153
|
-
for (gene_name, fpkm, feature)
|
|
154
|
-
in zip(df["seqname"], df["FPKM"], df["feature"])
|
|
155
|
-
if feature == "gene"
|
|
156
|
-
}
|
|
157
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|