Skip to content

GtfAttributes

Mojo struct 🡭

@memory_only
struct GtfAttributes

Parsed GTF column 9 attributes.

gene_id and transcript_id are mandatory GTF2.2 fields stored directly. All other attributes are in _extras as single-value key-value pairs. Duplicate keys in _extras are preserved; use get_all() to retrieve all.

  • gene_id (BString)
  • transcript_id (BString)

AnyType, Copyable, Deinitable, Movable, Sized, Writable

fn def __init__(out self, var gene_id: BString, var transcript_id: BString)

Args:

  • gene_id (BString)
  • transcript_id (BString)
  • self (Self)

Returns:

Self

fn def __init__(out self, *, copy: Self)

Args:

  • copy (Self)
  • self (Self)

Returns:

Self

fn def get(ref self, key: String) -> Optional[BString]

Return the first value for the given attribute key, if any.

Args:

  • self (Self)
  • key (String)

Returns:

Optional[BString]

fn def get_all(ref self, key: String) -> List[BString]

Return all values for key in encounter order (supports duplicate keys).

Args:

  • self (Self)
  • key (String)

Returns:

List[BString]

fn def __len__(self) -> Int

Return count of non-empty attributes (gene_id, transcript_id, and extras).

Args:

  • self (Self)

Returns:

Int

fn def write_to[w: Writer](ref self, mut writer: w)

Emit attributes in GTF format: gene_id ”…”; transcript_id ”…”; …

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)