Sha256: 8e4918520eca66c65ce4ef95c27392efc3d6330119de09b1cb8b7fa88bc2dc7b

Contents?: true

Size: 1.94 KB

Versions: 45

Compression:

Stored size: 1.94 KB

Contents

require 'rbbt'
require 'rbbt/tsv'
require 'rbbt/resource'

module TFacts
  extend Resource
  self.subdir = "share/databases/TF"

  TFacts.claim TFacts.source["Catalogues.xls"], :url, "http://www.tfacts.org/TFactS-new/TFactS-v2/tfacts/data/Catalogues.xls"

  TFacts.claim TFacts.targets, :proc do
    require 'spreadsheet'
    book = Spreadsheet.open TFacts.source["Catalogues.xls"].produce.find
    sheet = book.worksheet 0

    tsv = TSV.setup({}, :key_field => "Associated Gene Name", :fields => ["Transcription Factor Associated Gene Name"], :namespace => "Hsa", :type => :flat)
    sheet.each do |row|
      target, tf = row.values_at 0, 1
      tsv[target] ||= []
      tsv[target] << tf
    end

    tsv.to_s
  end

  TFacts.claim TFacts.targets_signed, :proc do
    require 'spreadsheet'
    book = Spreadsheet.open TFacts.source["Catalogues.xls"].produce.find
    sheet = book.worksheet 0

    tsv = TSV.setup({}, :key_field => "Associated Gene Name", :fields => ["Transcription Factor Associated Gene Name", "Sign"], :namespace => "Hsa", :type => :double)
    sheet.each do |row|
      target, tf, sign = row.values_at 0, 1, 2
      tsv[target] ||= [[],[]]
      tsv[target][0] << tf
      tsv[target][1] << sign
    end

    tsv.to_s
  end

  TFacts.claim TFacts.regulators, :proc do
    TFacts.targets.tsv.reorder("Transcription Factor Associated Gene Name").to_s
  end

end

if defined? Entity and defined? Gene and Entity === Gene

  module Gene
    property :is_transcription_factor? => :array2single do
      tfs = TFacts.targets.keys
      self.name.collect{|gene| tfs.include? gene}
    end

    property :transcription_regulators => :array2single do
      Gene.setup(TFacts.regulators.tsv(:persist => true).values_at(*self.name), "Associated Gene Name", self.organism)
    end

    property :transcription_targets => :array2single do
      Gene.setup(TFacts.targets.tsv(:persist => true).values_at(*self.name), "Associated Gene Name", self.organism)
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
rbbt-sources-3.1.9 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.8 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.7 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.5 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.4 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.3 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.2 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.1 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.1.0 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.37 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.36 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.35 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.34 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.33 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.32 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.31 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.30 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.29 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.28 lib/rbbt/sources/tfacts.rb
rbbt-sources-3.0.27 lib/rbbt/sources/tfacts.rb