Module: GEO

Defined in:
lib/MARQ/GEO.rb

Overview

Work with GEO datasets

Defined Under Namespace

Modules: Process, Remote, SOFT

Constant Summary collapse

CACHE_DIR =
File.join(MARQ.cachedir,'GEO')
DATA_DIR =
File.join(MARQ.datadir, 'GEO')
PLATFORM_BLACKLIST =
%w(GPL4065)

Class Method Summary collapse

Class Method Details

.dataset_organism(dataset) ⇒ Object



618
619
620
# File 'lib/MARQ/GEO.rb', line 618

def self.dataset_organism(dataset)
  platform_organism(dataset_platform(dataset))
end

.dataset_path(dataset, platform = nil) ⇒ Object



567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/MARQ/GEO.rb', line 567

def self.dataset_path(dataset, platform = nil)
  if platform
    platforms = [platform]
  else
    platforms = self.platforms
  end

  platforms.each do |platform|
    platform_path = platform_path(platform)

    next if platform_path.nil?

    prefix = File.join(platform_path, dataset_type(dataset).to_s, dataset)
    
    if File.exists?(prefix + '.orders') || File.exists?(prefix + '.skip')
      return File.join(platform_path, dataset_type(dataset).to_s, dataset)
    end

  end

  return nil
end

.dataset_platform(dataset) ⇒ Object



607
608
609
610
611
612
# File 'lib/MARQ/GEO.rb', line 607

def self.dataset_platform(dataset)
  path = dataset_path(dataset)
  return nil if path.nil?
  path.match(/(GPL\d+)/)
  return $1
end

.dataset_type(dataset) ⇒ Object



552
553
554
555
556
557
558
559
# File 'lib/MARQ/GEO.rb', line 552

def self.dataset_type(dataset)
  case
  when dataset =~ /^GDS/
    :GDS
  when dataset =~ /^GSE/
    :GSE
  end
end

.platform_datasets(platform) ⇒ Object



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/MARQ/GEO.rb', line 590

def self.platform_datasets(platform)
  cross_platform = MARQ::Platform.is_cross_platform? platform
  
  path = platform_path(MARQ::Name.clean(platform))
  return [] if path.nil?

  datasets = Dir.glob(File.join(path, '*', '*.orders')).
    collect {|path| File.basename(path).sub(/\.orders$/,'')}

  if cross_platform
    datasets.select  {|dataset| MARQ::Dataset.is_cross_platform? dataset }.
             collect {|dataset| MARQ::Name.clean(dataset) }
  else
    datasets.select  {|dataset| ! MARQ::Dataset.is_cross_platform? dataset }
  end
end

.platform_organism(platform) ⇒ Object



614
615
616
# File 'lib/MARQ/GEO.rb', line 614

def self.platform_organism(platform)
  GEO::SOFT.GPL(platform)[:organism]
end

.platform_path(platform) ⇒ Object



561
562
563
564
565
# File 'lib/MARQ/GEO.rb', line 561

def self.platform_path(platform)
  path = File.join(DATA_DIR, platform)
  path = nil unless File.exists? File.join(path, 'codes')
  path
end

.platformsObject



547
548
549
# File 'lib/MARQ/GEO.rb', line 547

def self.platforms
  Dir.glob(File.join(DATA_DIR, "GPL*")).collect {|path| File.basename(path) }
end

.process_dataset(dataset, platform) ⇒ Object



626
627
628
629
630
631
632
633
634
635
# File 'lib/MARQ/GEO.rb', line 626

def self.process_dataset(dataset, platform)
  case dataset_type(dataset)
  when :GDS
    GEO::Process.GDS(dataset, platform)
  when :GSE
    info = YAML::load(File.open("series/#{ MARQ::Name.clean dataset }.yaml"))
    FileUtils.rm("platforms/#{ info[:platform] }.skip") if File.exist?  "platforms/#{ info[:platform] }.skip"
    GEO::Process.GSE(dataset, info)
  end
end

.process_platform(platform) ⇒ Object



622
623
624
# File 'lib/MARQ/GEO.rb', line 622

def self.process_platform(platform)
  GEO::Process.GPL(platform) unless platform =~ /_/
end