Sha256: e7f16cba82e2ba060f121b8adc5477a3228aaeee74a69412e61b4219fc46cb7e

Contents?: true

Size: 1.62 KB

Versions: 66

Compression:

Stored size: 1.62 KB

Contents

require 'rbbt-util'
require 'rbbt/resource'
require 'rbbt/sources/organism'

module MSigDB
  extend Resource
  self.subdir = 'share/databases/MSigDB'

  def self.organism(org="Hsa")
    Organism.default_code(org)
  end

  #self.search_paths = {}
  #self.search_paths[:default] = :lib

  MSigDB.claim MSigDB['.source/all_sets.zip'], :proc do |filename|
    raise "Download the 'ZIPed file set' from http://software.broadinstitute.org/gsea/downloads.jsp into #{filename}"
  end

  MSigDB.claim MSigDB.all_sets, :proc do |dirname|
    zip_file = MSigDB['.source/all_sets.zip'].produce.find
    TmpFile.with_dir do |tmpdir|
      Misc.unzip_in_dir(zip_file, tmpdir)
      Path.setup(tmpdir)
      tmpdir.glob('**/*symbols.gmt').each do |file|
        name_parts = File.basename(file).split(".")
        base_name = name_parts[0..-5] * "_"
        dumper = TSV::Dumper.new :key_field => "MSigDB Geneset ID", :fields => ["Associated Gene Name"], :namespace => MSigDB.organism, :type => :flat
        dumper.init
        io = TSV.traverse file, :type => :array, :into => dumper do |line|
          name, url, *genes = line.split("\t")
          [name, genes]
        end
        Open.write(dirname[base_name], io.stream)
      end
    end
  end
end

if defined? Entity

  module MSigDBGeneSet
    extend Entity
    self.format= "MSigDB Geneset ID"

    property :name => :single2array do
      self.downcase.gsub("_",' ')
    end

    property :genes => :single2array do
      @@pathway_genes ||= MSigDB.all_sets.msigdb.tsv :persist => true
      genes = @@pathway_genes[self]
      Gene.setup(genes, "Associated Gene Name", MSigDB.organism).ensembl
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
rbbt-sources-3.4.2 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.4.1 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.3.0 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.16 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.15 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.14 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.13 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.12 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.11 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.10 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.9 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.8 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.6 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.4 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.3 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.2 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.1 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.2.0 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.1.52 lib/rbbt/sources/MSigDB.rb
rbbt-sources-3.1.51 lib/rbbt/sources/MSigDB.rb