require File.expand_path( File.dirname(__FILE__) + '/../spec_helper' ) # contains shared behavior that we need. require File.expand_path( File.dirname(__FILE__) + '/../transmem_spec_shared' ) require 'transmem/toppred' require 'yaml' describe TopPred::Index do before(:all) do @toppred_file = Tfiles + '/toppred.small.out' @obj = TopPred::Index.new(@toppred_file) @test_hash = {"YAL001C"=>0, "YAL011W"=>0, "YAL009W"=>2, "YAL010C"=>1, "YAL008W"=>3, "YAL007C"=>2, "YAL004W"=>0, "YAL005C"=>1, "YAL003W"=>0, "YAL002W"=>3, "YAL013W"=>0, "YAL014C"=>1, "YAL012W"=>1} @ref_to_key= { 'gi|16127905|ref|NP_414542.1| thr operon leader peptide [Escherichia coli K12]' => 'gi_16127905_ref_NP_414542_1_', 'SWN:PWP1_HUMAN PERIODIC TRYPTOPHAN PROTEIN 1 HOMOLOG' => 'SWN_PWP1_HUMAN', 'MY:B|/-"[super]"duper!@#$%^&*(wil) and other stuff' => 'MY_B_____super__duper_________wil_' } end it_should_behave_like 'a transmem index' end describe "a toppred parser", :shared => true do it 'parses a toppred file into a hash structure' do @file_to_hash.exist_as_a_file?.should be_true hash = @class.default_index(@file_to_hash) hash.should == @structure_to_create end end describe "TopPred parsing a text file" do before(:all) do @class = TopPred @file_to_hash = Tfiles + '/toppred.small.out' @structure_to_create = YAML.load(TopPredSupportingFile::MY_YAML1) @structure_to_create.each {|id,hash| string_to_symbol(hash) } end it_should_behave_like 'a toppred parser' end describe "TopPred parsing an xml file" do before(:all) do @class = TopPred @file_to_hash = Tfiles + '/toppred.xml.out' @structure_to_create = YAML.load(TopPredSupportingFile::MY_YAML2) @structure_to_create.each {|id,hash| string_to_symbol(hash) } end it_should_behave_like 'a toppred parser' end describe TopPred::Index do before(:all) do toppred_file = Tfiles + '/toppred.xml.out' @obj = TopPred::Index.new(toppred_file) @tm_test = { :mykey => 'SWN_K1CL_HUMAN', :seqs => %w(GFG VGSGYGGSAFGFG GGGSL), :exps => { :number => [2.0, 7.0, 3.0], :fraction => [2.0/3, 7.0/13, 3.0/5 ], } } end it_should_behave_like "a calculator of transmembrane overlap" end module TopPredSupportingFile MY_YAML1 = <