Module: Minimap2
- Defined in:
- lib/minimap2.rb,
lib/minimap2/ffi.rb,
lib/minimap2/aligner.rb,
lib/minimap2/version.rb,
lib/minimap2/alignment.rb,
lib/minimap2/ffi/mappy.rb,
lib/minimap2/ffi/constants.rb,
lib/minimap2/ffi/functions.rb
Overview
Defined Under Namespace
Modules: FFI Classes: Aligner, Alignment, Error
Constant Summary collapse
- VERSION =
"0.2.28.0"
Class Attribute Summary collapse
-
.ffi_lib ⇒ Object
Returns the value of attribute ffi_lib.
Class Method Summary collapse
-
.execute(arg0, arg1, ...) ⇒ Object
Execute minimap2 comannd with given options.
-
.fastx_read(file_path, comment: false) {|name, seq, qual, comment| ... } ⇒ Enumerator
Read fasta/fastq file.
-
.revcomp(seq) ⇒ string
Reverse complement sequence.
-
.verbose ⇒ Integer
Get verbosity level.
-
.verbose=(level) ⇒ Integer
Set verbosity level.
Class Attribute Details
.ffi_lib ⇒ Object
Returns the value of attribute ffi_lib.
19 20 21 |
# File 'lib/minimap2.rb', line 19 def ffi_lib @ffi_lib end |
Class Method Details
.execute(arg0, arg1, ...) ⇒ Object
Execute minimap2 comannd with given options.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/minimap2.rb', line 40 def execute(*rb_argv) str_ptrs = [] # First argument is the program name. str_ptrs << ::FFI::MemoryPointer.from_string("minimap2") rb_argv.each do |arg| arg.to_s.split(/\s+/).each do |s| str_ptrs << ::FFI::MemoryPointer.from_string(s) end end str_ptrs << nil # Load all the pointers into a native memory block argv = ::FFI::MemoryPointer.new(:pointer, str_ptrs.length) str_ptrs.each_with_index do |p, i| argv[i].put_pointer(0, p) end FFI.main(str_ptrs.length - 1, argv) end |
.fastx_read(file_path, comment: false) {|name, seq, qual, comment| ... } ⇒ Enumerator
Read fasta/fastq file. Note: You can BioRuby instead of this method.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/minimap2.rb', line 82 def fastx_read(file_path, comment: false, &block) path = File.(file_path) # raise error in Ruby because ks.null? is false even if file not exist. raise ArgumentError, "File not found: #{path}" unless File.exist?(path) ks = FFI.mm_fastx_open(path) if block_given? fastx_each(ks, comment, &block) else Enumerator.new do |y| # rewind not work fastx_each(ks, comment) { |r| y << r } end end end |
.revcomp(seq) ⇒ string
Reverse complement sequence.
104 105 106 107 108 109 |
# File 'lib/minimap2.rb', line 104 def revcomp(seq) l = seq.size bseq = ::FFI::MemoryPointer.new(:char, l) bseq.put_bytes(0, seq) FFI.mappy_revcomp(l, bseq) end |
.verbose ⇒ Integer
Get verbosity level.
63 64 65 |
# File 'lib/minimap2.rb', line 63 def verbose FFI.mm_verbose_level(-1) end |
.verbose=(level) ⇒ Integer
Set verbosity level.
71 72 73 |
# File 'lib/minimap2.rb', line 71 def verbose=(level) FFI.mm_verbose_level(level) end |