Module: CustomDS
- Defined in:
- lib/MARQ/CustomDS.rb
Constant Summary collapse
- @@r =
nil
Class Method Summary collapse
- .clean(dataset) ⇒ Object
- .customdir ⇒ Object
- .datasets(org) ⇒ Object
- .has_cross_platform?(dataset) ⇒ Boolean
- .info(dataset) ⇒ Object
- .is_cross_platform?(dataset) ⇒ Boolean
- .organism(dataset) ⇒ Object
- .path(dataset) ⇒ Object
- .process(name) ⇒ Object
- .r ⇒ Object
Class Method Details
.clean(dataset) ⇒ Object
53 54 55 |
# File 'lib/MARQ/CustomDS.rb', line 53 def self.clean(dataset) dataset.sub(/_cross_platform/,'') end |
.customdir ⇒ Object
7 8 9 |
# File 'lib/MARQ/CustomDS.rb', line 7 def self.customdir File.join(MARQ.datadir,'CustomDS') end |
.datasets(org) ⇒ Object
61 62 63 |
# File 'lib/MARQ/CustomDS.rb', line 61 def self.datasets(org) Dir.glob(File.join(customdir, org) + '/*.orders').collect{|f| clean(File.basename(f.sub(/.orders/,'')))}.uniq end |
.has_cross_platform?(dataset) ⇒ Boolean
57 58 59 |
# File 'lib/MARQ/CustomDS.rb', line 57 def self.has_cross_platform?(dataset) Dir.glob(path(clean(dataset)) + '_cross_platform.orders').any? end |
.info(dataset) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/MARQ/CustomDS.rb', line 20 def self.info(dataset) begin text = Open.read(path(dataset) + '.description') if text =~ /(.*)\n--\n(.*)/ {:title => $1.strip, :description => $2.strip} elsif text.collect.length > 1 || text.length > 200 {:title => "", :description => text} else {:title => text, :description => ""} end rescue Exception puts $!. {:title => "" , :description => "" } end end |
.is_cross_platform?(dataset) ⇒ Boolean
49 50 51 |
# File 'lib/MARQ/CustomDS.rb', line 49 def self.is_cross_platform?(dataset) dataset.match(/_cross_platform/) end |
.organism(dataset) ⇒ Object
45 46 47 |
# File 'lib/MARQ/CustomDS.rb', line 45 def self.organism(dataset) path(dataset).match(/#{ customdir }\/(.*?)\//)[1] end |
.path(dataset) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/MARQ/CustomDS.rb', line 36 def self.path(dataset) files = Dir.glob(customdir + "/*/#{ dataset }.orders") if files.length == 1 files.first.sub(/.orders/,'') else Dir.glob(customdir + "/*/#{ dataset }").first end end |
.process(name) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/MARQ/CustomDS.rb', line 65 def self.process(name) puts "Processing #{ name }" org = organism(name) prefix = File.join(customdir, org, name) conditions = Dir.glob(prefix + '/*').collect{|f| File.basename(f)} - %w(values codes info description cross_platform) description = Open.read(File.join(prefix, 'description')) info = YAML.load(File.open(File.join(prefix, 'info'))) r.CustomDS_process(prefix, false, conditions, description, info["two_channel"], !info["log2"]) codes = Open.read(File.join(prefix,'codes')).collect{|l| l.chomp} cross_platform = ID.translate(org, codes) if cross_platform.length > codes.length / 4 Open.write(File.join(prefix,'cross_platform'),cross_platform.collect{|c| c || "NO MATCH"}.join("\n")) r.CustomDS_process(prefix, true, conditions, description, info["two_channel"], !info["log2"]) end end |