module Bio::DB::Exonerate

RYO %St%pit%qlt%tlt%gt%Vn

Public Class Methods

align(opts={}) { |aln| ... } click to toggle source

TODO: Make a proper object with generic parser

# 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