rbbt-util 6.0.4 → 6.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6312e564dc119b942bb279017a12bd3571f27b1caa57db746c62996e8c73407
4
- data.tar.gz: f08802c255d5967bf211bf801fbeb7f91e9d2a82804f51393061ce422e7fc26e
3
+ metadata.gz: c5f392d8b49d9b1f3f0e2fc2a627654d7e0d8c8766277ab525c42f692d97eac4
4
+ data.tar.gz: 78026648894c3868852a01fb1a74bf9b554c9a28e121f51f77029fc6265019cd
5
5
  SHA512:
6
- metadata.gz: 2f74e126c73d121853002d2918ef5cb8c9b181c7c2264d7eb7c9f4a4d78441fc6b026f1b27eca445613717fff6a8f0169f9aeb86d33afeafe2eebed696685cc3
7
- data.tar.gz: 93ddc50c5c0f5b45e79449f81788405fada4ad9aabaeac1f6fd908765184a79220e2960472a460a973afedd31ae2ad389c60d67a80e4b82ae63ac70748bf8a25
6
+ metadata.gz: 43188e6b49995ee547e1c968ba1daca213e3204e20d0695dfd5b0a75b3788e866d04cba23e84ef59d794e58b2eaae8c7e8860ea07e7e7d71fab14df96dd6d583
7
+ data.tar.gz: 6656b4fb1a54e5c6b9711a3c5bc735a04335de2380bb93fcd18f923b54914b408640e4545167c7c1599122ae2685e8fca3375b4775c2b3c30f2bdc23146344c1
data/bin/rbbt CHANGED
@@ -102,7 +102,7 @@ end
102
102
  $scout_command_dir = Scout.bin.scout
103
103
  $scout_command_dir.path_maps[:rbbt_bin] = File.join(File.dirname(__dir__), "{PATH/bin\\/scout/bin\\/rbbt}")
104
104
  $scout_command_dir.path_maps[:rbbt_commands] = File.join(File.dirname(__dir__), "{PATH/bin\\/scout/share\\/rbbt_commands}")
105
- $scout_command_dir.path_maps[:scout_commands] = File.join(Scout.root.find(:scout_gear), "{PATH/bin\\/scout/scout_commands}")
105
+ $scout_command_dir.path_maps[:scout_commands] = File.join(Scout.root.find(:scout_gear_lib), "{PATH/bin\\/scout/scout_commands}")
106
106
 
107
107
  SOPT.description =<<EOF
108
108
  This command controls many aspects of the Scout framework, from configuration tasks to running applications.
@@ -133,7 +133,7 @@ module HPC
133
133
  # Save inputs into inputs_dir
134
134
  inputs_dir = IndiferentHash.process_options options, :inputs_dir
135
135
  saved = job.save_inputs(inputs_dir)
136
- options[:load_inputs] = inputs_dir if saved && saved.any?
136
+ options[:load_inputs] = inputs_dir if saved && !saved.nil? && !saved.empty?
137
137
 
138
138
  saved.each do |input|
139
139
  options.delete input
@@ -1,9 +1,9 @@
1
- require 'rbbt/knowledge_base/registry'
2
- class KnowledgeBase
3
- def enrichment(name, entities, options = {})
4
- require 'rbbt/statistics/hypergeometric'
5
- database = get_database(name, options)
6
- entities = identify_source name, entities
7
- database.enrichment entities, database.fields.first, :persist => false
8
- end
9
- end
1
+ #require 'rbbt/knowledge_base/registry'
2
+ #class KnowledgeBase
3
+ # def enrichment(name, entities, options = {})
4
+ # require 'rbbt/statistics/hypergeometric'
5
+ # database = get_database(name, options)
6
+ # entities = identify_source name, entities
7
+ # database.enrichment entities, database.fields.first, :persist => false
8
+ # end
9
+ #end
@@ -1,128 +1,128 @@
1
- require 'rbbt/entity'
2
- require 'rbbt/knowledge_base/registry'
3
-
4
- class KnowledgeBase
5
-
6
- def select_entities(name, entities, options = {})
7
- index = get_index(name, options)
8
-
9
- source_field = index.source_field
10
- target_field = index.target_field
11
-
12
- source_type = Entity.formats[source_field]
13
- target_type = Entity.formats[target_field]
14
-
15
- source_entities = entities[:source] || entities[source_field] || entities[Entity.formats[source_field].to_s] || entities[:both]
16
- target_entities = entities[:target] || entities[target_field] || entities[Entity.formats[target_field].to_s] || entities[:both]
17
-
18
- [source_entities, target_entities]
19
- end
20
-
21
-
22
- def entity_options_for(type, database_name = nil)
23
- entity_options = self.entity_options
24
- IndiferentHash.setup entity_options if entity_options and not IndiferentHash === entity_options
25
- options = entity_options[type.to_s] || entity_options[Entity.formats[type.to_s].to_s] || {}
26
- options[:format] = @format[type] if Hash === @format && @format.include?(type)
27
- namespace = self.namespace
28
- namespace = db_namespace(database_name) if namespace.nil? and database_name
29
- options = {:organism => namespace}.merge(options)
30
- if database_name
31
- database = get_database(database_name)
32
- if database.entity_options and (database.entity_options[type] or database.entity_options[Entity.formats[type.to_s].to_s])
33
- options = options.merge(database.entity_options[type] || database.entity_options[Entity.formats[type.to_s].to_s])
34
- end
35
- end
36
- options
37
- end
38
-
39
- def annotate(entities, type, database = nil)
40
- format = @format[type] || type
41
- entity_options = entity_options_for(type, database)
42
- Entity.prepare_entity(entities, format, entity_options)
43
- end
44
-
45
- def translate(entities, type)
46
- if format = @format[type] and (entities.respond_to? :format and format != entities.format)
47
- entities.to format
48
- else
49
- entities
50
- end
51
- end
52
-
53
- def source_type(name)
54
- Entity.formats[source(name)]
55
- end
56
-
57
- def target_type(name)
58
- Entity.formats[target(name)]
59
- end
60
-
61
- def entities
62
- all_databases.inject([]){|acc,name| acc << source(name); acc << target(name)}.uniq
63
- end
64
-
65
- def entity_types
66
- entities.collect{|entity| Entity.formats[entity] }.uniq
67
- end
68
-
69
- def identifier_files(name)
70
- get_database(name).identifier_files.dup
71
- end
72
-
73
- def db_namespace(name)
74
- get_database(name).namespace
75
- end
76
-
77
- def source_index(name)
78
- Persist.memory("Source index #{name}: KB directory #{dir}") do
79
- identifier_files = identifier_files(name)
80
- identifier_files.concat Entity.identifier_files(source(name)) if defined? Entity
81
- identifier_files.uniq!
82
- identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
83
- identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, db_namespace(name)))} if not namespace and db_namespace(name)
84
- identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
85
- TSV.translation_index identifier_files, nil, source(name), :persist => true
86
- end
87
- end
88
-
89
- def target_index(name)
90
- Persist.memory("Target index #{name}: KB directory #{dir}") do
91
- identifier_files = identifier_files(name)
92
- identifier_files.concat Entity.identifier_files(target(name)) if defined? Entity
93
- identifier_files.uniq!
94
- identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if self.namespace
95
- identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, db_namespace(name)))} if namespace.nil? and db_namespace(name)
96
- identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
97
- TSV.translation_index identifier_files, nil, target(name), :persist => true
98
- end
99
- end
100
-
101
- def identify_source(name, entity)
102
- return :all if entity == :all
103
- index = source_index(name)
104
- return entity if index.nil?
105
- if Array === entity
106
- entity.collect{|e| index[e] || e }
107
- else
108
- index[entity] || entity
109
- end
110
- end
111
-
112
-
113
- def identify_target(name, entity)
114
- return :all if entity == :all
115
- index = target_index(name)
116
- return entity if index.nil?
117
- if Array === entity
118
- entity.collect{|e| index[e] || e }
119
- else
120
- index[entity] || entity
121
- end
122
- end
123
-
124
- def identify(name, entity)
125
- identify_source(name, entity) || identify_target(name, entity)
126
- end
127
- end
128
-
1
+ #require 'rbbt/entity'
2
+ #require 'rbbt/knowledge_base/registry'
3
+ #
4
+ #class KnowledgeBase
5
+ #
6
+ # def select_entities(name, entities, options = {})
7
+ # index = get_index(name, options)
8
+ #
9
+ # source_field = index.source_field
10
+ # target_field = index.target_field
11
+ #
12
+ # source_type = Entity.formats[source_field]
13
+ # target_type = Entity.formats[target_field]
14
+ #
15
+ # source_entities = entities[:source] || entities[source_field] || entities[Entity.formats[source_field].to_s] || entities[:both]
16
+ # target_entities = entities[:target] || entities[target_field] || entities[Entity.formats[target_field].to_s] || entities[:both]
17
+ #
18
+ # [source_entities, target_entities]
19
+ # end
20
+ #
21
+ #
22
+ # def entity_options_for(type, database_name = nil)
23
+ # entity_options = self.entity_options
24
+ # IndiferentHash.setup entity_options if entity_options and not IndiferentHash === entity_options
25
+ # options = entity_options[type.to_s] || entity_options[Entity.formats[type.to_s].to_s] || {}
26
+ # options[:format] = @format[type] if Hash === @format && @format.include?(type)
27
+ # namespace = self.namespace
28
+ # namespace = db_namespace(database_name) if namespace.nil? and database_name
29
+ # options = {:organism => namespace}.merge(options)
30
+ # if database_name
31
+ # database = get_database(database_name)
32
+ # if database.entity_options and (database.entity_options[type] or database.entity_options[Entity.formats[type.to_s].to_s])
33
+ # options = options.merge(database.entity_options[type] || database.entity_options[Entity.formats[type.to_s].to_s])
34
+ # end
35
+ # end
36
+ # options
37
+ # end
38
+ #
39
+ # def annotate(entities, type, database = nil)
40
+ # format = @format[type] || type
41
+ # entity_options = entity_options_for(type, database)
42
+ # Entity.prepare_entity(entities, format, entity_options)
43
+ # end
44
+ #
45
+ # def translate(entities, type)
46
+ # if format = @format[type] and (entities.respond_to? :format and format != entities.format)
47
+ # entities.to format
48
+ # else
49
+ # entities
50
+ # end
51
+ # end
52
+ #
53
+ # def source_type(name)
54
+ # Entity.formats[source(name)]
55
+ # end
56
+ #
57
+ # def target_type(name)
58
+ # Entity.formats[target(name)]
59
+ # end
60
+ #
61
+ # def entities
62
+ # all_databases.inject([]){|acc,name| acc << source(name); acc << target(name)}.uniq
63
+ # end
64
+ #
65
+ # def entity_types
66
+ # entities.collect{|entity| Entity.formats[entity] }.uniq
67
+ # end
68
+ #
69
+ # def identifier_files(name)
70
+ # get_database(name).identifier_files.dup
71
+ # end
72
+ #
73
+ # def db_namespace(name)
74
+ # get_database(name).namespace
75
+ # end
76
+ #
77
+ # def source_index(name)
78
+ # Persist.memory("Source index #{name}: KB directory #{dir}") do
79
+ # identifier_files = identifier_files(name)
80
+ # identifier_files.concat Entity.identifier_files(source(name)) if defined? Entity
81
+ # identifier_files.uniq!
82
+ # identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
83
+ # identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, db_namespace(name)))} if not namespace and db_namespace(name)
84
+ # identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
85
+ # TSV.translation_index identifier_files, nil, source(name), :persist => true
86
+ # end
87
+ # end
88
+ #
89
+ # def target_index(name)
90
+ # Persist.memory("Target index #{name}: KB directory #{dir}") do
91
+ # identifier_files = identifier_files(name)
92
+ # identifier_files.concat Entity.identifier_files(target(name)) if defined? Entity
93
+ # identifier_files.uniq!
94
+ # identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if self.namespace
95
+ # identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, db_namespace(name)))} if namespace.nil? and db_namespace(name)
96
+ # identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
97
+ # TSV.translation_index identifier_files, nil, target(name), :persist => true
98
+ # end
99
+ # end
100
+ #
101
+ # def identify_source(name, entity)
102
+ # return :all if entity == :all
103
+ # index = source_index(name)
104
+ # return entity if index.nil?
105
+ # if Array === entity
106
+ # entity.collect{|e| index[e] || e }
107
+ # else
108
+ # index[entity] || entity
109
+ # end
110
+ # end
111
+ #
112
+ #
113
+ # def identify_target(name, entity)
114
+ # return :all if entity == :all
115
+ # index = target_index(name)
116
+ # return entity if index.nil?
117
+ # if Array === entity
118
+ # entity.collect{|e| index[e] || e }
119
+ # else
120
+ # index[entity] || entity
121
+ # end
122
+ # end
123
+ #
124
+ # def identify(name, entity)
125
+ # identify_source(name, entity) || identify_target(name, entity)
126
+ # end
127
+ #end
128
+ #
@@ -1,94 +1,94 @@
1
- require 'rbbt/knowledge_base/registry'
2
-
3
- class KnowledgeBase
4
-
5
- def _subset(name, source = :all, target = :all, options = {})
6
- repo = get_index name, options
7
-
8
- repo.subset(source, target)
9
- end
10
-
11
- def subset(name, entities, options = {}, &block)
12
- entities, options = options, entities if entities.nil? and Hash === options
13
-
14
- entities = case entities
15
- when :all
16
- {:target => :all, :source => :all}
17
- when AnnotatedArray
18
- format = entities.format if entities.respond_to? :format
19
- format ||= entities.base_entity.to_s
20
- {format => entities.purge}
21
- when Hash
22
- entities
23
- else
24
- raise "Entities are not a Hash or an AnnotatedArray: #{Log.fingerprint entities}"
25
- end
26
-
27
- identify, identify_source, identify_target = entities.merge(options || {}).values_at :identify, :identify_source, :identify_target
28
-
29
- source, target = select_entities(name, entities, options)
30
-
31
- source = identify_source(name, source) if identify_source
32
- target = identify_target(name, target) if identify_target
33
-
34
- source = identify(name, source) if identify && !identify_source
35
- target = identify(name, target) if identify && !identify_target
36
-
37
- return [] if source.nil? or target.nil?
38
- return [] if Array === target and target.empty?
39
- return [] if Array === source and source.empty?
40
-
41
- matches = _subset name, source, target, options
42
-
43
- setup(name, matches)
44
-
45
- matches = matches.select(&block) if block_given?
46
-
47
- matches
48
- end
49
-
50
- def all(name, options={})
51
- repo = get_index name, options
52
- setup name, repo.keys
53
- end
54
-
55
- def _children(name, entity)
56
- repo = get_index name
57
- repo.match(entity)
58
- end
59
-
60
- def children(name, entity)
61
- entity = identify_source(name, entity)
62
- setup(name, _children(name, entity))
63
- end
64
-
65
- def _parents(name, entity)
66
- repo = get_index name
67
- repo.reverse.match(entity)
68
- end
69
-
70
- def parents(name, entity)
71
- entity = identify_target(name, entity)
72
- matches = _parents(name, entity)
73
- #matches.each{|m| m.replace(m.partition("~").reverse*"") } unless undirected(name)
74
- setup(name, matches, true)
75
- end
76
-
77
- def _neighbours(name, entity)
78
- if undirected(name) and source(name) == target(name)
79
- {:children => _children(name, entity)}
80
- else
81
- {:parents => _parents(name, entity), :children => _children(name, entity)}
82
- end
83
- end
84
-
85
- def neighbours(name, entity)
86
- hash = _neighbours(name, entity)
87
- IndiferentHash.setup(hash)
88
- setup(name, hash[:children]) if hash[:children]
89
- setup(name, hash[:parents], true) if hash[:parents]
90
- hash
91
- end
92
-
93
- end
94
-
1
+ #require 'rbbt/knowledge_base/registry'
2
+ #
3
+ #class KnowledgeBase
4
+ #
5
+ # def _subset(name, source = :all, target = :all, options = {})
6
+ # repo = get_index name, options
7
+ #
8
+ # repo.subset(source, target)
9
+ # end
10
+ #
11
+ # def subset(name, entities, options = {}, &block)
12
+ # entities, options = options, entities if entities.nil? and Hash === options
13
+ #
14
+ # entities = case entities
15
+ # when :all
16
+ # {:target => :all, :source => :all}
17
+ # when AnnotatedArray
18
+ # format = entities.format if entities.respond_to? :format
19
+ # format ||= entities.base_entity.to_s
20
+ # {format => entities.purge}
21
+ # when Hash
22
+ # entities
23
+ # else
24
+ # raise "Entities are not a Hash or an AnnotatedArray: #{Log.fingerprint entities}"
25
+ # end
26
+ #
27
+ # identify, identify_source, identify_target = entities.merge(options || {}).values_at :identify, :identify_source, :identify_target
28
+ #
29
+ # source, target = select_entities(name, entities, options)
30
+ #
31
+ # source = identify_source(name, source) if identify_source
32
+ # target = identify_target(name, target) if identify_target
33
+ #
34
+ # source = identify(name, source) if identify && !identify_source
35
+ # target = identify(name, target) if identify && !identify_target
36
+ #
37
+ # return [] if source.nil? or target.nil?
38
+ # return [] if Array === target and target.empty?
39
+ # return [] if Array === source and source.empty?
40
+ #
41
+ # matches = _subset name, source, target, options
42
+ #
43
+ # setup(name, matches)
44
+ #
45
+ # matches = matches.select(&block) if block_given?
46
+ #
47
+ # matches
48
+ # end
49
+ #
50
+ # def all(name, options={})
51
+ # repo = get_index name, options
52
+ # setup name, repo.keys
53
+ # end
54
+ #
55
+ # def _children(name, entity)
56
+ # repo = get_index name
57
+ # repo.match(entity)
58
+ # end
59
+ #
60
+ # def children(name, entity)
61
+ # entity = identify_source(name, entity)
62
+ # setup(name, _children(name, entity))
63
+ # end
64
+ #
65
+ # def _parents(name, entity)
66
+ # repo = get_index name
67
+ # repo.reverse.match(entity)
68
+ # end
69
+ #
70
+ # def parents(name, entity)
71
+ # entity = identify_target(name, entity)
72
+ # matches = _parents(name, entity)
73
+ # #matches.each{|m| m.replace(m.partition("~").reverse*"") } unless undirected(name)
74
+ # setup(name, matches, true)
75
+ # end
76
+ #
77
+ # def _neighbours(name, entity)
78
+ # if undirected(name) and source(name) == target(name)
79
+ # {:children => _children(name, entity)}
80
+ # else
81
+ # {:parents => _parents(name, entity), :children => _children(name, entity)}
82
+ # end
83
+ # end
84
+ #
85
+ # def neighbours(name, entity)
86
+ # hash = _neighbours(name, entity)
87
+ # IndiferentHash.setup(hash)
88
+ # setup(name, hash[:children]) if hash[:children]
89
+ # setup(name, hash[:parents], true) if hash[:parents]
90
+ # hash
91
+ # end
92
+ #
93
+ #end
94
+ #