libssw 0.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f52642bad07253a1fa4ad73032c49d805a53080812bbb663c0fa825c6b0241f0
4
+ data.tar.gz: af7af5c499367ad64f4914bd1c4efce747966170d181960fa20b2c419745666b
5
+ SHA512:
6
+ metadata.gz: 3858b66d605d0011ce6e9c6606befbd7520613a1435297276a707cf22431ee38e043c7402ac336a08851da79ffd097bf28d72cd8debd995e66e1c1466c3a48b5
7
+ data.tar.gz: 7aed161e8a3a8d8c9b754749af60408dbdcc05a8076efe3d116d76fdccac03dbee967cf95a6c7f042cdf7b9cdb99b24e9f059e995c351079a8a156316198f3e7
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 kojix2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # ruby-libssw
2
+
3
+ [libssw](https://github.com/mengyao/Complete-Striped-Smith-Waterman-Library) - fast SIMD parallelized implementation of the Smith-Waterman algorithm - for Ruby
4
+
5
+ ## Installation
6
+
7
+ ```ssh
8
+ gem install libssw
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ require 'libssw'
15
+ SSW = LibSSW
16
+ ```
17
+
18
+ ## Development
19
+
20
+ ```sh
21
+ git clone --recurse-submodules https://github.com/kojix2/ruby-libssw
22
+ bundle exec rake libssw:compile
23
+ bundle exec rake test
24
+ ```
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kojix2/ruby-libssw.
29
+
30
+ ## License
31
+
32
+ * [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'libssw'
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+ require_relative 'libssw/version'
5
+
6
+ module LibSSW
7
+ class Error < StandardError; end
8
+
9
+ class << self
10
+ attr_accessor :ffi_lib
11
+ end
12
+
13
+ lib_name = case RbConfig::CONFIG['host_os']
14
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
15
+ 'libssw.dll' # unconfirmed
16
+ when /darwin|mac os/
17
+ 'libssw.dylib' # unconfirmed
18
+ else
19
+ 'libssw.so'
20
+ end
21
+
22
+ self.ffi_lib = if ENV['LIBSSWDIR'] && !ENV['LIBSSWDIR'].empty?
23
+ File.expand_path(lib_name, ENV['LIBUIDIR'])
24
+ else
25
+ File.expand_path("../vendor/#{lib_name}", __dir__)
26
+ end
27
+
28
+ autoload :FFI, 'libssw/ffi'
29
+
30
+ extend Forwardable
31
+ Align = FFI::Align
32
+ Profile = FFI::Profile
33
+ def_delegators :FFI,
34
+ :ssw_init,
35
+ :init_destroy,
36
+ :align_destroy,
37
+ :mark_mismatch
38
+ end
@@ -0,0 +1,29 @@
1
+ module LibSSW
2
+ BLOSUM50 = [
3
+ # A R N D C Q E G H I L K M F P S T W Y V B Z X *
4
+ 5, -2, -1, -2, -1, -1, -1, 0, -2, -1, -2, -1, -1, -3, -1, 1, 0, -3, -2, 0, -2, -1, -1, -5, # A
5
+ -2, 7, -1, -2, -4, 1, 0, -3, 0, -4, -3, 3, -2, -3, -3, -1, -1, -3, -1, -3, -1, 0, -1, -5, # R
6
+ -1, -1, 7, 2, -2, 0, 0, 0, 1, -3, -4, 0, -2, -4, -2, 1, 0, -4, -2, -3, 5, 0, -1, -5, # N
7
+ -2, -2, 2, 8, -4, 0, 2, -1, -1, -4, -4, -1, -4, -5, -1, 0, -1, -5, -3, -4, 6, 1, -1, -5, # D
8
+ -1, -4, -2, -4, 13, -3, -3, -3, -3, -2, -2, -3, -2, -2, -4, -1, -1, -5, -3, -1, -3, -3, -1, -5, # C
9
+ -1, 1, 0, 0, -3, 7, 2, -2, 1, -3, -2, 2, 0, -4, -1, 0, -1, -1, -1, -3, 0, 4, -1, -5, # Q
10
+ -1, 0, 0, 2, -3, 2, 6, -3, 0, -4, -3, 1, -2, -3, -1, -1, -1, -3, -2, -3, 1, 5, -1, -5, # E
11
+ 0, -3, 0, -1, -3, -2, -3, 8, -2, -4, -4, -2, -3, -4, -2, 0, -2, -3, -3, -4, -1, -2, -1, -5, # G
12
+ -2, 0, 1, -1, -3, 1, 0, -2, 10, -4, -3, 0, -1, -1, -2, -1, -2, -3, 2, -4, 0, 0, -1, -5, # H
13
+ -1, -4, -3, -4, -2, -3, -4, -4, -4, 5, 2, -3, 2, 0, -3, -3, -1, -3, -1, 4, -4, -3, -1, -5, # I
14
+ -2, -3, -4, -4, -2, -2, -3, -4, -3, 2, 5, -3, 3, 1, -4, -3, -1, -2, -1, 1, -4, -3, -1, -5, # L
15
+ -1, 3, 0, -1, -3, 2, 1, -2, 0, -3, -3, 6, -2, -4, -1, 0, -1, -3, -2, -3, 0, 1, -1, -5, # K
16
+ -1, -2, -2, -4, -2, 0, -2, -3, -1, 2, 3, -2, 7, 0, -3, -2, -1, -1, 0, 1, -3, -1, -1, -5, # M
17
+ -3, -3, -4, -5, -2, -4, -3, -4, -1, 0, 1, -4, 0, 8, -4, -3, -2, 1, 4, -1, -4, -4, -1, -5, # F
18
+ -1, -3, -2, -1, -4, -1, -1, -2, -2, -3, -4, -1, -3, -4, 10, -1, -1, -4, -3, -3, -2, -1, -1, -5, # P
19
+ 1, -1, 1, 0, -1, 0, -1, 0, -1, -3, -3, 0, -2, -3, -1, 5, 2, -4, -2, -2, 0, 0, -1, -5, # S
20
+ 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 2, 5, -3, -2, 0, 0, -1, -1, -5, # T
21
+ -3, -3, -4, -5, -5, -1, -3, -3, -3, -3, -2, -3, -1, 1, -4, -4, -3, 15, 2, -3, -5, -2, -1, -5, # W
22
+ -2, -1, -2, -3, -3, -1, -2, -3, 2, -1, -1, -2, 0, 4, -3, -2, -2, 2, 8, -1, -3, -2, -1, -5, # Y
23
+ 0, -3, -3, -4, -1, -3, -3, -4, -4, 4, 1, -3, 1, -1, -3, -2, 0, -3, -1, 5, -3, -3, -1, -5, # V
24
+ -2, -1, 5, 6, -3, 0, 1, -1, 0, -4, -4, 0, -3, -4, -2, 0, 0, -5, -3, -3, 6, 1, -1, -5, # B
25
+ -1, 0, 0, 1, -3, 4, 5, -2, 0, -3, -3, 1, -1, -4, -1, 0, -1, -2, -2, -3, 1, 5, -1, -5, # Z
26
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -5, # X
27
+ -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 1 # *
28
+ ]
29
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fiddle/import'
4
+
5
+ module LibSSW
6
+ module FFI
7
+ extend Fiddle::Importer
8
+
9
+ begin
10
+ dlload LibSSW.ffi_lib
11
+ rescue LoadError => e
12
+ raise LoadError, "Could not find libssw shared library. \n#{e}"
13
+ end
14
+
15
+ class << self
16
+ attr_reader :func_map
17
+
18
+ def try_extern(signature, *opts)
19
+ extern(signature, *opts)
20
+ rescue StandardError => e
21
+ warn "#{e.class.name}: #{e.message}"
22
+ end
23
+
24
+ def ffi_methods
25
+ @ffi_methods ||= func_map.each_key.to_a
26
+ end
27
+ end
28
+
29
+ Align = struct [
30
+ 'uint16_t score1',
31
+ 'uint16_t score2',
32
+ 'int32_t ref_begin1',
33
+ 'int32_t ref_end1',
34
+ 'int32_t read_begin1',
35
+ 'int32_t read_end1',
36
+ 'int32_t ref_end2',
37
+ 'uint32_t* cigar',
38
+ 'int32_t cigarLen'
39
+ ]
40
+
41
+ Profile = struct [
42
+ 'int32_t* byte', # __m128i* profile_byte; // 0: none
43
+ 'int32_t* word', # __m128i* profile_word; // 0: none
44
+ 'const int8_t* read',
45
+ 'const int8_t* mat',
46
+ 'int32_t readLen',
47
+ 'int32_t n',
48
+ 'uint8_t bias'
49
+ ]
50
+
51
+ # s_profile* ssw_init (const int8_t* read, const int32_t readLen, const int8_t* mat, const int32_t n, const int8_t score_size)
52
+ try_extern 's_profile* ssw_init (const int8_t* read, int32_t readLen, const int8_t* mat, int32_t n, int8_t score_size)'
53
+
54
+ try_extern 'void init_destroy (s_profile* p)'
55
+
56
+ try_extern 's_align* ssw_align (' \
57
+ 'const s_profile* prof,' \
58
+ 'const int8_t* ref,' \
59
+ 'int32_t refLen,' \
60
+ 'uint8_t weight_gapO,' \
61
+ 'uint8_t weight_gapE,' \
62
+ 'uint8_t flag,' \
63
+ 'uint16_t filters,' \
64
+ 'int32_t filterd,' \
65
+ 'int32_t maskLen)'
66
+
67
+ try_extern 'void align_destroy (s_align* a)'
68
+
69
+ try_extern 'int32_t mark_mismatch (' \
70
+ 'int32_t ref_begin1,' \
71
+ 'int32_t read_begin1,' \
72
+ 'int32_t read_end1,' \
73
+ 'const int8_t* ref,' \
74
+ 'const int8_t* read,' \
75
+ 'int32_t readLen,' \
76
+ 'uint32_t** cigar,' \
77
+ 'int32_t* cigarLen)'
78
+ end
79
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibSSW
4
+ VERSION = '0.0.0.pre'
5
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libssw
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - kojix2
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fiddle
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Ruby bindings for libssw
84
+ email:
85
+ - 2xijok@gmail.com
86
+ executables:
87
+ - rbssw
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - LICENSE.txt
92
+ - README.md
93
+ - exe/rbssw
94
+ - lib/libssw.rb
95
+ - lib/libssw/BLOSUM50.rb
96
+ - lib/libssw/ffi.rb
97
+ - lib/libssw/version.rb
98
+ homepage: https://github.com/kojix2/ruby-libssw
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '2.5'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">"
114
+ - !ruby/object:Gem::Version
115
+ version: 1.3.1
116
+ requirements: []
117
+ rubygems_version: 3.2.3
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Ruby bindings for libssw
121
+ test_files: []