Small FASTA/FASTQ I/O for Crystal.
Add this to shard.yml:
dependencies:
fastx:
github: bio-cr/fastx.crThen run:
shards install- Read and write FASTA
- Read and write FASTQ
- Auto-handle gzip when the path ends with
.gz - Iterate with owned
Stringvalues or lower-allocation borrowedBytes - Stream large records line by line without accumulating full sequences
- Encode/decode nucleotide bases and FASTQ quality scores
Read FASTA:
require "fastx"
Fastx::Fasta::Reader.open("reads.fa.gz") do |reader|
reader.each do |header, sequence|
puts "#{header}\t#{sequence.bytesize}"
end
endRead FASTQ:
Fastx::Fastq::Reader.open("reads.fq.gz") do |reader|
reader.each do |identifier, sequence, quality|
puts "#{identifier}\t#{sequence.bytesize}\t#{quality.bytesize}"
end
endWrite FASTA:
Fastx::Fasta::Writer.open("out.fa", line_width: 80) do |writer|
writer.write("seq1", "ACGTACGT")
endWrite FASTQ:
Fastx::Fastq::Writer.open("out.fq.gz") do |writer|
writer.write("seq1", "ACGT", "!!!!")
end- Getting started
- Reading FASTA and FASTQ
- Writing FASTA and FASTQ
- Streams and limits
- Base and quality encoding
MIT License