Sha256: 7fbbaa3edcaf244d71aa0a7882fc09df4083cc31a2a5f58b1194aa25d3888d2e

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

$:<<"."
require 'test/helper'
require 'digest/md5'

class TestBioBwa < Test::Unit::TestCase
  
  def setup
    @testdata = File.join("test","data","testdata")
  end
  
  def test_short_read_alignment
    assert_nothing_raised do
      Bio::BWA.short_read_alignment(:prefix=>"#{@testdata}",:file_in=>"#{@testdata}.fa",:file_out=>"#{@testdata}.sai")
    end
    md5 = Digest::MD5::hexdigest(File.open("#{@testdata}.sai","rb") {|f| f.read})
    assert_equal("56793f4473805683a7d494808c19f79e",md5)
  end
  
  def test_long_read_alignment
    assert_nothing_raised do
      Bio::BWA.long_read_alignment(:prefix=>"#{@testdata}",:file_in=>"#{@testdata}.fa", :file_out=>"#{@testdata}.bwasw")
    end
    md5 = Digest::MD5::hexdigest(File.open("#{@testdata}.bwasw","rb") {|f| f.read})
    assert_equal("f569b0dfa7482d468bc68eb8151fb117",md5)
    FileUtils.rm("#{@testdata}.bwasw")
  end
  
  def test_simple_SW
    if RUBY_PLATFORM != 'java' then # the method redirect STDOUT to a file and this test does not pass in JRuby
      assert_nothing_raised do
        Bio::BWA.simple_SW(:long_seq=>"#{@testdata}.long.fa",:short_seq=>"#{@testdata}.short.fa",:f => true,:file_out => "#{@testdata}.stdsw")
      end
      md5 = Digest::MD5::hexdigest(File.open("#{@testdata}.stdsw","rb") {|f| f.read})
      assert_equal("cedb41d4ba3581111fbcefec6063dc86",md5)
      FileUtils.rm("#{@testdata}.stdsw")
    end
  end
  
  def test_errors
    assert_raise ArgumentError do
      Bio::BWA.long_read_alignment(:prefix=>"#{@testdata}",:file_out=>"#{@testdata}.fa")
    end
    
    assert_raise ArgumentError do
      Bio::BWA.long_read_alignment(:prefix=>"#{@testdata}",:file_in=>"#{@testdata}.fa", :file_out=>"#{@testdata}.bwasw", :unknown_parameter => "foo")
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bio-bwa-0.2.2 test/test_bio-bwa_run_aln.rb
bio-bwa-0.2.1 test/test_bio-bwa_run_aln.rb
bio-bwa-0.2.0 test/test_bio-bwa_run_aln.rb