Create a new SAM writer with specified options
Writer configuration options
Optionalvalidate?: booleanValidate records before writing (default: true)
OptionalincludeLineNumbers?: booleanInclude line numbers in error reporting (default: true)
OptionalonError?: (error: string, record?: SAMHeader | SAMAlignment) => voidCustom error handler
OptionalonWarning?: (warning: string, record?: SAMHeader | SAMAlignment) => voidCustom warning handler
Write SAM records to string format
Array of SAM headers and alignments to write
Formatted SAM string with proper line separators
Write SAM records to file using Bun's native file I/O
Path where SAM file should be written
Array of SAM headers and alignments to write
Optionaloptions: { encoding?: "utf8" | "binary"; mode?: number }File writing options
Write SAM records to a WritableStream
WritableStream to write formatted SAM data to
Async iterable of SAM headers and alignments
SAM writer for outputting alignments and headers
Designed to complement the SAMParser with full format compliance. Handles all SAM format requirements including header validation, alignment field formatting, CIGAR string validation, and optional tag serialization.
Example: Basic usage
Example: Writing to file
Example: Streaming output