rbbt-dm 1.1.42 → 1.1.43

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb33662dd918f39ceb8090b64983a746960c5216
4
- data.tar.gz: 5865c507c3ea0468f80a9b80a602b5b7ccc11d73
3
+ metadata.gz: 270570bf58c397ec1f6da3195f882a5cf73eb1a1
4
+ data.tar.gz: 4f7232e2c2cddff960f2f9dce6e4279298b53408
5
5
  SHA512:
6
- metadata.gz: f11deb2301550a9382aca6c9c41fe9ece9e93f2c63c29db84d777b48caec99b3dfeb05e6cc98b4e52f07fa7ea01f312abef81733c9deeafc16694ce6f9449caa
7
- data.tar.gz: '0715538b774c7b547c60773c61711539ace35774b7e21813e62fb42aab800946a5ec7002f99e4bf3e1a2030ca837251fc788daf94bee837f6a0a093129567794'
6
+ metadata.gz: faa0514ae85d537007147f8a1c06367202cffa83c5081b68f9e2e23943b02cc5601160fbcfd32f0c041fd511b2f3116e82b14b5313ba57488297f76a74f77433
7
+ data.tar.gz: bc1d750d449763f45482318e1f4fe5d54f80c64eb90c3fb08c71d94d282496aa87e54004f309e2c2dac4cc3bc01995880481be490c4bf6510d1e35417276eb85
@@ -1,19 +1,21 @@
1
- require 'priority_queue'
1
+ require 'fc'
2
2
 
3
3
  module Paths
4
4
 
5
5
  def self.dijkstra(adjacency, start_node, end_node = nil, max_steps = nil)
6
6
  return nil unless adjacency.include? start_node
7
7
 
8
- active = PriorityQueue.new
8
+ active = FastContainers::PriorityQueue.new(:max)
9
9
  distances = Hash.new { 1.0 / 0.0 }
10
10
  parents = Hash.new
11
11
 
12
- active[start_node] << 0
12
+ active.push(start_node, 0)
13
13
  best = 1.0 / 0.0
14
14
  until active.empty?
15
- u = active.priorities.first
16
- distance = active.shift
15
+ u = active.top
16
+ distance = active.top_key
17
+ active.pop
18
+
17
19
  distances[u] = distance
18
20
  d = distance + 1
19
21
  path = extract_path(parents, start_node, u)
@@ -21,13 +23,12 @@ module Paths
21
23
  adjacency[u].each do |v|
22
24
  next unless d < distances[v] and d < best # we can't relax this one
23
25
  best = d if (String === end_node ? end_node == v : end_node.include?(v))
24
- active[v] << d if adjacency.include? v
26
+ active.push(v,d) if adjacency.include? v
25
27
  distances[v] = d
26
28
  parents[v] = u
27
29
  end
28
30
  end
29
31
 
30
-
31
32
  if end_node
32
33
  end_node = end_node.select{|n| parents.keys.include? n}.first unless String === end_node
33
34
  return nil if not parents.include? end_node
@@ -48,25 +49,28 @@ module Paths
48
49
  def self.weighted_dijkstra(adjacency, start_node, end_node = nil, threshold = nil, max_steps = nil)
49
50
  return nil unless adjacency.include? start_node
50
51
 
51
- active = PriorityQueue.new
52
+ active = FastContainers::PriorityQueue.new(:max)
52
53
  distances = Hash.new { 1.0 / 0.0 }
53
54
  parents = Hash.new
54
55
 
55
- active[start_node] << 0
56
+ #active[start_node] << 0
57
+ active.push(start_node, 0)
56
58
  best = 1.0 / 0.0
57
59
  found = false
58
60
  until active.empty?
59
- u = active.priorities.first
60
- distance = active.shift
61
+ u = active.top
62
+ distance = active.top_key
63
+ active.pop
61
64
  distances[u] = distance
62
65
  path = extract_path(parents, start_node, u)
63
66
  next if path.length > max_steps if max_steps
64
67
  next if not adjacency.include?(u) or (adjacency[u].nil? or adjacency[u].empty? )
65
68
  Misc.zip_fields(adjacency[u]).each do |v,node_dist|
69
+ node_dist = node_dist.to_f
66
70
  next if node_dist.nil? or (threshold and node_dist > threshold)
67
71
  d = distance + node_dist
68
72
  next unless d < distances[v] and d < best # we can't relax this one
69
- active[v] << d
73
+ active.push(v, d)
70
74
  distances[v] = d
71
75
  parents[v] = u
72
76
  if (String === end_node ? end_node == v : end_node.include?(v))
@@ -7,45 +7,42 @@ require 'set'
7
7
 
8
8
  class TestNetwork < Test::Unit::TestCase
9
9
  def _test_dijsktra
10
- string = STRING.protein_protein.tsv :persist => false, :fields => ["Interactor Ensembl Protein ID"], :type => :flat
11
- string.unnamed = true
12
-
13
- start_node = "ENSP00000256078"
14
- end_node = "ENSP00000306245"
15
-
16
- path = Paths.dijkstra(string, start_node, [end_node])
17
-
18
- assert path != nil
19
- assert path.include? start_node
20
- assert path.include? end_node
10
+ network_txt=<<-EOF
11
+ #: :sep=/\s/#:type=:flat
12
+ #Start End
13
+ N1 N2
14
+ N2 N3 N4
15
+ N4 N5
16
+ EOF
17
+ network = TSV.open(StringIO.new(network_txt))
18
+
19
+ start_node = "N1"
20
+ end_node = "N5"
21
+
22
+ path = Paths.dijkstra(network, start_node, [end_node])
23
+ assert_equal %w(N1 N2 N4), path.reverse
21
24
  end
22
25
 
23
26
  def test_weighted_dijsktra
24
- string = STRING.protein_protein.tsv
25
- string.unnamed = true
27
+ network_txt=<<-EOF
28
+ #: :sep=/\s/#:type=:double
29
+ #Start End Score
30
+ N1 N2|N5 1|10
31
+ N2 N3|N4 1|1
32
+ N4 N5 1
33
+ EOF
34
+ network = TSV.open(StringIO.new(network_txt))
26
35
 
27
- string.process "Score" do |scores|
28
- scores.collect{|score| 1000 - score.to_i}
29
- end
30
-
31
- start_node = "ENSP00000256078"
32
- end_node = "ENSP00000306245"
33
-
34
- path = Paths.weighted_dijkstra(string, start_node, end_node)
36
+ start_node = "N1"
37
+ end_node = "N5"
35
38
 
36
- assert path != nil
37
- assert path.include? start_node
38
- assert path.include? end_node
39
-
40
- path = Paths.weighted_dijkstra(string, start_node, Set.new([end_node]))
39
+ path = Paths.weighted_dijkstra(network, start_node, [end_node])
40
+ assert_equal %w(N1 N2 N4 N5), path.reverse
41
41
 
42
- assert path != nil
43
- assert path.include? start_node
44
- assert path.include? end_node
45
-
46
42
  end
47
43
 
48
- def _test_random_weighted_dijsktra
44
+
45
+ def __test_random_weighted_dijsktra
49
46
  string = STRING.protein_protein.tsv
50
47
 
51
48
  string.process "Score" do |scores|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-dm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.42
4
+ version: 1.1.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-03 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: priority_queue
42
+ name: priority_queue_cxx
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -138,18 +138,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.6.13
141
+ rubygems_version: 2.6.8
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Data-mining and statistics
145
145
  test_files:
146
+ - test/test_helper.rb
147
+ - test/rbbt/test_stan.rb
148
+ - test/rbbt/vector/model/test_svm.rb
149
+ - test/rbbt/vector/test_model.rb
146
150
  - test/rbbt/network/test_paths.rb
147
151
  - test/rbbt/matrix/test_barcode.rb
148
- - test/rbbt/statistics/test_random_walk.rb
149
152
  - test/rbbt/statistics/test_fisher.rb
150
- - test/rbbt/statistics/test_fdr.rb
151
153
  - test/rbbt/statistics/test_hypergeometric.rb
152
- - test/rbbt/vector/test_model.rb
153
- - test/rbbt/vector/model/test_svm.rb
154
- - test/rbbt/test_stan.rb
155
- - test/test_helper.rb
154
+ - test/rbbt/statistics/test_fdr.rb
155
+ - test/rbbt/statistics/test_random_walk.rb