require 'test/unit'
require File.dirname(File.expand_path(__FILE__)) + '/load_bin_path'
class PrecisionTest < 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_ #{@tf_bioworks_shuff}`
puts output
assert_match(/
/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_ #{@tf_bioworks_shuff} #{@tf_bioworks_esmall_xml}`
assert_match(//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_ #{@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_ #{@tf_bioworks_shuff}`
File.unlink outfile
File.unlink File.join(File.dirname(__FILE__),'other.png')
end
end