read_gff()
Read GFF files into one table.
Reads one GFF file, or every .gff, .gff2, .gff3 and .gtf file of a folder. Each attribute becomes a column. GFF3 attributes are read as key=value pairs, URL-decoded; GTF and GFF2 attributes, rows without any =, as key "value" pairs, without the quotes. A key repeated in one row, such as tag in GTF files, keeps all its values joined with ",", as GFF3 writes several values of one key. Comment lines are left out, and reading stops at a ##FASTA section.
Usage
from geneviewer import read_gff
read_gff(path, fields=None)Arguments
| Argument | Type | Description |
|---|---|---|
path | str or path-like | A GFF file, or a folder of them. |
fields | sequence of str, optional | The columns to keep, e.g. ["seqid", "type", "start", "end", "strand", "Name"]. A folder's table keeps its filename column. |
Value
pandas.DataFrame: One row per feature: seqid, source, type, start, end, score, strand, phase, then the attributes; for a folder, filename, the file's name without its extension. seqid, source, type, strand and phase are text; score is numbers, NaN for "." (a value that is not a number is NaN too, with a warning).
Errors
| Error | When |
|---|---|
FileNotFoundError | When the path does not exist, or a folder has no GFF files. |
ValueError | When a field is not a column of the table. |
