test/rbbt/knowledge_base/test_registry.rb in rbbt-util-5.14.34 vs test/rbbt/knowledge_base/test_registry.rb in rbbt-util-5.14.35
- old
+ new
@@ -27,10 +27,12 @@
KNOWLEDGE_BASE = KnowledgeBase.new '/tmp/kb.foo2'
KNOWLEDGE_BASE.register :effects, EFFECT_TSV, EFFECT_OPTIONS.dup
+ KNOWLEDGE_BASE.register :pina, datafile_test('pina'), :source => "UniProt/SwissProt Accession", :target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession", :undirected => true
+
def test_database
assert_equal "Associated Gene Name", KNOWLEDGE_BASE.get_database(:effects, :source_format => "Associated Gene Name").key_field
end
def test_index
@@ -39,14 +41,41 @@
def test_index_persist
assert KNOWLEDGE_BASE.get_index(:effects, :source_format => "Associated Gene Name", :target_format => "Ensembl Gene ID", :persist => true).include? "MDM2~ENSG00000141510"
end
-
def test_index_flat
require 'rbbt/sources/tfacts'
file = TFacts.regulators
KNOWLEDGE_BASE.register :tfacts, file, :type => :flat, :source => "Transcription Factor Associated Gene Name=~Associated Gene Name", :merge => true
assert KNOWLEDGE_BASE.subset(:tfacts, :source => ["TP53"], :target => :all).length > 10
+ end
+
+ def test_pina
+ index = KNOWLEDGE_BASE.get_index(:pina, :persist => false, :source_format => "Associated Gene Name", :target_format => "Associated Gene Name")
+ assert index["TP53~ARID1A"]
+ assert index["ARID1A~TP53"]
+ assert_equal index["ARID1A~TP53"], index["TP53~ARID1A"]
+
+ index = KNOWLEDGE_BASE.get_index(:pina, :persist => false, :source_format => "Associated Gene Name", :target_format => "Associated Gene Name", :undirected => false)
+ count = 0
+ index.through do |k,values|
+ split_values = values.collect{|v| v.split ";;" }
+ count += 1 if Misc.zip_fields(split_values).uniq != Misc.zip_fields(split_values)
+ end
+
+ index = KNOWLEDGE_BASE.get_index(:pina, :persist => false, :source_format => "Associated Gene Name", :target_format => "Associated Gene Name", :undirected => true)
+ count2 = 0
+ index.through do |k,values|
+ split_values = values.collect{|v| v.split ";;" }
+ count2 += 1 if Misc.zip_fields(split_values).uniq != Misc.zip_fields(split_values)
+ end
+
+ assert_equal count, count2
+ end
+
+
+ def test_pina2
+ index = KNOWLEDGE_BASE.get_index(:pina, :persist => true, :source_format => "Ensembl Gene ID", :target_format => "Ensembl Gene ID", :undirected => true)
end
end