Feature¶
gffbase.feature.Feature ¶
Feature(seqid: str = '.', source: str = '.', featuretype: str = '.', start='.', end='.', score: str = '.', strand: str = '.', frame: str = '.', attributes=None, extra=None, bin: int | None = None, id: str | None = None, dialect: dict | None = None, file_order: int | None = None, keep_order: bool = False, sort_attribute_values: bool = False)
Backward-compatible public Feature object.
Mirrors the legacy gffutils.Feature constructor and observable
behavior: 1-based inclusive coordinates, list-wrapped multi-value
attributes, dialect-faithful __str__ round-trip.
Source code in python/gffbase/feature.py
chrom
property
writable
¶
Alias for seqid (GFF column 1), the name gffutils uses.
Reading and writing either name affects the same underlying value.
stop
property
writable
¶
Alias for end (GFF column 5), the name gffutils uses.
None when the source line carried . -- such a feature has no
coordinates and is skipped by region().
segments
property
¶
This feature's physical input lines.
An ordinary feature is its own sole segment, so callers can write
for seg in feature.segments without first asking whether the
feature is discontinuous.
to_line ¶
Render this feature as one GFF line.
By default this is byte-faithful: if the original column 9 was never
parsed or mutated, its bytes are re-emitted verbatim, so a file that
round-trips through gffbase comes back unchanged. That is what
str(feature) does too.
normalized=True instead re-renders column 9 from the parsed
attribute mapping, applying the dialect's separators and the
sort_attribute_values setting. This is what gffutils always does,
so it is the form to use when comparing against the oracle -- at the
cost of losing whatever the source file's exact spacing was.
Values are percent-encoded on this path, so a value containing ;,
,, =, & or % re-emits as valid GFF3. Spaces and non-ASCII are
left alone, which is what the spec says and what the oracle does.
Source code in python/gffbase/feature.py
to_lines ¶
astuple ¶
Legacy 12-tuple shape used by the SQLite export path:
(id, seqid, source, featuretype, start, end, score, strand, frame,
attributes_json, extra_json, bin).
Source code in python/gffbase/feature.py
calc_bin ¶
Compute and store this feature's UCSC bin.
Parameters:
-
_bin(int | None, default:None) –Set the bin directly instead of deriving it.
Returns:
-
int | None–The bin, or
Nonewhen the feature has no coordinates.
Source code in python/gffbase/feature.py
sequence ¶
Extract sequence from a FASTA path or a pyfaidx-style mapping.
Source code in python/gffbase/feature.py
ParsedFeature (parser-internal record)¶
The slotted dataclass the Rust+Python parser emits before features land in the database.
gffbase.feature.ParsedFeature
dataclass
¶
ParsedFeature(seqid: str, source: str, featuretype: str, start: int | None, end: int | None, score: str, strand: str, frame: str, attributes_blob: bytes, attributes_pairs: list[tuple[str, str, int]] = list(), extra: list[str] = list())
attributes_dict ¶
Materialize attributes as {key: [values...]}. Preserves first-seen
key order and multi-value ordering. Defers to attributes_pairs so the
Rust and Python parsers remain trivially comparable.
Source code in python/gffbase/feature.py
from_tuple
classmethod
¶
Build from the 11-tuple shape that the Rust extension yields.