项目作者: kojix2

项目描述 :
Powerful long read aligner for Ruby
高级语言: Ruby
项目地址: git://github.com/kojix2/ruby-minimap2.git
创建时间: 2020-12-31T04:13:33Z
项目社区:https://github.com/kojix2/ruby-minimap2

开源协议:MIT License

下载


ruby-minimap2

Gem Version
test
Docs Latest
The MIT License
DOI
Lines of Code

:dna: minimap2 - the long-read mapper - for Ruby

Installation

ruby-minimap2 bundles the Minimap2 C source code and builds it automatically during installation.

Just install the gem. Works on Linux, macOS, and Windows.

  1. gem install minimap2

Show minimap2 version (check installation)

  1. ruby -r minimap2 -e 'Minimap2.execute("--version")'

Compiling from source

git clone —recursive https://github.com/kojix2/ruby-minimap2
cd ruby-minimap2
bundle install
bundle exec rake minimap2:build
bundle exec rake install

Quick Start

  1. require "minimap2"
  2. aligner = Minimap2::Aligner.new("ext/minimap2/test/MT-human.fa")
  3. seq = aligner.seq("MT_human", 100, 200)
  4. hits = aligner.align(seq)
  5. pp hits
  1. [#<Minimap2::Alignment:0x000055bbfde2d128
  2. @blen=100,
  3. @cigar=[[100, 0]],
  4. @cigar_str="100M",
  5. @cs="",
  6. @ctg="MT_human",
  7. @ctg_len=16569,
  8. @mapq=60,
  9. @md="",
  10. @mlen=100,
  11. @nm=0,
  12. @primary=1,
  13. @q_en=100,
  14. @q_st=0,
  15. @r_en=200,
  16. @r_st=100,
  17. @read_num=1,
  18. @strand=1,
  19. @trans_strand=0>]

APIs Overview

  1. * Minimap2 module
  2. - fastx_read Read fasta/fastq file.
  3. - revcomp Reverse complement sequence.
  4. - execute Calls the main function of Minimap2 with arguments. `Minimap2.execute("--version")`
  5. * Aligner class
  6. * attributes
  7. - index Returns the value of attribute index.
  8. - idx_opt Returns the value of attribute idx_opt.
  9. - map_opt Returns the value of attribute map_opt.
  10. * methods
  11. - new(path, preset: nil) Create a new aligner. (presets: sr, map-pb, map-out, map-hifi, splice, asm5, etc.)
  12. - align Maps and returns alignments.
  13. - seq Retrieve a subsequence from the index.
  14. * Alignment class
  15. * attributes
  16. - ctg Returns name of the reference sequence the query is mapped to.
  17. - ctg_len Returns total length of the reference sequence.
  18. - r_st Returns start positions on the reference.
  19. - r_en Returns end positions on the reference.
  20. - strand Returns +1 if on the forward strand; -1 if on the reverse strand.
  21. - trans_strand Returns transcript strand. +1 if on the forward strand; -1 if on the reverse strand; 0 if unknown.
  22. - blen Returns length of the alignment, including both alignment matches and gaps but excluding ambiguous bases.
  23. - mlen Returns length of the matching bases in the alignment, excluding ambiguous base matches.
  24. - nm Returns number of mismatches, gaps and ambiguous positions in the alignment.
  25. - primary Returns if the alignment is primary (typically the best and the first to generate).
  26. - q_st Returns start positions on the query.
  27. - q_en Returns end positions on the query.
  28. - mapq Returns mapping quality.
  29. - 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.
  30. - read_num Returns read number that the alignment corresponds to; 1 for the first read and 2 for the second read.
  31. - cs Returns the cs tag.
  32. - 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.
  33. - cigar_str Returns CIGAR string.
  34. * methods
  35. - to_h Convert Alignment to hash.
  36. - to_s Convert to the PAF format without the QueryName and QueryLength columns.
  37. ## FFI module
  38. * IdxOpt class Indexing options.
  39. * MapOpt class Mapping options.
  • API is based on Mappy, the official Python binding for Minimap2.
  • Aligner#map has been changed to align, because map means iterator in Ruby.
  • See documentation for details.

C Structures and Functions

### FFI

- Ruby-Minimap2 is built on top of Ruby-FFI.
- Native C functions can be called from the Minimap2::FFI module.
- Native C structure members can be accessed.
- Bitfields are supported by ffi-bitfield gems.

ruby aligner.idx_opt.members # => [:k, :w, :flag, :bucket_bits, :mini_batch_size, :batch_size] aligner.kds_opt.values # => [15, 10, 0, 14, 50000000, 9223372036854775807] aligner.idx_opt[:k] # => 15 aligner.idx_opt[:k] = 14 aligner.idx_opt[:k] # => 14

Contributing


Development

Fork your repository.
then clone.

sh git clone --recursive https://github.com/kojix2/ruby-minimap2 # git clone https://github.com/kojix2/ruby-minimap2 # cd ruby-minimap2 # git submodule update -i

Build Minimap2 and Mappy.

sh cd ruby-minimap2 bundle install # Install dependent packages including Ruby-FFI bundle exec rake minimap2:build

A shared library will be created in the vendor directory.

└── vendor └── libminimap2.so

Run tests.

bundle exec rake test

Release a Gem.

bundle exec rake minimap2:cleanall bundle exec rake build 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. bundle exec rake release

ruby-minimap2 is a library under development and there are many points to be improved.

Please feel free to report bugs and pull requests!

Many OSS projects become abandoned because only the founder has commit rights to the original repository.
If you need commit rights to ruby-minimap2 repository or want to get admin rights and take over the project, please feel free to contact me @kojix2.

License

MIT License

Acknowledgements

I would like to thank Heng Li for making Minimap2, and all the readers who read the README to the end.