rbbt-util 5.4.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/bin/rbbt_monitor.rb +8 -4
- data/lib/rbbt.rb +4 -11
- data/lib/rbbt/annotations.rb +4 -1
- data/lib/rbbt/association.rb +218 -157
- data/lib/rbbt/association/index.rb +92 -0
- data/lib/rbbt/association/item.rb +44 -0
- data/lib/rbbt/entity.rb +4 -0
- data/lib/rbbt/fix_width_table.rb +14 -9
- data/lib/rbbt/knowledge_base.rb +269 -0
- data/lib/rbbt/persist.rb +1 -1
- data/lib/rbbt/persist/tsv.rb +22 -2
- data/lib/rbbt/resource.rb +0 -1
- data/lib/rbbt/resource/path.rb +1 -1
- data/lib/rbbt/resource/util.rb +0 -1
- data/lib/rbbt/tsv.rb +15 -14
- data/lib/rbbt/tsv/accessor.rb +21 -16
- data/lib/rbbt/tsv/attach.rb +5 -5
- data/lib/rbbt/tsv/attach/util.rb +4 -2
- data/lib/rbbt/tsv/change_id.rb +67 -0
- data/lib/rbbt/tsv/index.rb +5 -3
- data/lib/rbbt/tsv/manipulate.rb +83 -37
- data/lib/rbbt/tsv/parser.rb +2 -1
- data/lib/rbbt/tsv/util.rb +2 -0
- data/lib/rbbt/util/cmd.rb +1 -2
- data/lib/rbbt/util/log.rb +42 -38
- data/lib/rbbt/util/misc.rb +134 -46
- data/lib/rbbt/util/open.rb +3 -17
- data/lib/rbbt/util/semaphore.rb +8 -2
- data/lib/rbbt/workflow.rb +31 -46
- data/lib/rbbt/workflow/accessor.rb +1 -1
- data/lib/rbbt/workflow/step.rb +5 -3
- data/share/rbbt_commands/workflow/server +1 -0
- data/share/rbbt_commands/workflow/task +12 -2
- data/test/rbbt/association/test_index.rb +36 -0
- data/test/rbbt/test_annotations.rb +5 -4
- data/test/rbbt/test_association.rb +40 -13
- data/test/rbbt/test_knowledge_base.rb +103 -0
- data/test/rbbt/test_workflow.rb +4 -2
- data/test/rbbt/tsv/test_change_id.rb +43 -0
- data/test/rbbt/tsv/test_index.rb +2 -1
- data/test/rbbt/tsv/test_manipulate.rb +51 -0
- data/test/rbbt/util/test_misc.rb +21 -1
- data/test/test_helper.rb +8 -4
- metadata +12 -86
data/lib/rbbt/util/semaphore.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'inline'
|
3
|
+
continue = true
|
4
|
+
rescue Exception
|
5
|
+
Log.warn "The RubyInline gem could not be loaded: semaphore synchronization will not work"
|
6
|
+
continue = false
|
7
|
+
end
|
2
8
|
|
3
9
|
module RbbtSemaphore
|
4
10
|
inline(:C) do |builder|
|
@@ -67,5 +73,5 @@ void post_semaphore(char* name){
|
|
67
73
|
pids.each do |pid| Process.waitpid pid end
|
68
74
|
end
|
69
75
|
end
|
70
|
-
end
|
76
|
+
end if continue
|
71
77
|
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rbbt/workflow/step'
|
|
4
4
|
require 'rbbt/workflow/accessor'
|
5
5
|
|
6
6
|
module Workflow
|
7
|
+
|
7
8
|
def self.resolve_locals(inputs)
|
8
9
|
inputs.each do |name, value|
|
9
10
|
if value =~ /^local:(.*?):(.*)/ or
|
@@ -33,66 +34,56 @@ module Workflow
|
|
33
34
|
eval "Object::#{wf_name} = RbbtRestClient.new '#{ url }', '#{wf_name}'"
|
34
35
|
end
|
35
36
|
|
37
|
+
def self.load_workflow_file(filename)
|
38
|
+
begin
|
39
|
+
$LOAD_PATH.unshift(File.join(File.dirname(File.expand_path(filename)), 'lib'))
|
40
|
+
require filename
|
41
|
+
Log.info "Workflow loaded from: #{ filename }"
|
42
|
+
return true
|
43
|
+
rescue Exception
|
44
|
+
Log.warn "Error loading workflow: #{ filename }"
|
45
|
+
raise $!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
36
49
|
def self.require_local_workflow(wf_name)
|
50
|
+
filename = nil
|
51
|
+
|
37
52
|
if Path === wf_name
|
38
53
|
case
|
39
|
-
|
40
54
|
# Points to workflow file
|
41
55
|
when ((File.exists?(wf_name.find) and not File.directory?(wf_name.find)) or File.exists?(wf_name.find + '.rb'))
|
42
|
-
|
43
|
-
require wf_name.find
|
44
|
-
Log.medium "Workflow loaded from file: #{ wf_name }"
|
45
|
-
return true
|
56
|
+
filename = wf_name.find
|
46
57
|
|
47
58
|
# Points to workflow dir
|
48
59
|
when (File.exists?(wf_name.find) and File.directory?(wf_name.find) and File.exists?(File.join(wf_name.find, 'workflow.rb')))
|
49
|
-
|
50
|
-
require File.join(wf_name.find, 'workflow.rb')
|
51
|
-
Log.medium "Workflow loaded from directory: #{ wf_name }"
|
52
|
-
return true
|
53
|
-
|
54
|
-
else
|
55
|
-
raise "Workflow path was not resolved: #{ wf_name } (#{wf_name.find})"
|
60
|
+
filename = wf_name['workflow.rb'].find
|
56
61
|
end
|
57
62
|
|
58
63
|
else
|
59
64
|
case
|
60
65
|
# Points to workflow file
|
61
66
|
when ((File.exists?(wf_name) and not File.directory?(wf_name)) or File.exists?(wf_name + '.rb') or File.exists?(wf_name))
|
62
|
-
|
63
|
-
wf_name = "./" << wf_name unless wf_name[0] == "/"
|
64
|
-
require wf_name
|
65
|
-
Log.medium "Workflow loaded from file: #{ wf_name }"
|
66
|
-
return true
|
67
|
-
|
67
|
+
filename = (wf_name =~ /\.?\//) ? wf_name : "./" << wf_name
|
68
68
|
when (defined?(Rbbt) and Rbbt.etc.workflow_dir.exists?)
|
69
69
|
dir = Rbbt.etc.workflow_dir.read.strip
|
70
70
|
dir = File.join(dir, wf_name)
|
71
|
-
|
72
|
-
require File.join(dir, 'workflow.rb')
|
73
|
-
Log.medium "Workflow #{wf_name} loaded from workflow_dir: #{ dir }"
|
74
|
-
return true
|
75
|
-
|
71
|
+
filename = File.join(dir, 'workflow.rb')
|
76
72
|
when defined?(Rbbt)
|
77
73
|
path = Rbbt.workflows[wf_name].find
|
78
|
-
|
79
|
-
require File.join(path, 'workflow.rb')
|
80
|
-
Log.medium "Workflow #{wf_name} loaded from Rbbt.workflows: #{ path }"
|
81
|
-
return true
|
82
|
-
|
74
|
+
filename = File.join(dir, 'workflow.rb')
|
83
75
|
else
|
84
76
|
path = File.join(ENV['HOME'], '.workflows', wf_name)
|
85
|
-
|
86
|
-
require File.join(path, 'workflow.rb')
|
87
|
-
Log.medium "Workflow #{wf_name} loaded from .workflows: #{ path }"
|
88
|
-
return true
|
77
|
+
filename = File.join(dir, 'workflow.rb')
|
89
78
|
end
|
90
79
|
end
|
91
80
|
|
92
|
-
|
81
|
+
return false if filename.nil? or not File.exists? filename
|
82
|
+
load_workflow_file filename
|
93
83
|
end
|
94
|
-
|
95
84
|
def self.require_workflow(wf_name)
|
85
|
+
|
86
|
+
# Already loaded
|
96
87
|
begin
|
97
88
|
Misc.string2const wf_name
|
98
89
|
Log.debug "Workflow #{ wf_name } already loaded"
|
@@ -100,9 +91,10 @@ module Workflow
|
|
100
91
|
rescue Exception
|
101
92
|
end
|
102
93
|
|
94
|
+
# Load remotely
|
103
95
|
if Rbbt.etc.remote_workflows.exists?
|
104
96
|
remote_workflows = Rbbt.etc.remote_workflows.yaml
|
105
|
-
if remote_workflows.include?
|
97
|
+
if Hash === remote_workflows and remote_workflows.include?(wf_name)
|
106
98
|
url = remote_workflows[wf_name]
|
107
99
|
require_remote_workflow(wf_name, url)
|
108
100
|
Log.debug "Workflow #{ wf_name } loaded remotely: #{ url }"
|
@@ -110,19 +102,12 @@ module Workflow
|
|
110
102
|
end
|
111
103
|
end
|
112
104
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
raise "Workflow not found: #{ wf_name }" if wf_name == Misc.snake_case(wf_name)
|
117
|
-
begin
|
118
|
-
require_local_workflow(Misc.snake_case(wf_name))
|
119
|
-
rescue Exception
|
120
|
-
Log.error("Workflow not found: #{ wf_name }")
|
121
|
-
raise $!
|
122
|
-
end
|
123
|
-
end
|
105
|
+
# Load locally
|
106
|
+
|
107
|
+
require_local_workflow(wf_name) || require_local_workflow(Misc.snake_case(wf_name)) || raise("Workflow not found or could not be loaded: #{ wf_name }")
|
124
108
|
end
|
125
109
|
|
110
|
+
|
126
111
|
attr_accessor :description
|
127
112
|
attr_accessor :libdir, :workdir
|
128
113
|
attr_accessor :helpers, :tasks
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -4,6 +4,8 @@ require 'rbbt/util/log'
|
|
4
4
|
require 'rbbt/util/semaphore'
|
5
5
|
require 'rbbt/workflow/accessor'
|
6
6
|
|
7
|
+
class ParameterException < Exception; end
|
8
|
+
|
7
9
|
class Step
|
8
10
|
attr_accessor :path, :task, :inputs, :dependencies, :bindings
|
9
11
|
attr_accessor :pid
|
@@ -176,10 +178,10 @@ class Step
|
|
176
178
|
rescue Step::Aborted
|
177
179
|
Log.debug("Forked process aborted: #{@path}")
|
178
180
|
log :aborted, "Aborted"
|
179
|
-
|
181
|
+
raise $!
|
180
182
|
rescue Exception
|
181
|
-
Log.debug("Exception caught on forked process: #{
|
182
|
-
|
183
|
+
Log.debug("Exception caught on forked process: #{@path}")
|
184
|
+
raise $!
|
183
185
|
end
|
184
186
|
|
185
187
|
begin
|
@@ -4,7 +4,9 @@ require 'rbbt/util/simpleopt'
|
|
4
4
|
require 'rbbt/workflow'
|
5
5
|
require 'rbbt/workflow/usage'
|
6
6
|
|
7
|
-
|
7
|
+
YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE and YAML::ENGINE.respond_to? :yamler
|
8
|
+
|
9
|
+
def usage(workflow = nil, task = nil, error = nil)
|
8
10
|
puts SOPT.doc
|
9
11
|
puts "## WORKFLOW"
|
10
12
|
puts
|
@@ -23,6 +25,10 @@ def usage(workflow = nil, task = nil)
|
|
23
25
|
puts workflow.workflow_description
|
24
26
|
puts
|
25
27
|
workflow.doc(task)
|
28
|
+
if error
|
29
|
+
puts
|
30
|
+
puts "Error: " << error
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
exit 0
|
@@ -104,7 +110,7 @@ options = SOPT.get <<EOF
|
|
104
110
|
-as--array_separator* Change the character that separates elements of Arrays, ',', '|', or '\\n' by default:
|
105
111
|
-cl--clean Clean the last step of the job so that it gets recomputed:
|
106
112
|
-rcl--recursive_clean Clean the last step and its dependencies to recompute the job completely:
|
107
|
-
-
|
113
|
+
-jn--jobname* Job name to use. The name 'Default' is used by default:
|
108
114
|
-pn--printname Print the name of the job and exit without starting it:
|
109
115
|
EOF
|
110
116
|
|
@@ -180,6 +186,7 @@ if recursive_clean and job.done?
|
|
180
186
|
end
|
181
187
|
|
182
188
|
# run
|
189
|
+
begin
|
183
190
|
if do_exec
|
184
191
|
res = job.exec
|
185
192
|
case
|
@@ -212,6 +219,9 @@ if options.delete(:printname)
|
|
212
219
|
else
|
213
220
|
Log.low "Job name: #{job.name}"
|
214
221
|
end
|
222
|
+
rescue ParameterException
|
223
|
+
usage(workflow, task, $!.message)
|
224
|
+
end
|
215
225
|
|
216
226
|
if Step === res
|
217
227
|
puts Open.read(res.path) if File.exists? res.path
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
require 'rbbt/workflow'
|
3
|
+
require 'rbbt/association'
|
4
|
+
require 'rbbt/association/index'
|
5
|
+
|
6
|
+
Workflow.require_workflow "Genomics"
|
7
|
+
require 'rbbt/entity/gene'
|
8
|
+
class TestAssociationIndex < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def test_subset
|
18
|
+
require 'rbbt/sources/pina'
|
19
|
+
require 'rbbt/sources/kegg'
|
20
|
+
tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013").ensembl
|
21
|
+
index = Association.index(Pina.protein_protein,
|
22
|
+
{:namespace => tp53.organism,
|
23
|
+
:target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession",
|
24
|
+
:format => "Ensembl Gene ID",
|
25
|
+
:undirected => true},
|
26
|
+
{:dir => '/tmp/test_association3', :update => false})
|
27
|
+
genes = tp53.pina_interactors.ensembl
|
28
|
+
genes << tp53
|
29
|
+
|
30
|
+
Misc.benchmark(10) do
|
31
|
+
index.subset_entities("Ensembl Gene ID" => genes).length
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal 204, index.subset_entities("Ensembl Gene ID" => genes).select{|m| m.partition("~")[0] == tp53}.uniq.length
|
35
|
+
end
|
36
|
+
end
|
@@ -91,10 +91,11 @@ class TestAnnotations < Test::Unit::TestCase
|
|
91
91
|
AnnotatedString.setup(str1, annotation_str1)
|
92
92
|
AnnotatedString.setup(str2, annotation_str2)
|
93
93
|
|
94
|
-
assert_equal
|
95
|
-
assert_equal
|
96
|
-
assert_equal
|
97
|
-
assert_equal annotation_str1, Annotated.tsv([str1, str2], :
|
94
|
+
assert_equal str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + ":0"]["literal"]
|
95
|
+
assert_equal annotation_str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + ":0"]["annotation_str"]
|
96
|
+
assert_equal str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + ":0"]["literal"]
|
97
|
+
assert_equal annotation_str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + ":0"]["annotation_str"]
|
98
|
+
assert_equal annotation_str1, Annotated.tsv([str1, str2], :annotation_str, :JSON).tap{|t| t.unnamed = false}[str1.id + ":0"]["annotation_str"]
|
98
99
|
end
|
99
100
|
|
100
101
|
def test_literal
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
require 'rbbt/workflow'
|
3
3
|
require 'rbbt/association'
|
4
|
+
require 'rbbt/knowledge_base'
|
4
5
|
require 'rbbt/entity'
|
5
6
|
require 'rbbt/util/tmpfile'
|
6
7
|
require 'test/unit'
|
@@ -22,55 +23,81 @@ class TestAssociations < Test::Unit::TestCase
|
|
22
23
|
|
23
24
|
FAssocs = ""
|
24
25
|
DAssocs = ""
|
26
|
+
|
25
27
|
def setup
|
26
28
|
FAssocs.replace TmpFile.tmp_file
|
27
29
|
DAssocs.replace TmpFile.tmp_file
|
28
30
|
Open.write(FAssocs, TEST_ASSOCIATIONS)
|
29
31
|
end
|
32
|
+
|
30
33
|
def teardown
|
31
34
|
FileUtils.rm FAssocs
|
32
35
|
FileUtils.rm_rf DAssocs
|
33
36
|
end
|
34
37
|
|
35
|
-
def
|
38
|
+
def _test_simple_open
|
36
39
|
database = Association.open(FAssocs, {}, :dir => DAssocs)
|
37
40
|
assert_equal ["C", "K"], database["c"]["Entity2"]
|
38
41
|
end
|
39
42
|
|
40
|
-
def
|
43
|
+
def _test_source_open
|
41
44
|
database = Association.open(FAssocs, {:source => "Entity2", :zipped => true}, :dir => DAssocs)
|
42
45
|
assert_equal ["c", "3", 'cc', "PTEN"], database["C"].flatten
|
43
46
|
assert_equal ["c", "4", 'kk', "PTEN"], database["K"].flatten
|
44
47
|
end
|
45
48
|
|
46
|
-
def
|
49
|
+
def _test_target_open
|
47
50
|
database = Association.open(FAssocs, {:source => "Entity2", :target => "Entity3", :zipped => true}, :dir => DAssocs)
|
48
51
|
assert_equal ["cc", "c", "3", "PTEN"], database["C"].flatten
|
49
52
|
assert_equal ["kk", "c", "4", "PTEN"], database["K"].flatten
|
50
53
|
end
|
51
54
|
|
52
|
-
def
|
55
|
+
def test_target_open
|
56
|
+
require 'rbbt/sources/pina'
|
57
|
+
|
58
|
+
database = Association.open(Pina.protein_protein,{
|
59
|
+
:undirected => false,
|
60
|
+
:target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession"}, :persist => false)
|
61
|
+
|
62
|
+
assert( ! database["Q13547"][0].include?("O15379"))
|
63
|
+
|
64
|
+
database = Association.open(Pina.protein_protein,{
|
65
|
+
:undirected => true,
|
66
|
+
:target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession"}, :persist => false)
|
67
|
+
|
68
|
+
assert database["O15379"][0].include? "Q13547"
|
69
|
+
|
70
|
+
assert database["Q13547"][0].include? "O15379"
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def _test_gene_open
|
53
75
|
database = Association.open(FAssocs, {:source => "Gene=~Associated Gene Name", :target => "Entity3", :zipped => true}, :dir => DAssocs)
|
54
76
|
assert_equal ["aa"], database["TP53"].first
|
55
77
|
end
|
56
78
|
|
57
|
-
def
|
79
|
+
def _test_gene_open_translate
|
58
80
|
tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013")
|
59
|
-
database = Association.open(FAssocs, {:source => "Gene=~Associated Gene Name", :
|
81
|
+
database = Association.open(FAssocs, {:source => "Gene=~Associated Gene Name", :source_format => "Ensembl Gene ID", :target => "Entity3", :zipped => true}, :dir => DAssocs)
|
60
82
|
assert_equal ["aa"], database[tp53.ensembl].first
|
61
83
|
end
|
62
84
|
|
63
|
-
def
|
85
|
+
def _test_gene_target_open_translate
|
64
86
|
tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013")
|
65
87
|
database = Association.open(FAssocs, {:target => "Gene=~Associated Gene Name=>Ensembl Gene ID", :source => "Entity3", :zipped => true}, :dir => DAssocs)
|
66
88
|
assert_equal [tp53.ensembl], database["aa"].first
|
67
89
|
end
|
68
90
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
91
|
+
def _test_ICGC
|
92
|
+
assoc = Association.open(Open.open('ftp://data.dcc.icgc.org/current/Chronic_Lymphocytic_Leukemia-ISC_MICINN-ES/simple_somatic_mutation.CLLE-ES.tsv.gz'),
|
93
|
+
{ :source => "gene_affected=~Ensembl Gene ID=>Associated Gene Name", :target => "icgc_donor_id=~Sample",
|
94
|
+
:fields => ['consequence_type'],
|
95
|
+
:namespace => 'Hsa/jan2013',
|
96
|
+
:merge => true, :header_hash=>''}, :persist => false)
|
97
|
+
|
98
|
+
assert_equal 9, assoc["SF3B1"]["Sample"].uniq.length
|
99
|
+
|
75
100
|
end
|
101
|
+
|
102
|
+
|
76
103
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rbbt/knowledge_base'
|
5
|
+
require 'rbbt/sources/pina'
|
6
|
+
|
7
|
+
require 'rbbt/workflow'
|
8
|
+
Workflow.require_workflow "Genomics"
|
9
|
+
require 'genomics_kb'
|
10
|
+
|
11
|
+
class TestKnowledgeBase < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
KnowledgeBase.knowledge_base_dir = Rbbt.tmp.knowledge_base_test.find
|
14
|
+
@kb = Genomics.knowledge_base
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_register
|
18
|
+
TmpFile.with_file do |dir|
|
19
|
+
kb = KnowledgeBase.new dir
|
20
|
+
|
21
|
+
kb.register :pina, Pina.protein_protein, :target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession"
|
22
|
+
assert_equal [Gene], kb.entity_types
|
23
|
+
assert kb.all_databases.include? :pina
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_format_Gene
|
28
|
+
TmpFile.with_file do |dir|
|
29
|
+
kb = KnowledgeBase.new dir, "Hsa/jan2013"
|
30
|
+
kb.format["Gene"] = "Ensembl Gene ID"
|
31
|
+
|
32
|
+
kb.register 'nature', NCI.nature_pathways, :merge => true, :target => "UniProt/SwissProt Accession", :key_field => 0
|
33
|
+
|
34
|
+
assert kb.get_database('nature', :persist => false).slice("Ensembl Gene ID").values.flatten.uniq.length > 10
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_fields
|
39
|
+
TmpFile.with_file do |dir|
|
40
|
+
kb = KnowledgeBase.new dir, "Hsa/jan2013"
|
41
|
+
kb.format["Gene"] = "Ensembl Gene ID"
|
42
|
+
|
43
|
+
kb.register 'nature', NCI.nature_pathways, :merge => true, :fields => [2], :key_field => 0
|
44
|
+
assert kb.get_database('nature', :persist => false).slice("Ensembl Gene ID").values.flatten.uniq.length > 10
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_global
|
49
|
+
assert @kb.all_databases.include? "pina"
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_benchmark
|
53
|
+
tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013").ensembl
|
54
|
+
kb = KnowledgeBase.new Rbbt.tmp.test.kb2
|
55
|
+
kb.namespace = "Hsa/jan2013"
|
56
|
+
|
57
|
+
require 'rbbt/sources/COSMIC'
|
58
|
+
require 'rbbt/entity/genomic_mutation'
|
59
|
+
mutations = tp53.COSMIC_mutations
|
60
|
+
Misc.benchmark(10) do
|
61
|
+
name = "mutations"
|
62
|
+
kb.add_index name, "Ensembl Gene ID", "Genomic Mutation", "Change"
|
63
|
+
kb.write name do
|
64
|
+
mutations.each do |gm|
|
65
|
+
kb.add name, tp53, gm, gm.base
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_items
|
72
|
+
tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013").ensembl
|
73
|
+
kb = KnowledgeBase.new Rbbt.tmp.test.kb2, "Hsa/jan2013"
|
74
|
+
kb.index('g2t', Organism.gene_transcripts("Hsa/jan2013"), :target => "Ensembl Transcript ID")
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_benchmark2
|
78
|
+
tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013").ensembl
|
79
|
+
kb = KnowledgeBase.new Rbbt.tmp.test.kb2, "Hsa/jan2013"
|
80
|
+
kb.index('g2t', Organism.gene_transcripts("Hsa/jan2013"), :target => "Ensembl Transcript ID")
|
81
|
+
l = nil
|
82
|
+
Misc.benchmark(1000) do
|
83
|
+
l = tp53.transcripts.length
|
84
|
+
end
|
85
|
+
assert l > 0
|
86
|
+
end
|
87
|
+
|
88
|
+
def __test_subset
|
89
|
+
gene = "TP53"
|
90
|
+
found = Genomics.knowledge_base.identify :pina, gene
|
91
|
+
p53_interactors = Misc.profile{ Genomics.knowledge_base.children(:pina, found).target_entity }
|
92
|
+
|
93
|
+
ddd p53_interactors.length
|
94
|
+
|
95
|
+
Misc.profile do
|
96
|
+
puts Genomics.knowledge_base.subset(:pina,{"Gene" => p53_interactors}).length
|
97
|
+
end
|
98
|
+
ddd 2
|
99
|
+
#assert Genomics.knowledge_base.subset(:pina,{"Gene" => p53_interactors}).target_entities.name.include? "MDM2"
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|