File: test_soft.rb

package info (click to toggle)
ruby-bio 2.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,108 kB
  • sloc: ruby: 68,331; perl: 13; makefile: 11; sh: 1
file content (139 lines) | stat: -rw-r--r-- 6,738 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#
# test/unit/bio/db/test_soft.rb - Unit test for Bio::SOFT
#
# Author::    Trevor Wennblom  <mailto:trevor@corevx.com>
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
# License::   The Ruby License
#
#  $Id:$
#

# loading helper routine for testing bioruby
require 'pathname'
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
                            'bioruby_test_helper.rb')).cleanpath.to_s

# libraries needed for the tests
require 'test/unit'
require 'bio/db/soft'

module Bio #:nodoc:
  class TestSOFT < Test::Unit::TestCase #:nodoc:
    
    def setup
      test_data_path = Pathname.new(File.join(BioRubyTestDataPath, 'soft')).cleanpath.to_s
      series_filename = File.join(test_data_path, 'GSE3457_family_partial.soft')
      dataset_filename = File.join(test_data_path, 'GDS100_partial.soft')

      @obj_series = Bio::SOFT.new( IO.readlines(series_filename))
      @obj_dataset = Bio::SOFT.new( IO.readlines(dataset_filename))
    end

    def test_series
      assert_equal( @obj_series.platform[:geo_accession], 'GPL2092')
      assert_equal( @obj_series.platform[:organism], 'Populus')
      assert_equal( @obj_series.platform[:contributor], ["Jingyi,,Li", "Olga,,Shevchenko", "Steve,H,Strauss", "Amy,M,Brunner"])
      assert_equal( @obj_series.platform[:data_row_count], '240')
      assert_equal( @obj_series.platform.keys.sort {|a,b| a.to_s <=> b.to_s}[0..2], [:contact_address, :contact_city, :contact_country])
      assert_equal( @obj_series.platform[:"contact_zip/postal_code"], '97331')
      assert_equal( @obj_series.platform[:table].header, ["ID", "GB_ACC", "SPOT_ID", "Function/Family", "ORGANISM", "SEQUENCE"])             
      assert_equal( @obj_series.platform[:table].header_description, {"ORGANISM"=>"sequence sources",
       "SEQUENCE"=>"oligo sequence used",
       "Function/Family"=>"gene functions and family",
       "ID"=>"",
       "SPOT_ID"=>"",
       "GB_ACC"=>"Gene bank accession number"}) 
      assert_equal( @obj_series.platform[:table].rows.size, 240)          
      assert_equal( @obj_series.platform[:table].rows[5], ["A039P68U",
       "AI163321",
       "",
       "TF, flowering protein CONSTANS",
       "P. tremula x P. tremuloides",
       "AGAAAATTCGATATACTGTCCGTAAAGAGGTAGCACTTAGAATGCAACGGAATAAAGGGCAGTTCACCTC"])            
      assert_equal( @obj_series.platform[:table].rows[5][4], 'P. tremula x P. tremuloides')         
      assert_equal( @obj_series.platform[:table].rows[5][:organism], 'P. tremula x P. tremuloides') 
      assert_equal( @obj_series.platform[:table].rows[5]['ORGANISM'], 'P. tremula x P. tremuloides')
      
      assert_equal( @obj_series.series[:geo_accession], 'GSE3457')           
      assert_equal( @obj_series.series[:contributor], ["Jingyi,,Li",
       "Olga,,Shevchenko",
       "Ove,,Nilsson",
       "Steve,H,Strauss",
       "Amy,M,Brunner"])             
      assert_equal( @obj_series.series[:platform_id], 'GPL2092')             
      assert_equal( @obj_series.series[:sample_id].size, 74)          
      assert_equal( @obj_series.series[:sample_id][0..4], ["GSM77557", "GSM77558", "GSM77559", "GSM77560", "GSM77561"])         
                                                                 
      assert_equal( @obj_series.database[:name], 'Gene Expression Omnibus (GEO)')                  
      assert_equal( @obj_series.database[:ref], 'Nucleic Acids Res. 2005 Jan 1;33 Database Issue:D562-6')                   
      assert_equal( @obj_series.database[:institute], 'NCBI NLM NIH')             
                                                                 
      assert_equal( @obj_series.samples.size, 2)                     
      assert_equal( @obj_series.samples[:GSM77557][:series_id], 'GSE3457')   
      assert_equal( @obj_series.samples['GSM77557'][:series_id], 'GSE3457')  
      assert_equal( @obj_series.samples[:GSM77557][:platform_id], 'GPL2092') 
      assert_equal( @obj_series.samples[:GSM77557][:type], 'RNA')        
      assert_equal( @obj_series.samples[:GSM77557][:title], 'fb6a1')       
      assert_equal( @obj_series.samples[:GSM77557][:table].header, ["ID_REF", "VALUE"])
      assert_equal( @obj_series.samples[:GSM77557][:table].header_description, {"ID_REF"=>"", "VALUE"=>"normalized signal intensities"})
      assert_equal( @obj_series.samples[:GSM77557][:table].rows.size, 217)
      assert_equal( @obj_series.samples[:GSM77557][:table].rows[5], ["A039P68U", "5.36"])  
      assert_equal( @obj_series.samples[:GSM77557][:table].rows[5][0], 'A039P68U')        
      assert_equal( @obj_series.samples[:GSM77557][:table].rows[5][:id_ref], 'A039P68U')  
      assert_equal( @obj_series.samples[:GSM77557][:table].rows[5]['ID_REF'], 'A039P68U')
    end
    
    def test_dataset
      assert_equal( @obj_dataset.database[:name], 'Gene Expression Omnibus (GEO)')

      assert_equal( @obj_dataset.database[:ref], 'Nucleic Acids Res. 2005 Jan 1;33 Database Issue:D562-6')
      assert_equal( @obj_dataset.database[:institute], 'NCBI NLM NIH')

      assert_equal( @obj_dataset.subsets.size, 8)
      assert_equal( @obj_dataset.subsets.keys.sort, ["GDS100_1",
       "GDS100_2",
       "GDS100_3",
       "GDS100_4",
       "GDS100_5",
       "GDS100_6",
       "GDS100_7",
       "GDS100_8"])
      assert_equal( @obj_dataset.subsets[:GDS100_7],  {:sample_id=>"GSM548,GSM543",
       :dataset_id=>"GDS100",
       :description=>"60 minute",
       :type=>"time"})
      assert_equal( @obj_dataset.subsets['GDS100_7'][:sample_id], 'GSM548,GSM543')
      assert_equal( @obj_dataset.subsets[:GDS100_7][:sample_id], 'GSM548,GSM543')
      assert_equal( @obj_dataset.subsets[:GDS100_7][:dataset_id], 'GDS100')
                                                                 
      assert_equal( @obj_dataset.dataset[:order], 'none')
      assert_equal( @obj_dataset.dataset[:sample_organism], 'Escherichia coli')
      assert_equal( @obj_dataset.dataset[:table].header, ["ID_REF",
       "IDENTIFIER",
       "GSM549",
       "GSM542",
       "GSM543",
       "GSM547",
       "GSM544",
       "GSM545",
       "GSM546",
       "GSM548"])
      assert_equal( @obj_dataset.dataset[:table].rows.size, 15)
      assert_equal( @obj_dataset.dataset[:table].rows[5], ["6",
       "EMPTY",
       "0.097",
       "0.217",
       "0.242",
       "0.067",
       "0.104",
       "0.162",
       "0.104",
       "0.154"])
      assert_equal( @obj_dataset.dataset[:table].rows[5][4], '0.242')
      assert_equal( @obj_dataset.dataset[:table].rows[5][:gsm549], '0.097')
      assert_equal( @obj_dataset.dataset[:table].rows[5][:GSM549], '0.097')
      assert_equal( @obj_dataset.dataset[:table].rows[5]['GSM549'], '0.097')
    end
  end

end