Sha256: 16e6a29d2ed3d33e9d8c6bc4f0dad09b261e68893c2a4217a8e24be9b8413aa8

Contents?: true

Size: 1.32 KB

Versions: 542

Compression:

Stored size: 1.32 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '../../../test_helper')
require 'rbbt/util/tmpfile'
require 'test/unit'
require 'rbbt/knowledge_base'
require 'rbbt/knowledge_base/query'

class TestKnowledgeBaseQuery < Test::Unit::TestCase

  EFFECT =StringIO.new <<-END
#: :sep=" "#:type=:double
#SG TG Effect
MDM2 TP53 inhibition
TP53 NFKB1|GLI1 activation|activation true|true
  END

  EFFECT_OPTIONS = {
    :source => "SG=~Associated Gene Name=>Ensembl Gene ID",
    :target => "TG=~Associated Gene Name=>Ensembl Gene ID",
    :persist => false,
    :identifiers => datafile_test('identifiers'),
    :undirected => true,
    :namespace => "Hsa"
  }

  EFFECT_TSV = TSV.open EFFECT, EFFECT_OPTIONS.dup 

  KNOWLEDGE_BASE = KnowledgeBase.new '/tmp/kb.foo2', "Hsa"
  KNOWLEDGE_BASE.format = {"Gene" => "Ensembl Gene ID"}

  KNOWLEDGE_BASE.register :effects, EFFECT_TSV, EFFECT_OPTIONS.dup

  def test_subset_all_persist
    Misc.benchmark(1000) do
      assert_equal 6, KNOWLEDGE_BASE.subset(:effects, :all).length

      assert_equal 4, KNOWLEDGE_BASE.subset(:effects, :all).target_entity.uniq.length
      assert_equal %w(Effect), KNOWLEDGE_BASE.subset(:effects, :all).info.first.keys 
    end
  end

  def test_subset_all_persist_format
    assert KNOWLEDGE_BASE.subset(:effects, :all).target_entity.reject{|e| e =~ /^ENS/}.empty?
  end

end

Version data entries

542 entries across 542 versions & 1 rubygems

Version Path
rbbt-util-5.27.1 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.27.0 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.171 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.170 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.169 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.168 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.167 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.166 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.164 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.163 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.162 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.161 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.160 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.159 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.158 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.157 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.156 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.155 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.154 test/rbbt/knowledge_base/test_query.rb
rbbt-util-5.26.153 test/rbbt/knowledge_base/test_query.rb