Module: MARQ::Dataset
- Defined in:
- lib/MARQ/main.rb
Class Method Summary collapse
- .broken?(dataset) ⇒ Boolean
- .codes(dataset) ⇒ Object
- .codes_for(dataset, type, experiment) ⇒ Object
- .exists?(dataset) ⇒ Boolean
- .experiments(dataset) ⇒ Object
- .has_cross_platform?(dataset) ⇒ Boolean
- .info(name) ⇒ Object
- .is_cross_platform?(dataset) ⇒ Boolean
- .is_GEO?(dataset) ⇒ Boolean
- .logratios(dataset) ⇒ Object
- .orders(dataset) ⇒ Object
- .organism(dataset) ⇒ Object
- .path(platform) ⇒ Object
- .platform(dataset) ⇒ Object
- .process(dataset, platform = nil) ⇒ Object
- .pvalues(dataset) ⇒ Object
- .read_file(dataset, ext) ⇒ Object
- .read_values(dataset, file, integer = false) ⇒ Object
- .read_values_t(dataset, file) ⇒ Object
- .t(dataset) ⇒ Object
Class Method Details
.broken?(dataset) ⇒ Boolean
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/MARQ/main.rb', line 121 def self.broken?(dataset) path = path(dataset) return false if path.nil? if File.exists?(path + '.skip') return true else return false end end |
.codes(dataset) ⇒ Object
214 215 216 |
# File 'lib/MARQ/main.rb', line 214 def self.codes(dataset) read_file(dataset, 'codes').split(/\n/) end |
.codes_for(dataset, type, experiment) ⇒ Object
234 235 236 237 238 |
# File 'lib/MARQ/main.rb', line 234 def self.codes_for(dataset, type, experiment) codes = codes(dataset) values = send(type, dataset)[experiment] Hash[*codes.zip(values).reject{|p| p.last.nil? }.flatten] end |
.exists?(dataset) ⇒ Boolean
112 113 114 115 116 117 118 119 |
# File 'lib/MARQ/main.rb', line 112 def self.exists?(dataset) path = path(dataset) if path.nil? return false else return File.exists?(path + '.orders') end end |
.experiments(dataset) ⇒ Object
210 211 212 |
# File 'lib/MARQ/main.rb', line 210 def self.experiments(dataset) read_file(dataset, 'experiments').split(/\n/).collect{|exp| exp.strip } end |
.has_cross_platform?(dataset) ⇒ Boolean
137 138 139 |
# File 'lib/MARQ/main.rb', line 137 def self.has_cross_platform?(dataset) File.exists?(path(dataset) + '_cross_platform.orders') end |
.info(name) ⇒ Object
141 142 143 144 145 146 147 148 149 |
# File 'lib/MARQ/main.rb', line 141 def self.info(name) begin title, description = Open.read(path(name) + '.description').split(/\n--\n/).values_at(0,1) {:title => title.strip, :description => description.strip} rescue Exception puts $!. {:title => "" , :description => "" } end end |
.is_cross_platform?(dataset) ⇒ Boolean
133 134 135 |
# File 'lib/MARQ/main.rb', line 133 def self.is_cross_platform?(dataset) MARQ::Name.is_cross_platform? dataset end |
.is_GEO?(dataset) ⇒ Boolean
100 101 102 |
# File 'lib/MARQ/main.rb', line 100 def self.is_GEO?(dataset) ! dataset.match(/^(?:GDS|GSE)/).nil? end |
.logratios(dataset) ⇒ Object
222 223 224 |
# File 'lib/MARQ/main.rb', line 222 def self.logratios(dataset) read_values(dataset, 'logratios') end |
.orders(dataset) ⇒ Object
218 219 220 |
# File 'lib/MARQ/main.rb', line 218 def self.orders(dataset) read_values(dataset, 'orders', true) end |
.organism(dataset) ⇒ Object
159 160 161 |
# File 'lib/MARQ/main.rb', line 159 def self.organism(dataset) MARQ::Platform.organism(platform(dataset)) end |
.path(platform) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/MARQ/main.rb', line 104 def self.path(platform) if is_GEO? platform GEO.dataset_path(platform) else CustomDS.dataset_path(platform) end end |
.platform(dataset) ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/MARQ/main.rb', line 151 def self.platform(dataset) if is_GEO? dataset GEO.dataset_platform(dataset) else CustomDS.dataset_platform(dataset) end end |
.process(dataset, platform = nil) ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/MARQ/main.rb', line 163 def self.process(dataset, platform = nil) if is_GEO? dataset GEO.process_dataset(dataset, platform) else CustomDS.process_dataset(dataset, platform) end end |
.pvalues(dataset) ⇒ Object
226 227 228 |
# File 'lib/MARQ/main.rb', line 226 def self.pvalues(dataset) read_values_t(dataset, 'pvalues') end |
.read_file(dataset, ext) ⇒ Object
171 172 173 |
# File 'lib/MARQ/main.rb', line 171 def self.read_file(dataset, ext) Open.read(path(dataset) + '.' + ext) end |
.read_values(dataset, file, integer = false) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/MARQ/main.rb', line 175 def self.read_values(dataset, file, integer = false) result = {} experiments = experiments(dataset) experiments.each{|experiment| result[experiment] = [] } read_file(dataset, file).split(/\n/).each do |line| values = line.chomp.split(/\t/) if integer values.each_with_index{|value, i| result[experiments[i]] << (value == 'NA' ? nil : value.to_i)} else values.each_with_index{|value, i| result[experiments[i]] << (value == 'NA' ? nil : value.to_f)} end end result end |
.read_values_t(dataset, file) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/MARQ/main.rb', line 192 def self.read_values_t(dataset, file) experiments = experiments(dataset).reject{|experiment| MARQ::Name.is_ratio? experiment } return {} if experiments.empty? result = {} experiments.each{|experiment| result[experiment] = [] } read_file(dataset, file).split(/\n/).each do |line| values = line.chomp.split(/\t/) values.each_with_index{|value, i| result[experiments[i]] << (value == 'NA' ? nil : value.to_f) } end result end |
.t(dataset) ⇒ Object
230 231 232 |
# File 'lib/MARQ/main.rb', line 230 def self.t(dataset) read_values_t(dataset, 't') end |