Class: BioDSL::Mummer

Inherits:
Object
  • Object
show all
Defined in:
lib/BioDSL/mummer.rb

Overview

Class for executing MUMmer and parsing MUMmer results.

Defined Under Namespace

Classes: Match

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seq1, seq2, options = {}) ⇒ Mummer

Constructor for Mummer class.

Parameters:

  • seq1 (BioDSL::Seq)

    Sequence 1.

  • seq2 (BioPeices::Seq)

    Sequence 2.

  • options (Hash) (defaults to: {})

    Options hash.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/BioDSL/mummer.rb', line 59

def initialize(seq1, seq2, options = {})
  @seq1    = seq1
  @seq2    = seq2
  @options = options
  @command = []
  @q_id    = nil
  @dir     = nil

  default_options
  check_options
end

Class Method Details

.each_mem(seq1, seq2, options = {}) {|Mummer::Match| ... } ⇒ Enumerable

Returns An Enumerable.

Parameters:

  • seq1 (BioDSL::Seq)

    Sequence 1.

  • seq2 (BioPeices::Seq)

    Sequence 2.

  • options (Hash) (defaults to: {})

    Options hash.

Yields:

Returns:

  • (Enumerable)

    An Enumerable



42
43
44
45
46
47
48
49
50
# File 'lib/BioDSL/mummer.rb', line 42

def self.each_mem(seq1, seq2, options = {})
  mummer = new(seq1, seq2, options)

  if block_given?
    mummer.each_mem { |mem| yield mem }
  else
    mummer.each_mem
  end
end

Instance Method Details

#each_mem {|Mummer::Match| ... } ⇒ Enumerable

Returns An Enumerable.

Yields:

Returns:

  • (Enumerable)

    An Enumerable



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/BioDSL/mummer.rb', line 73

def each_mem
  return to_enum :each_mem unless block_given?

  TmpDir.create('in1', 'in2', 'out') do |file_in1, file_in2, file_out|
    BioDSL::Fasta.open(file_in1, 'w') { |io| io.puts @seq1.to_fasta }
    BioDSL::Fasta.open(file_in2, 'w') { |io| io.puts @seq2.to_fasta }

    execute(file_in1, file_in2, file_out)

    File.open(file_out) do |io|
      while (match = get_match(io))
        yield match
      end
    end
  end
end