This page is incomplete and a placeholder for the methods reference. It will be updated with more details and examples.
iterator readFQ*(path: string): FQRecord
High-level iterator for FASTA/FASTQ parsing.
path: string
- File path (use “-“ for stdin)iterator readFQPtr*(path: string): FQRecordPtr
High-performance iterator with pointer-based records.
path: string
- File path (use “-“ for stdin)proc readFastx*[T](f: var Bufio[T], r: var FQRecord): bool
Low-level procedure for custom parsing workflows.
f: var Bufio[T]
- Buffered input streamr: var FQRecord
- Record to populateproc xopen*[T](fn: string, mode: FileMode = fmRead, sz: int = 0x10000): Bufio[T]
Opens a file with buffered I/O.
fn: string
- File pathmode: FileMode
- File mode (default: fmRead)sz: int
- Buffer size (default: 0x10000)proc open*[T](f: var Bufio[T], fn: string, mode: FileMode = fmRead, sz: int = 0x10000): int
Opens a file for buffered I/O.
proc close*[T](f: var Bufio[T]): int
Closes a buffered I/O handle.
f: var Bufio[T]
- File handle to closeproc reverseComplement*(sequence: string): string
Reverse complements a DNA sequence.
sequence: string
- Input DNA sequencereverseComplement("ATGC")
returns “GCAT”proc reverseComplementRecord*(record: var FQRecord)
Reverse complements a sequence record in place.
record: var FQRecord
- Record to modifyproc reverseComplementRecord*(record: FQRecord): FQRecord
Creates a new record with reverse-complemented sequence.
record: FQRecord
- Input recordproc gcContent*(sequence: string): float
Calculates GC content of a DNA sequence.
sequence: string
- DNA sequenceproc trimQuality*(quality: string, minQual: int, offset: int = 33): string
Trims a quality string based on minimum quality threshold.
quality: string
- Quality stringminQual: int
- Minimum quality value (0-40)offset: int
- Quality score offset (default: 33)proc qualityTrim*(record: var FQRecord, minQual: int, offset: int = 33)
Trims a record based on quality scores.
record: var FQRecord
- Record to modifyminQual: int
- Minimum quality valueoffset: int
- Quality score offset (default: 33)proc maskLowQuality*(record: var FQRecord, minQual: int, offset: int = 33, maskChar: char = 'N')
Masks sequence positions with low quality scores.
record: var FQRecord
- Record to modifyminQual: int
- Minimum quality valueoffset: int
- Quality score offset (default: 33)maskChar: char
- Character to use for masking (default: ‘N’)proc subSequence*(record: FQRecord, start: int, length: int = -1): FQRecord
Extracts a subsequence from a record.
record: FQRecord
- Input recordstart: int
- Start position (0-based)length: int
- Length to extract (-1 for end of sequence)proc `$`*(rec: FQRecord): string
proc `$`*(rec: FQRecordPtr): string
Converts records to string representation in FASTA/FASTQ format.
rec: FQRecord/FQRecordPtr
- Record to converttype Interval*[S,T] = tuple[st, en: S, data: T, max: S]
proc sort*[S,T](a: var seq[Interval[S,T]])
proc index*[S,T](a: var seq[Interval[S,T]]): int
iterator overlap*[S,T](a: seq[Interval[S,T]], st: S, en: S): Interval[S,T]
Interval tree implementation for genomic intervals.
import readfx
# Using readFQ (string-based)
for record in readFQ("sample.fastq.gz"):
echo record.name, " has length ", record.sequence.len
# Using readFQPtr (pointer-based)
for record in readFQPtr("sample.fastq.gz"):
echo $record.name, " has length ", len($record.sequence)
# Using readFastx (low-level)
var record: FQRecord
var f = xopen[GzFile]("sample.fastq.gz")
defer: f.close()
while f.readFastx(record):
echo record.name, " has length ", record.sequence.len
# GC content calculation
let gc = gcContent(record.sequence)
# Reverse complement
let rcSeq = reverseComplement(record.sequence)
let rcRecord = reverseComplementRecord(record)
# Quality trimming
qualityTrim(record, 20) # Trim bases with quality < 20
# Masking low quality bases
maskLowQuality(record, 20) # Mask bases with quality < 20 as 'N'
# Extract subsequence
let firstTenBases = subSequence(record, 0, 10)