Sha256: 21aad207feec53b20caa981db42afc987545d2082f4f896b223b32f0eb1094a9

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 KB

Contents

require 'test/unit'
require File.dirname(File.expand_path(__FILE__)) + '/load_bin_path'


class PrecTest < Test::Unit::TestCase
  ROOT_DIR = File.join(File.dirname(__FILE__), "..")

  def initialize(arg)
    super(arg)
    @tfiles = File.dirname(__FILE__) + '/tfiles/'
    @tf_bioworks_esmall_xml = @tfiles + "bioworks_with_INV_small.xml" 
    @tf_bioworks_shuff = @tfiles + "bioworks_with_SHUFF_small.xml"
    @cmd = "ruby -I#{File.join(ROOT_DIR, "lib")} -S precision.rb "
    @tf_html = @tfiles + "ppv.html"
    @tf_png = @tfiles + "ppv.png"
    @nodelete = false
  end

  def test_usage
    assert_match(/Usage:/, `#{@cmd}`)
  end

  def test_basic_cat
    output = `#{@cmd} -o #{@tf_html} -f SHUFF_ --prefix #{@tf_bioworks_shuff}`
    puts output
    
    assert_match(/<table.*<\/table>/m, IO.read(@tf_html), "has html table in it")
    assert_match(/10.*0.3000/m, IO.read(@tf_html), "has values")
    [@tf_html, @tf_png].each do |file|
      assert(File.exist?(file), "file #{file} exists")
      File.unlink(file) unless @nodelete
    end
  end

  def test_multiple_files
    output = `#{@cmd} -o #{@tf_html} -f SHUFF_,INV_ --prefix #{@tf_bioworks_shuff} #{@tf_bioworks_esmall_xml}`
    assert_match(/<table.*<\/table>/m, IO.read(@tf_html), "has html table in it")
    assert_match(/1.*1.0000.*1.*1.0000.*0.*0.*15.*0.8667/m, IO.read(@tf_html), "has values")
    [@tf_html, @tf_png].each do |file|
      assert(File.exist?(file), "file #{file} exists")
      File.unlink(file) unless @nodelete
    end
  end

  def test_area_under_curve
    file = @tfiles + 'ppv_area.txt'
    `#{@cmd} -o #{file} -a -f SHUFF_ --prefix #{@tf_bioworks_shuff}`
    assert(File.exist?(file), "file #{file} exists")
    output = IO.read(file)
    assert_match(/Prec.*7.39206/, output, "consistency check")
    File.unlink file
     
    outfile = File.join(File.dirname(__FILE__), 'other.html')
    `#{@cmd} -o #{outfile} -f SHUFF_ --prefix #{@tf_bioworks_shuff}`
    File.unlink outfile
    File.unlink File.join(File.dirname(__FILE__),'other.png')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mspire-0.2.4 test/tc_precision.rb
mspire-0.2.2 test/tc_precision.rb