Module: Bio::DB::Exonerate

Defined in:
lib/bio/db/exonerate.rb

Defined Under Namespace

Classes: Alignment, ExonerateException, Vulgar

Class Method Summary collapse

Class Method Details

.align(opts = {}) ⇒ Object

TODO: Make a proper object with generic parser



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bio/db/exonerate.rb', line 8

def self.align(opts={})
  opts = {
    :model => 'affine:local' ,
    :ryo => "RESULT:\\t%S\\t%pi\\t%ql\\t%tl\\t%g\\t%V\\n" , 
    :bestn => 20,
    :percentage => 50
  }
  .merge(opts)

  target=opts[:target]
  query=opts[:query]

  cmdline = "exonerate --verbose 0 --showalignment no --bestn #{opts[:bestn]} --showvulgar no  --model #{opts[:model]}   --ryo '#{opts[:ryo]}' #{query} #{target}"
  status, stdout, stderr = systemu cmdline
  #$stderr.puts cmdline
  if status.exitstatus == 0
    alns = Array.new unless block_given?
    stdout.each_line do |line|
      aln = Alignment.parse_custom(line) 
      if aln
        if block_given?
          yield aln
        else
          alns << aln
        end
      end
    end
    return alns unless block_given?
  else
    raise ExonerateException.new(), "Error running exonerate. Command line was '#{cmdline}'\nExonerate STDERR was:\n#{stderr}"
  end
end