require File.expand_path( File.dirname(__FILE__) + '/../spec_helper' ) require 'spec_id/srf' SpecHelperHeaderHash = { 'SQTGenerator' => 'mspire', 'SQTGeneratorVersion' => String, 'Database' => 'C:\\Xcalibur\\database\\ecoli_K12_ncbi_20060321.fasta', 'FragmentMasses' => 'AVG', 'PrecursorMasses' => 'AVG', 'StartTime' => nil, 'Alg-MSModel' => 'LCQ Deca XP', 'Alg-PreMassUnits' => 'amu', 'DBLocusCount' => '4237', 'Alg-FragMassTol' => '1.0000', 'Alg-PreMassTol' => '1.4000', 'Alg-IonSeries' => '0 1 1 0.0 1.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0', 'Alg-Enzyme' => 'Trypsin(KR/P) (2)', 'Comment' => ['Created from Bioworks .srf file'], 'StaticMod' => ['C=160.1901','Cterm=10.1230','E=161.4455'], 'DynamicMod' => ['STY*=+79.97990', 'M#=+14.02660'], } SpecHelperOtherLines =< 10).should be_true header_hash_match(header_lines, SpecHelperHeaderHash).should be_true other_lines = lines.grep(/^[^H]/) other_lines[0,4].join('').should == SpecHelperOtherLines other_lines[-3,3].join('').should == SpecHelperOtherLinesEnd del(@output) end it 'warns if the db path is incorrect and we want to update db info' do # requires some knowledge of how the database file is extracted # internally wacky_path = '/not/a/real/path/wacky.fasta' @srf.header.db_filename = wacky_path my_error_string = '' StringIO.open(my_error_string, 'w') do |strio| $stderr = strio @srf.to_sqt(@output, :db_info => true) end my_error_string.should include(wacky_path) @srf.header.db_filename = @original_db_filename $stderr = STDERR @output.should exist IO.readlines(@output).size.should == 80910 del(@output) end it 'can get db info with correct path' do @srf.to_sqt(@output, :db_info => true, :new_db_path => Tfiles_l + '/opd1_2runs_2mods/sequest') @output.should exist lines = IO.readlines(@output) has_md5 = lines.any? do |line| line =~ /DBMD5Sum\s+202b1d95e91f2da30191174a7f13a04e/ end has_md5.should be_true has_seq_len = lines.any? do |line| # frozen line =~ /DBSeqLength\s+1342842/ end has_seq_len.should be_true lines.size.should == 80912 del(@output) end it 'can update the Database' do @srf.to_sqt(@output, :new_db_path => Tfiles_l + '/opd1_2runs_2mods/sequest', :update_db_path => true) regexp = Regexp.new("Database\t/.*/opd1_2runs_2mods/sequest/ecoli_K12_ncbi_20060321.fasta") updated_db = IO.readlines(@output).any? do |line| line =~ regexp end updated_db.should be_true del(@output) end end end