Skip to content

quadram-institute-bioscience/readfx

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReadFX - Nim FASTQ/FASTA Parser

Nim Tests

The Nim FASTA/FASTQ parsing library for SeqFu.

Installation

nimble install readfx

Usage

import readfx

# Using the C wrapper (klib)
for record in readFQ("example.fastq"):
  echo record.name, ": ", record.sequence.len
  
# Using pointer-based version (more efficient, reuses memory)
for record in readFQPtr("example.fastq.gz"):
  echo $record.name, ": ", record.sequenceLen
  
# Using the native Nim implementation
var r: FQRecord
var f = xopen[GzFile]("example.fastq.gz")
defer: f.close()
while f.readFastx(r):
  echo r.name, ": ", r.sequence.len

# Reading paired-end FASTQ files
for pair in readFQPair("sample_R1.fastq.gz", "sample_R2.fastq.gz"):
  echo "R1: ", pair.read1.name, " (", pair.read1.sequence.len, " bp)"
  echo "R2: ", pair.read2.name, " (", pair.read2.sequence.len, " bp)"

# Pointer-based paired-end iteration (zero-copy, pointers are reused)
for pair in readFQPairPtr("sample_R1.fastq.gz", "sample_R2.fastq.gz"):
  echo "Pair length: ", pair.read1.sequenceLen + pair.read2.sequenceLen

# Pointer-based interleaved paired-end iteration
for pair in readFQInterleavedPairPtr("sample.interleaved.fastq.gz", checkNames = true):
  echo "Pair length: ", pair.read1.sequenceLen + pair.read2.sequenceLen

FQRecordPtr now includes cached nameLen, commentLen, sequenceLen, and qualityLen fields. These lengths exclude the trailing NUL terminator and avoid repeated cstring scans in pointer-heavy code. Because FQRecordPtr layout changed, downstream projects must be recompiled after upgrading to this release.

Authors

About

SeqFu FASTX parser (klib)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Nim 80.6%
  • C 11.4%
  • Python 6.9%
  • Other 1.1%