minimap2 0.2.31.0 → 1.2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -64
  3. data/ext/ruby_minimap2/extconf.rb +47 -0
  4. data/ext/ruby_minimap2/native_main.c +15 -0
  5. data/ext/ruby_minimap2/ruby_minimap2.c +1134 -0
  6. data/lib/minimap2/aligner.rb +66 -383
  7. data/lib/minimap2/alignment.rb +15 -8
  8. data/lib/minimap2/version.rb +2 -1
  9. data/lib/minimap2.rb +39 -110
  10. metadata +8 -89
  11. data/ext/Rakefile +0 -63
  12. data/ext/cmappy/cmappy.c +0 -134
  13. data/ext/cmappy/cmappy.h +0 -46
  14. data/ext/minimap2/FAQ.md +0 -46
  15. data/ext/minimap2/MANIFEST.in +0 -10
  16. data/ext/minimap2/Makefile.simde +0 -97
  17. data/ext/minimap2/NEWS.md +0 -1022
  18. data/ext/minimap2/README.md +0 -429
  19. data/ext/minimap2/code_of_conduct.md +0 -30
  20. data/ext/minimap2/cookbook.md +0 -243
  21. data/ext/minimap2/minimap2.1 +0 -844
  22. data/ext/minimap2/misc/README.md +0 -180
  23. data/ext/minimap2/misc/pafcluster.js +0 -241
  24. data/ext/minimap2/misc/paftools.js +0 -3830
  25. data/ext/minimap2/pyproject.toml +0 -2
  26. data/ext/minimap2/python/README.rst +0 -198
  27. data/ext/minimap2/python/cmappy.h +0 -152
  28. data/ext/minimap2/python/cmappy.pxd +0 -157
  29. data/ext/minimap2/python/mappy.pyx +0 -297
  30. data/ext/minimap2/python/minimap2.py +0 -43
  31. data/ext/minimap2/setup.py +0 -55
  32. data/ext/minimap2/test/MT-human.fa +0 -278
  33. data/ext/minimap2/test/MT-orang.fa +0 -276
  34. data/ext/minimap2/test/q-inv.fa +0 -4
  35. data/ext/minimap2/test/q2.fa +0 -2
  36. data/ext/minimap2/test/t-inv.fa +0 -127
  37. data/ext/minimap2/test/t2.fa +0 -2
  38. data/ext/minimap2/test/x3s-aln.txt +0 -5
  39. data/ext/minimap2/test/x3s-qry.fa +0 -5
  40. data/ext/minimap2/test/x3s-ref.fa +0 -10
  41. data/ext/minimap2/tex/Makefile +0 -21
  42. data/ext/minimap2/tex/bioinfo.cls +0 -930
  43. data/ext/minimap2/tex/blasr-mc.eval +0 -17
  44. data/ext/minimap2/tex/bowtie2-s3.sam.eval +0 -28
  45. data/ext/minimap2/tex/bwa-s3.sam.eval +0 -52
  46. data/ext/minimap2/tex/bwa.eval +0 -55
  47. data/ext/minimap2/tex/eval2roc.pl +0 -33
  48. data/ext/minimap2/tex/graphmap.eval +0 -4
  49. data/ext/minimap2/tex/hs38-simu.sh +0 -10
  50. data/ext/minimap2/tex/minialign.eval +0 -49
  51. data/ext/minimap2/tex/minimap2.bib +0 -460
  52. data/ext/minimap2/tex/minimap2.tex +0 -724
  53. data/ext/minimap2/tex/mm2-s3.sam.eval +0 -62
  54. data/ext/minimap2/tex/mm2-update.tex +0 -240
  55. data/ext/minimap2/tex/mm2.approx.eval +0 -12
  56. data/ext/minimap2/tex/mm2.eval +0 -13
  57. data/ext/minimap2/tex/natbib.bst +0 -1288
  58. data/ext/minimap2/tex/natbib.sty +0 -803
  59. data/ext/minimap2/tex/ngmlr.eval +0 -38
  60. data/ext/minimap2/tex/roc.gp +0 -60
  61. data/ext/minimap2/tex/snap-s3.sam.eval +0 -62
  62. data/ext/minimap2.patch +0 -19
  63. data/lib/minimap2/ffi/constants.rb +0 -267
  64. data/lib/minimap2/ffi/functions.rb +0 -245
  65. data/lib/minimap2/ffi/mappy.rb +0 -104
  66. data/lib/minimap2/ffi.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b27519808e7302696fd897b42041bc6f6f11ac114bc9654a91c07c59f5284813
4
- data.tar.gz: 8adb8dd6b933029ce21b66269750dc1017af4c5e3f292fb7f3da65c7bd25eae7
3
+ metadata.gz: 66111ad941edb14875a0f3c66f8ac1f5cbef18182bb96cb2a363f8ec29e6e817
4
+ data.tar.gz: 2ce71684a6a25196f7735252888cbdc1ff66674829edbb72d492184ecc171510
5
5
  SHA512:
6
- metadata.gz: 30ac518def61ad07b388acb1a20dd4857cd7de124c3ca7eb942049834a6927763e2c31e8f9da12457eae786fad92a8153a28cb711f027124521721b7147eb4b0
7
- data.tar.gz: 9cf1e73fb89b42a55630b049a9dd0a8612c68910f3b02227c2a19a2b0b57963497f7dce1e78dc0f13eafc69967f21eb2e5526808c4bda4d02f9f1bc6a57a57ef
6
+ metadata.gz: 6f708837128825a21efe2428ccef35f985c6de313d7dc2a669ef45b6ba17873a3672859fcc72c11f2dfd12af26686f5e5909f952a99fb7a519a37749d59798c4
7
+ data.tar.gz: '0083cf367e4bfd1c9eeeeea626289d97d064cc69efd47e1bcb50fddbe13ffece5f5d8b4f540926daaaa3224eed225227cd2a07b367d310bbf34a906c164dafb3'
data/README.md CHANGED
@@ -11,9 +11,9 @@
11
11
 
12
12
  ## Installation
13
13
 
14
- ruby-minimap2 bundles the Minimap2 C source code and builds it automatically during installation.
14
+ ruby-minimap2 bundles the Minimap2 C source code and builds a native extension during installation.
15
15
 
16
- Just install the gem. Works on Linux, macOS, and Windows.
16
+ Ruby 3.3 or later is required. Works on Linux, macOS, and Windows.
17
17
 
18
18
  ```
19
19
  gem install minimap2
@@ -41,30 +41,39 @@ ruby -r minimap2 -e 'Minimap2.execute("--version")'
41
41
  ```ruby
42
42
  require "minimap2"
43
43
 
44
- aligner = Minimap2::Aligner.new("ext/minimap2/test/MT-human.fa")
45
- seq = aligner.seq("MT_human", 100, 200)
46
- hits = aligner.align(seq, cs: true, ds: true)
44
+ reference = <<~DNA.delete("\n")
45
+ GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCATTTGGTATTTTCGTCTGGGGGGTATGCACGC
46
+ GATAGCATTGCGAGACGCTGGAGCCGGAGCACCCTATGTCGCAGTATCTGTCTTTGATTCCTGCCTCATCCTATTATTTAT
47
+ CGCACCTACGTTCAATATTACAGGCGAACATACTTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGACATAATAATAACA
48
+ ATTGAATGTCTGCACAGCCACTTTCCACACAGACATCATAACAAAAAATTTCCACCAAACCCCCCCTCCCCCGCTTC
49
+ DNA
50
+
51
+ aligner = Minimap2::Aligner.new(seq: reference)
52
+ query = reference[50, 200]
53
+ hits = aligner.align(query, name: "query", cs: true, ds: true)
47
54
  pp hits
48
55
  ```
49
56
 
50
57
  ```
51
58
  [#<Minimap2::Alignment:0x000055bbfde2d128
52
- @blen=100,
53
- @cigar=[[100, 0]],
54
- @cigar_str="100M",
55
- @cs=":100",
56
- @ctg="MT_human",
57
- @ctg_len=16569,
58
- @ds=":100",
59
+ @blen=200,
60
+ @cigar=[[200, 0]],
61
+ @cigar_str="200M",
62
+ @cs=":200",
63
+ @ctg="N/A",
64
+ @ctg_len=320,
65
+ @ds=":200",
59
66
  @mapq=60,
60
- @md="",
61
- @mlen=100,
67
+ @md=nil,
68
+ @mlen=200,
62
69
  @nm=0,
63
70
  @primary=1,
64
- @q_en=100,
71
+ @q_en=200,
65
72
  @q_st=0,
66
- @r_en=200,
67
- @r_st=100,
73
+ @qlen=200,
74
+ @qname="query",
75
+ @r_en=250,
76
+ @r_st=50,
68
77
  @read_num=1,
69
78
  @strand=1,
70
79
  @trans_strand=0>]
@@ -77,19 +86,25 @@ pp hits
77
86
  - fastx_read Read fasta/fastq file.
78
87
  - revcomp Reverse complement sequence.
79
88
  - execute Calls the main function of Minimap2 with arguments. `Minimap2.execute("--version")`
89
+ - verbose Returns the Minimap2 verbosity level.
90
+ - verbose= Sets the Minimap2 verbosity level.
80
91
 
81
92
  * Aligner class
82
- * attributes
83
- - index Returns the value of attribute index.
84
- - idx_opt Returns the value of attribute idx_opt.
85
- - map_opt Returns the value of attribute map_opt.
86
93
  * methods
87
- - new(path, preset: nil) Create a new aligner. (presets: sr, map-pb, map-out, map-hifi, splice, asm5, etc.)
94
+ - new(path, preset: nil) Create a new aligner. (presets: sr, map-pb, map-ont, map-hifi, splice, asm5, etc.)
88
95
  - align Maps and returns alignments.
89
96
  - seq Retrieve a subsequence from the index.
97
+ - k Returns the minimizer k-mer length.
98
+ - w Returns the minimizer window size.
99
+ - n_seq Returns the number of sequences in the index.
100
+ - seq_names Returns sequence names in the index.
101
+ - index? Returns whether the aligner has a live index.
102
+ - free_index Releases the index.
90
103
 
91
104
  * Alignment class
92
105
  * attributes
106
+ - qname Returns the query sequence name.
107
+ - qlen Returns the query sequence length.
93
108
  - ctg Returns name of the reference sequence the query is mapped to.
94
109
  - ctg_len Returns total length of the reference sequence.
95
110
  - r_st Returns start positions on the reference.
@@ -105,47 +120,22 @@ pp hits
105
120
  - mapq Returns mapping quality.
106
121
  - cigar Returns CIGAR returned as an array of shape (n_cigar,2). The two numbers give the length and the operator of each CIGAR operation.
107
122
  - read_num Returns read number that the alignment corresponds to; 1 for the first read and 2 for the second read.
108
- - cs Returns the cs tag.
109
- - ds Returns the ds tag.
110
- - md Returns the MD tag as in the SAM format. It is an empty string unless the md argument is applied when calling Aligner#align.
123
+ - cs Returns the cs tag, or nil unless requested.
124
+ - ds Returns the ds tag, or nil unless requested.
125
+ - md Returns the MD tag, or nil unless requested.
111
126
  - cigar_str Returns CIGAR string.
112
127
  * methods
113
128
  - to_h Convert Alignment to hash.
114
- - to_s Convert to the PAF format without the QueryName and QueryLength columns.
115
-
116
- ## FFI module
117
- * IdxOpt class Indexing options.
118
- * MapOpt class Mapping options.
129
+ - to_s Convert to the PAF format.
119
130
  ```
120
131
 
121
132
  - API is based on [Mappy](https://github.com/lh3/minimap2/tree/master/python), the official Python binding for Minimap2.
122
133
  - `Aligner#map` has been changed to `align`, because `map` means iterator in Ruby.
134
+ - Calls on the same Aligner are thread-safe and serialized. Different Aligner instances can run concurrently.
135
+ - Multipart indexes are supported, but primary alignments and mapping quality are calculated independently for each part.
136
+ - Sequence data uses ASCII-8BIT. Names read from an index use UTF-8.
123
137
  - See [documentation](https://kojix2.github.io/ruby-minimap2/) for details.
124
138
 
125
- <details>
126
- <summary><b>C Structures and Functions</b></summary>
127
-
128
- ### FFI
129
-
130
- - Ruby-Minimap2 is built on top of [Ruby-FFI](https://github.com/ffi/ffi).
131
- - Native C functions can be called from the `Minimap2::FFI` module.
132
- - Native C structure members can be accessed.
133
- - Bitfields are supported by [ffi-bitfield](https://github.com/kojix2/ffi-bitfield) gems.
134
-
135
- ```ruby
136
- aligner.idx_opt.members
137
- # => [:k, :w, :flag, :bucket_bits, :mini_batch_size, :batch_size]
138
- aligner.kds_opt.values
139
- # => [15, 10, 0, 14, 50000000, 9223372036854775807]
140
- aligner.idx_opt[:k]
141
- # => 15
142
- aligner.idx_opt[:k] = 14
143
- aligner.idx_opt[:k]
144
- # => 14
145
- ```
146
-
147
- </details>
148
-
149
139
  ## Contributing
150
140
 
151
141
  <details>
@@ -161,21 +151,14 @@ git clone --recursive https://github.com/kojix2/ruby-minimap2
161
151
  # git submodule update -i
162
152
  ```
163
153
 
164
- Build Minimap2 and Mappy.
154
+ Build the native extension.
165
155
 
166
156
  ```sh
167
157
  cd ruby-minimap2
168
- bundle install # Install dependent packages including Ruby-FFI
158
+ bundle install
169
159
  bundle exec rake minimap2:build
170
160
  ```
171
161
 
172
- A shared library will be created in the vendor directory.
173
-
174
- ```
175
- └── vendor
176
- └── libminimap2.so
177
- ```
178
-
179
162
  Run tests.
180
163
 
181
164
  ```
@@ -187,7 +170,7 @@ Release a Gem.
187
170
  ```
188
171
  bundle exec rake minimap2:cleanall
189
172
  bundle exec rake build
190
- ls -l pkg # Check the size of the Gem and make sure it does not contain any unused code such as shared libraries or lib/simde.
173
+ ls -l pkg # Check the size of the Gem.
191
174
  bundle exec rake release
192
175
  ```
193
176
 
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "fileutils"
5
+ require "rbconfig"
6
+ require "shellwords"
7
+
8
+ source_dir = File.expand_path("../minimap2", __dir__)
9
+ build_dir = File.expand_path("build/minimap2", Dir.pwd)
10
+
11
+ abort "minimap2 sources are missing; initialize the git submodule" unless File.file?(File.join(source_dir, "minimap.h"))
12
+ abort "zlib is required to build ruby-minimap2" unless have_library("z", "gzopen")
13
+ have_func("log") || have_library("m", "log")
14
+ if !(RbConfig::CONFIG.fetch("host_os") =~ /mswin/) && !(have_func("pthread_create") || have_library("pthread",
15
+ "pthread_create"))
16
+ abort "pthread is required to build ruby-minimap2"
17
+ end
18
+
19
+ FileUtils.rm_rf(build_dir)
20
+ FileUtils.mkdir_p(build_dir)
21
+ FileUtils.cp_r(Dir.glob(File.join(source_dir, "*")), build_dir)
22
+
23
+ host_cpu = RbConfig::CONFIG.fetch("host_cpu")
24
+ cflags = %w[-O2 -fPIC]
25
+ cflags.concat(Shellwords.split(RbConfig::CONFIG["ARCH_FLAG"].to_s))
26
+ make_args = ["libminimap2.a", "CC=#{RbConfig::CONFIG.fetch('CC')}"]
27
+ make_args << "AR=#{RbConfig::CONFIG['AR']}" unless RbConfig::CONFIG["AR"].to_s.empty?
28
+
29
+ case host_cpu
30
+ when /arm64|aarch64/
31
+ make_args.concat(["aarch64=1", "INCLUDES=-Isse2neon"])
32
+ cflags.concat(%w[-D_FILE_OFFSET_BITS=64 -fsigned-char])
33
+ when /arm/
34
+ make_args.concat(["arm_neon=1", "INCLUDES=-Isse2neon"])
35
+ cflags.concat(%w[-D_FILE_OFFSET_BITS=64 -mfpu=neon -fsigned-char])
36
+ end
37
+ make_args << "CFLAGS=#{cflags.join(' ')}"
38
+
39
+ Dir.chdir(build_dir) do
40
+ abort "failed to build bundled minimap2" unless system(RbConfig::CONFIG.fetch("MAKE", "make"), *make_args)
41
+ end
42
+
43
+ $INCFLAGS << " -I#{build_dir.quote}"
44
+ $LOCAL_LIBS << " #{File.join(build_dir, 'libminimap2.a').quote}"
45
+ $defs << "-DRUBY_MINIMAP2_TESTING" if enable_config("testing", false)
46
+
47
+ create_makefile("minimap2/minimap2_ext")
@@ -0,0 +1,15 @@
1
+ #include <stdlib.h>
2
+
3
+ #ifdef __clang__
4
+ #pragma clang diagnostic push
5
+ #pragma clang diagnostic ignored "-Wshorten-64-to-32"
6
+ #pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
7
+ #endif
8
+
9
+ #define main mm2_embedded_main
10
+ #define exit(status) return (status)
11
+ #include "build/minimap2/main.c"
12
+
13
+ #ifdef __clang__
14
+ #pragma clang diagnostic pop
15
+ #endif