Skip to content

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 ​

python
from geneviewer import read_gff

read_gff(path, fields=None)

Arguments ​

ArgumentTypeDescription
pathstr or path-likeA GFF file, or a folder of them.
fieldssequence of str, optionalThe 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 ​

ErrorWhen
FileNotFoundErrorWhen the path does not exist, or a folder has no GFF files.
ValueErrorWhen a field is not a column of the table.