test/tc_srf.rb in mspire-0.1.7 vs test/tc_srf.rb in mspire-0.2.0

- old
+ new

@@ -48,57 +48,74 @@ :peaks => "4\n\216C\000`\305D\254\205\303C\000@;D\354\321\nD\000 \275D\232\243'D\000\020iE\350\2302D\000`\245D\f\3164D\000p@E\314JID\000\300\213D\264\002PD\000\260\016E\252\213[D\0000\eE\340NoD\000@\177D0\371xD\000@:Dd\f\205D\000\000yD\200\261\215D\000@\371D\210N\221D\000`\274D\034N\256D\000\020\032EN\372\266D\000\000\aD\356\223\322D\000\250\227E" } Out_files_first = { :num_hits => 10, - :charge => 1, :computer => "VELA", :date_time => "11/17/2006, 04:13 PM,", } Out_files_first_hit = { :mh => 1220.5128044522, - :deltacn => 0.0, + :deltacn => 0.071944423019886, ## this is the modified version :sp => 96.5815887451172, :xcorr => 1.08377742767334, :id => 224, :rsp => 13, :ions_matched => 8, :ions_total => 20, - :peptide => "K.LCPHLTLLPGR.F", + :sequence => "K.LCPHLTLLPGR.F", + :aaseq => "LCPHLTLLPGR", :reference => "gi|1786425|gb|AAC73335.1| damage-inducible protein P; putative tRNA synthetase", + :first_scan => 2, + :last_scan => 2, + :base_name => '7MIX_STD_110802_1', + :charge => 1, } Out_files_last = { :num_hits => 10, - :charge => 1, :computer => "VELA", :date_time => "11/17/2006, 04:25 PM," , } Out_files_last_first_hit = { :mh => 2605.9368784522, - :deltacn => 0.0, + :deltacn => 0.03921128064394, :sp => 76.7447052001953, :xcorr => 0.915680646896362, :id => 13562, :rsp => 4, :ions_matched => 10, :ions_total => 84, - :peptide => "K.HLEINPNHPIVETLRQKAETHK.N", + :sequence => "K.HLEINPNHPIVETLRQKAETHK.N", + :aaseq => "HLEINPNHPIVETLRQKAETHK", :reference => "gi|30149327|ref|XP_293672.2| similar to ebiP7687 [Homo sapiens]", + :first_scan => 7161, + :last_scan => 7161, + :base_name => '7MIX_STD_110802_1', + :deltamass => 2605.9368784522 - 2604.8360326775, + :ppm => ((1.0e6 * (2605.9368784522 - 2604.8360326775)) / 2604.8360326775).abs, + :charge => 3, } Out_files_last_last_hit = { :mh => 2604.9025174522, - :deltacn => 0.307604849338531, + :deltacn => 1.1, :sp => 26.1511478424072, :xcorr => 0.634012818336487, :id => 8105, :rsp => 165, :ions_matched => 6, :ions_total => 84, - :peptide => "R.EAFLVNSDLTLRAQLTEFRDHK.L", - :reference => "gi|5453830|ref|NP_006181.1| origin recognition complex, subunit 2-like; origin" + :sequence => "R.EAFLVNSDLTLRAQLTEFRDHK.L", + :aaseq => "EAFLVNSDLTLRAQLTEFRDHK", + :reference => "gi|5453830|ref|NP_006181.1| origin recognition complex, subunit 2-like; origin", + :first_scan => 7161, + :last_scan => 7161, + :base_name => '7MIX_STD_110802_1', + :deltamass => 2604.9025174522 - 2604.8360326775, + :ppm => ((1.0e6 * (2604.9025174522 - 2604.8360326775)) / 2604.8360326775).abs, + :charge => 3, } Sequest_params = { "add_F_Phenylalanine"=>"0.0000", "add_O_Ornithine"=>"0.0000", "add_Y_Tyrosine"=>"0.0000", @@ -161,53 +178,82 @@ "mass_type_fragment"=>"0" } end +tfiles = File.dirname(__FILE__) + '/tfiles/' +tfiles_l = File.dirname(__FILE__) + '/tfiles_large/' +tf_srf = tfiles_l + "7MIX_STD_110802_1.srf" +tf_srf_inv = tfiles_l + "7MIX_STD_110802_1_INV.srf" +if File.exist? tfiles_l + start = Time.now + $group = SRFGroup.new([tf_srf, tf_srf_inv]) + $srf = $group.srfs.first + puts "Time to read and compile two SRF: #{Time.now - start} secs" +end + + class TestSRF < Test::Unit::TestCase include ToMatch def initialize(arg) super(arg) @tfiles = File.dirname(__FILE__) + '/tfiles/' @tfiles_l = File.dirname(__FILE__) + '/tfiles_large/' - @tf_srf = @tfiles_l + "7MIX_STD_110802_1.srf" + @srg_file = @tfiles + "tmp_bioworks.srg" + + @srf = $srf + @group = $group + end def test_basic - start = Time.now - obj = SRF.new(@tf_srf) - puts "TOOK: #{Time.now - start} secs" - ## Verify that we have everything and it is as we expect (not exhaustive) - head = obj.header - dtgen = head.dta_gen - ## HEADER - hash_match(Header, head) - hash_match(Dta_gen, dtgen) - ## DTA_FILES - hash_match(Dta_files_first, obj.dta_files.first) - hash_match(Dta_files_last, obj.dta_files.last) - ## OUT_FILES - hash_match(Out_files_first, obj.out_files.first) - hash_match(Out_files_first_hit, obj.out_files.first.hits.first) - hash_match(Out_files_last_first_hit, obj.out_files.last.hits.first) - hash_match(Out_files_last_last_hit, obj.out_files.last.hits.last) - ## SEQUEST_PARAMS - hash_match(Sequest_params, obj.params) - ## INDEX - assert_equal([7161, 7161, 3], obj.index.last) - assert_equal([2, 2, 1], obj.index.first) + if File.exist? @tfiles_l + ## Verify that we have everything and it is as we expect (not exhaustive) + head = @srf.header + dtgen = head.dta_gen + ## HEADER + hash_match(Header, head) + hash_match(Dta_gen, dtgen) + ## DTA_FILES + hash_match(Dta_files_first, @srf.dta_files.first) + hash_match(Dta_files_last, @srf.dta_files.last) + ## OUT_FILES + hash_match(Out_files_first, @srf.out_files.first) + hash_match(Out_files_first_hit, @srf.out_files.first.hits.first) + hash_match(Out_files_last_first_hit, @srf.out_files.last.hits.first) + hash_match(Out_files_last_last_hit, @srf.out_files.last.hits.last) + ## SEQUEST_PARAMS + hash_match(Sequest_params, @srf.params) + ## INDEX + assert_equal([7161, 7161, 3], @srf.index.last) + assert_equal([2, 2, 1], @srf.index.first) - assert_equal(obj.index.size, obj.dta_files.size) - assert_equal(obj.out_files.size, obj.dta_files.size) + assert_equal(@srf.index.size, @srf.dta_files.size) + assert_equal(@srf.out_files.size, @srf.dta_files.size) + else + assert_nil( puts("--SKIPPING TEST-- (missing dir: #{@tfiles_l})") ) + end end - def hash_match(hash, obj) + def test_srg + if File.exist? @tfiles_l + @group.to_srg(@srg_file) + assert(File.exist?(@srg_file), "file exists: " + @srg_file ) + else + assert_nil( puts("--SKIPPING TEST-- (missing dir: #{@tfiles_l})") ) + end + end + + ## treats reference special + def hash_match(hash, srf) hash.each do |k,v| if v.is_a? Float delta = v/100000 - assert_in_delta( obj.send(k.to_sym), v, delta, "param: #{k}") + assert_in_delta(v, srf.send(k.to_sym), delta, "param: #{k}") + elsif k == :reference + assert_equal(v[0,38], srf.prots.first.reference) else - assert_equal(obj.send(k.to_sym), v, "param: #{k}") + assert_equal(v, srf.send(k.to_sym), "param: #{k}") end end end end