HTSlib
:dna: HTSlib - high-throughput sequencing data manipulation - for Ruby
:apple: Feel free to fork it out if you can develop it!
:bowtie: Just a prototype. Pre-alpha stage.
Requirements
- htslib
- Ubuntu :
apt install libhts-dev - macOS :
brew install htslib
- Ubuntu :
Installation
gem install htslib
If you installed htslib with Ubuntu/apt or Mac/homebrew, pkg-config will automatically detect the location of the shared library.
Or you can set the environment variable HTSLIBDIR.
export HTSLIBDIR="/your/path/to/htslib" # libhts.so
Usage
HTS::FFI - Low-level API
require 'htslib'
a = HTS::FFI.hts_open("a.bam", "r")
b = HTS::FFI.hts_get_format(a)
p b[:category]
p b[:format]
A high-level API based on hts-python is under development.
require 'htslib'
bam = HTS::Bam.new("a.bam")
bam.each do |aln|
p name: aln.qname,
flag: aln.flag,
start: aln.start + 1,
mpos: aln.mate_pos + 1,
mqual: aln.mapping_quality,
seq: aln.sequence,
cigar: aln.cigar.to_s,
qual: aln.base_qualities.map { |i| (i + 33).chr }.join
end
Documentation
Development
To get started with development
git clone --recursive https://github.com/kojix2/ruby-htslib
cd ruby-htslib
bundle install
bundle exec rake htslib:build
bundle exec rake test
Contributing
Ruby-htslib is a library under development, so even small improvements like typofix are welcome! Please feel free to send us your pull requests.
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features