require 'test/unit' require File.dirname(File.expand_path(__FILE__)) + '/load_bin_path' class ProphProtSummaryTest < Test::Unit::TestCase NODELETE = false def initialize(arg) super(arg) @tfiles = File.dirname(__FILE__) + '/tfiles/' @tf_proph = @tfiles + "opd1/000_020-prot.xml" @tf_summary = @tfiles + "opd1/000_020-prot.summary.html" @tf_bioworks_small = @tfiles + 'bioworks_small.xml' @tf_bioworks_small_summary_html = @tfiles + 'bioworks_small.summary.html' @tf_proph_cat_inv = @tfiles + 'opd1/opd1_cat_inv_small-prot.xml' @tf_proph_cat_inv_summary_html = @tfiles + 'opd1/opd1_cat_inv_small-prot.summary.html' @tf_proph_cat_inv_summary_png = @tfiles + 'opd1/opd1_cat_inv_small-prot.summary.png' @tf_peptide_count = @tfiles + "peptide_counts.tmp.txt" @cmd = "ruby -I#{File.join(File.dirname(__FILE__), "..", "lib")} -S protein_summary.rb " end def test_usage assert_match(/usage:/, `#{@cmd}`) end def test_proph_basic print `#{@cmd} -c 5.0 #{@tf_proph}` assert(File.exist?(@tf_summary), "file #{@tf_summary} exists") string = IO.read(@tf_summary) assert_match(/gi\|16132176\|ref\|NP_418775\.1\|/, string) assert_match(/16132176/, string) File.unlink(@tf_summary) unless NODELETE end def test_bioworks_basic print `#{@cmd} #{@tf_bioworks_small}` assert(File.exist?(@tf_bioworks_small_summary_html), "file #{@tf_bioworks_small_summary_html} exists") File.unlink @tf_bioworks_small_summary_html unless NODELETE # @TODO: need to freeze the output here end def test_bioworks_with_fpr `#{@cmd} -f #{@tf_bioworks_small} #{@tf_bioworks_small} --fpr` assert_match('TP : 106', IO.read(@tf_bioworks_small_summary_html)) assert_match(/False Positive Rate.*: 0.500/, IO.read(@tf_bioworks_small_summary_html)) assert(File.exist?(@tf_bioworks_small_summary_html), "file #{@tf_bioworks_small_summary_html} exists") File.unlink @tf_bioworks_small_summary_html unless NODELETE end def test_proph_with_fpr #puts @cmd print `#{@cmd} #{@tf_proph_cat_inv} -f INV_ --fpr` File.unlink @tf_proph_cat_inv_summary_html unless NODELETE File.unlink @tf_proph_cat_inv_summary_png unless NODELETE end def test_peptide_count print `#{@cmd} -c 5.0 #{@tf_proph} --peptide_count #{@tf_peptide_count}` assert(File.exist?(@tf_peptide_count), "file #{@tf_peptide_count} exists") file = IO.read(@tf_peptide_count) assert_match("gi|16132176|ref|NP_418775.1|\t2", file) assert_match("gi|16131996|ref|NP_418595.1|\t1", file) assert_match("gi|16131692|ref|NP_418288.1|\t4", file) File.unlink @tf_peptide_count unless NODELETE end end