Project

libssw

0.0
No release in over 3 years
Ruby bindings for libssw
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 1.0.7
 Project Readme

ruby-libssw

test Gem Version Docs Latest DOI

🏁 libssw - fast SIMD parallelized implementation of the Smith-Waterman algorithm - for Ruby

Installation

gem install libssw

Set the environment variable LIBSSWDIR to specify the location of the shared library. For example, on Ubuntu, you can use libssw in the following way.

sudo apt install libssw-dev
export LIBSSWDIR=/usr/lib/x86_64-linux-gnu/ # libssw.so

Installing from source

When installing from source code using the following steps, the shared library libssw.so or libssw.dylib will be packed in the Ruby gem. In this case, the environment variable LIBSSWDIR is not required.

git clone --recursive https://github.com/kojix2/ruby-libssw
bundle exec rake libssw:build
bundle exec rake install

ruby-libssw does not support Windows.

Usage

require 'libssw'

ref_str  = "AAAAAAAAACGTTAAAAAAAAAA"
ref_int  = SSW::DNA.to_int_array(ref_str) 
# [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

read_str1 = "ACGTT"
read_str2 = SSW::DNA.revcomp(read_str1)
# "AACGT"
read_int1 = SSW::DNA.to_int_array(read_str1)
# [0, 1, 2, 3, 3]
read_int2 = SSW::DNA.to_int_array(read_str2)
# [0, 0, 1, 2, 3]

mat = SSW.create_scoring_matrix(SSW::DNA::Elements, 2, -2)
# mat = [2, -2, -2, -2,  0,
#       -2,  2, -2, -2,  0,
#       -2, -2,  2, -2,  0,
#       -2, -2, -2,  2,  0,
#        0,  0,  0,  0,  0]

profile1 = SSW.init(read_int1, mat)
align1   = SSW.align(profile1, ref_int, 3, 1, 1, 0, 0)
pp align1.to_h
# {
#  :score1       => 10,
#  :score2       => 0,
#  :ref_begin1   => 8,
#  :ref_end1     => 12,
#  :read_begin1  => 0,
#  :read_end1    => 4,
#  :ref_end2     => 0,
#  :cigar        => [80],
#  :cigar_len    => 1,
#  :cigar_string => "5M"
# }

profile2 = SSW.init(read_int2, mat)
align2   = SSW.align(profile2, ref_int, 3, 1, 1, 0, 0)
pp align2.to_h
# {
#  :score1       => 10,
#  :score2       => 0,
#  :ref_begin1   => 7,
#  :ref_end1     => 11,
#  :read_begin1  => 0,
#  :read_end1    => 4,
#  :ref_end2     => 0,
#  :cigar        => [80],
#  :cigar_len    => 1,
#  :cigar_string => "5M"
# }

puts SSW.build_path(read_str1, ref_str, align1)
# 5M
# ACGTT
# |||||
# ACGTT

APIs

See API Documentation.

* SSW module
  * SSW.init
  * SSW.init_destroy
  * SSW.align
  * SSW.align_destroy
  * SSW.mark_mismatch
  * SSW.create_scoring_matrix
  * SSW.build_path
  
  * Profile class
    * attributes
      * read, mat, read_len, n, bias

  * Align class
    * attributes
      * score1, score2, ref_begin1, ref_end1, read_begin1, read_end1, ref_end2
        cigar, cigar_len, cigar_string
  
  * DNA module
    * DNA.to_int_array
    * DNA.from_int_array
    * revcomp

  * AASeq module
    * AASeq.to_int_array
    * AASeq.from_int_array

  * BLOSUM62
  * BLOSUM50

Development

git clone --recursive https://github.com/kojix2/ruby-libssw
bundle exec rake libssw:build
bundle exec rake test
Do you need commit rights to my repository?
Do you want to get admin rights and take over the project?
If so, please feel free to contact me @kojix2.

Contributing

License