ruby-minigraph 0.0.20.0 → 0.0.20.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49f58deab3da3bede2c3097c3f1cd2c246adc9f327b2c1f4dce099d60b4ddddb
4
- data.tar.gz: e877833193973c617c12247901cc4ea18f1718dbce408f877052b702da533d94
3
+ metadata.gz: 934b7b35cb14c887f287dc2544e808861427238fb58ff46ba5b8f6692dc68052
4
+ data.tar.gz: 05eee8eb22678f9f06aa5cf015fdb12e5d9fadc9292ccf42eeed4efaf8d01035
5
5
  SHA512:
6
- metadata.gz: c185b325b680d528d55c069e9b9f0697cdde2dd73bbe7f8cce68215e07a1c32335c633217656592c0c33fdc5b97570f33768cb8208338ccbb3288d981f12ee83
7
- data.tar.gz: a3d3787cd6534192f9366b1c4b1eb9cba0a0520904e583a21d7fd6251eb1958e0bdfa22e586ae8bb5a9223a3fc11218a0c68c830ab54c8e027f4e6f15b0a1bf6
6
+ metadata.gz: 87f708b8f786eba2ac9bfbb6c532e24baf8bd2c062c794de09d76109bab27d9080a5ecad2d7a2307c1edc2a5e6d1ccbdd1cc2efd43c6f0f2b5cc91e5a177e960
7
+ data.tar.gz: 850538b9318cb51ca6180b081fe0a2004830406965aa87211018c9a421ab0b8d272630b1fb0238c6b3f50851661660fde9e3fd5d5b3a274bce1741511c99e40b
data/README.md CHANGED
@@ -12,7 +12,12 @@
12
12
 
13
13
  ## Installation
14
14
 
15
- You need to install it from the source code. Because you need to build minigraph and create a shared library. Open your terminal and type the following commands in order.
15
+ ```sh
16
+ gem install ruby-minigraph
17
+ ```
18
+
19
+ <details>
20
+ <summary><b>Compiling from source</b></summary>
16
21
 
17
22
  ```sh
18
23
  git clone --recursive https://github.com/kojix2/ruby-minigraph
@@ -22,20 +27,47 @@ bundle exec rake minigraph:build
22
27
  bundle exec rake install
23
28
  ```
24
29
 
25
- You can run tests to see if the installation was successful.
26
-
27
- ```
28
- bundle exec rake test
29
- ```
30
+ </details>
30
31
 
31
32
  ## Quick Start
32
33
 
33
34
  ```ruby
34
35
  require "minigraph"
36
+
37
+ Minigraph.execute("--version")
35
38
  ```
36
39
 
37
40
  ## APIs
38
41
 
42
+ Only low-level functions are provided at this time.
43
+
44
+ ```ruby
45
+ require "minigraph"
46
+
47
+ MG = Minigraph
48
+
49
+ n_threads = 4
50
+
51
+ target = "ext/minigraph/test/MT-human.fa"
52
+ queries = ["ext/minigraph/test/MT-orangeA.fa"]
53
+
54
+ opt = MG::FFI::MapOpt.new
55
+ ipt = MG::FFI::IdxOpt.new
56
+ gpt = MG::FFI::GGOpt.new
57
+
58
+ MG::FFI.mg_opt_set(0, ipt, opt, gpt)
59
+
60
+ g = MG::FFI.gfa_read(target)
61
+
62
+ ptr = FFI::MemoryPointer.new(:pointer, queries.length)
63
+ ptrs = queries.map{ FFI::MemoryPointer.from_string(_1) }
64
+ ptr.write_array_of_pointer(ptrs)
65
+
66
+ MG::FFI.mg_map_files(g, 1, ptr, ipt, opt, n_threads)
67
+
68
+ MG::FFI.gfa_destroy(g)
69
+ ```
70
+
39
71
  ## Development
40
72
 
41
73
  ```sh
@@ -66,8 +66,8 @@ module Minigraph
66
66
  # indexing option
67
67
  class IdxOpt < ::FFI::Struct
68
68
  layout \
69
- :k, :int,
70
69
  :w, :int,
70
+ :k, :int,
71
71
  :bucket_bits, :int
72
72
  end
73
73
 
@@ -9,10 +9,22 @@ module Minigraph
9
9
 
10
10
  # options
11
11
  attach_function \
12
- :mg_opt_set,
13
- [:string, IdxOpt.by_ref, MapOpt.by_ref, GGOpt.by_ref],
12
+ :mg_opt_set_raw, :mg_opt_set,
13
+ [:pointer, IdxOpt.by_ref, MapOpt.by_ref, GGOpt.by_ref],
14
14
  :int
15
15
 
16
+ private_class_method :mg_opt_set_raw
17
+
18
+ def self.mg_opt_set(preset, io, mo, go)
19
+ ptr = case preset
20
+ when 0, nil
21
+ ::FFI::Pointer.new(:int, 0)
22
+ else
23
+ ::FFI::MemoryPointer.from_string(preset.to_s)
24
+ end
25
+ mg_opt_set_raw(ptr, io, mo, go)
26
+ end
27
+
16
28
  attach_function \
17
29
  :mg_opt_check,
18
30
  [IdxOpt.by_ref, MapOpt.by_ref, GGOpt.by_ref],
@@ -66,5 +78,47 @@ module Minigraph
66
78
  :mg_ggen,
67
79
  [:pointer, :int32, :pointer, IdxOpt.by_ref, MapOpt.by_ref, GGOpt.by_ref, :int], # FIXME: gfa_t
68
80
  :int
81
+
82
+ attach_function \
83
+ :mg_idxopt_init,
84
+ [IdxOpt.by_ref],
85
+ :void
86
+
87
+ attach_function \
88
+ :mg_mapopt_init,
89
+ [MapOpt.by_ref],
90
+ :void
91
+
92
+ attach_function \
93
+ :mg_ggopt_init,
94
+ [GGOpt.by_ref],
95
+ :void
96
+
97
+ # gfa.h
98
+
99
+ attach_function \
100
+ :gfa_init,
101
+ [:void],
102
+ :pointer # gfa_t *
103
+
104
+ attach_function \
105
+ :gfa_destroy,
106
+ [:pointer], # gfa_t *
107
+ :void
108
+
109
+ attach_function \
110
+ :gfa_read,
111
+ [:string],
112
+ :pointer # gfa_t *
113
+
114
+ attach_function \
115
+ :gfa_print,
116
+ %i[pointer pointer int],
117
+ :void
118
+
119
+ attach_function \
120
+ :gfa_sort_ref_arc,
121
+ [:pointer], # gfa_t *
122
+ :void
69
123
  end
70
124
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Minigraph
4
- VERSION = "0.0.20.0"
4
+ VERSION = "0.0.20.1"
5
5
  end
data/lib/minigraph.rb CHANGED
@@ -10,6 +10,7 @@ require_relative "minigraph/version"
10
10
  # https://github.com/lh3/minigraph
11
11
  # Li, H., Feng, X. & Chu, C. The design and construction of reference pangenome graphs
12
12
  # with minigraph. Genome Biol 21, 265 (2020). https://doi.org/10.1186
13
+
13
14
  module Minigraph
14
15
  class Error < StandardError; end
15
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-minigraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20.0
4
+ version: 0.0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-21 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -137,7 +137,7 @@ homepage: https://github.com/kojix2/ruby-minigraph
137
137
  licenses:
138
138
  - MIT
139
139
  metadata: {}
140
- post_install_message:
140
+ post_install_message:
141
141
  rdoc_options: []
142
142
  require_paths:
143
143
  - lib
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubygems_version: 3.4.10
156
- signing_key:
156
+ signing_key:
157
157
  specification_version: 4
158
158
  summary: Ruby bindings for minigraph
159
159
  test_files: []