Skip to content

FastaRecord

Mojo struct 🡭

@memory_only
struct FastaRecord

A single FASTA record (two logical parts: >id, sequence).

Multi-line sequences are stored as a single logical line (no embedded newlines). Owned representation; safe to store in collections and reuse.

Attributes: id: Read identifier (id line content after the ’>’; stored without leading ’>’). sequence: Sequence line (normalized to a single line, no ‘\n’ or ‘\r’).

AnyType, Copyable, Hashable, ImplicitlyDestructible, Movable, Sized, Writable

def __init__(out self, id: String, sequence: String)

Build from id and sequence strings.

Args:

  • id (String)
  • sequence (String)
  • self (Self)

Returns:

Self

Raises:

def __init__(out self, id: Span[Byte, id.origin], sequence: Span[Byte, sequence.origin])

Args:

  • id (Span)
  • sequence (Span)
  • self (Self)

Returns:

Self

Raises:

def __init__(out self, var id: BString, var sequence: BString)

Args:

  • id (BString)
  • sequence (BString)
  • self (Self)

Returns:

Self

def __eq__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

Bool

def __ne__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

Bool

def sequence(ref self) -> StringSlice[origin_of(self)]

Return the sequence line as a string slice.

Args:

  • self (Self)

Returns:

StringSlice

def id(ref self) -> StringSlice[origin_of(self)]

Return the read identifier (id without leading ’>’) as a string slice.

Args:

  • self (Self)

Returns:

StringSlice

def definition(self) -> Definition

Args:

  • self (Self)

Returns:

Definition

def byte_len(self) -> Int

Return total byte length when written (”>” + id + “\n” + sequence + “\n”).

Args:

  • self (Self)

Returns:

Int

def write[w: Writer](self, mut writer: w, line_width: Int = 60)

Write the record in standard FASTA format.

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)
  • line_width (Int)
def write_to[w: Writer](self, mut writer: w)

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)
def __len__(self) -> Int

Return the sequence length (number of bases).

Args:

  • self (Self)

Returns:

Int

def __hash__[H: Hasher](self, mut hasher: H)

Parameters:

  • H (Hasher)

Args:

  • self (Self)
  • hasher (H)
def __repr__(self) -> String

Args:

  • self (Self)

Returns:

String