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.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.ffi_libObject

Returns the value of attribute ffi_lib.



22
23
24
# File 'lib/minimap2.rb', line 22

def ffi_lib
  @ffi_lib
end

Class Method Details

.fastx_read(file_path, read_comment = false) {|name, seq, qual, comment| ... } ⇒ Object

read fasta/fastq file Note: You can also use a generic library such as BioRuby instead of this method.

Parameters:

  • file_path (String)
  • read_comment (Boolean) (defaults to: false)

    If false or nil, the comment will not be read.

Yields:

  • (name, seq, qual, comment)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/minimap2.rb', line 43

def fastx_read(file_path, read_comment = false)
  path = File.expand_path(file_path)
  ks = FFI.mm_fastx_open(path)
  while FFI.kseq_read(ks) >= 0
    qual = ks[:qual][:s] if (ks[:qual][:l]).positive?
    name = ks[:name][:s]
    seq  = ks[:seq][:s]
    if read_comment
      comment = ks[:comment][:s] if (ks[:comment][:l]).positive?
      yield [name, seq, qual, comment]
    else
      yield [name, seq, qual]
    end
  end
  FFI.mm_fastx_close(ks)
end

.revcomp(seq) ⇒ string

reverse complement sequence

Parameters:

  • seq (String)

Returns:

  • (string)

    seq



64
65
66
67
68
69
# File 'lib/minimap2.rb', line 64

def revcomp(seq)
  l = seq.size
  bseq = ::FFI::MemoryPointer.new(:char, l)
  bseq.put_bytes(0, seq)
  FFI.mappy_revcomp(l, bseq)
end

.verbose(level = -1)) ⇒ Object

set verbosity level

Parameters:

  • level (Integer) (defaults to: -1))


74
75
76
# File 'lib/minimap2.rb', line 74

def verbose(level = -1)
  FFI.mm_verbose_level(level)
end