cwords 0.1.9 → 0.1.10
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.
- data/lib/wordRS-lib.rb +38 -0
- data/scripts/cwords.rb +2 -3
- metadata +2 -16
data/lib/wordRS-lib.rb
CHANGED
@@ -1,6 +1,44 @@
|
|
1
1
|
|
2
2
|
class Array
|
3
|
+
|
4
|
+
# threaded each
|
5
|
+
def threach(n = 1, &b)
|
6
|
+
return [] if n == 0 or size == 0
|
7
|
+
result = Array.new(size)
|
8
|
+
self.send(:each,&b) if n == 1
|
9
|
+
|
10
|
+
n = [n,size].min
|
11
|
+
|
12
|
+
part_size, part_remainder = size/n, size % n
|
13
|
+
threads = []
|
14
|
+
|
15
|
+
pstart = 0
|
16
|
+
n.times do |pi|
|
17
|
+
pend = pstart + part_size - 1
|
18
|
+
pend += 1 if pi<part_remainder
|
19
|
+
threads << Thread.new(pstart,pend) do |a,b|
|
20
|
+
for j in a..b
|
21
|
+
yield(slice(j))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
pstart = pend+1
|
25
|
+
end
|
26
|
+
|
27
|
+
threads.each { |t| t.join }
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
# unit tests for threach
|
32
|
+
#Array.send(:include, Threach)
|
33
|
+
#a=(0..4).to_a
|
34
|
+
#res = a.map{|x| x*10}
|
35
|
+
#a.size.times do |pn|
|
36
|
+
# b=Array.new(a.size)
|
37
|
+
# a.threach(pn+1) {|x| b[x]=x*10}
|
38
|
+
# puts b == beach
|
39
|
+
#end
|
3
40
|
|
41
|
+
|
4
42
|
def shuffle()
|
5
43
|
arr = self.dup
|
6
44
|
arr.size.downto 2 do |j|
|
data/scripts/cwords.rb
CHANGED
@@ -9,7 +9,6 @@ require 'wordRS-lib.rb'
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'progressbar'
|
11
11
|
require 'optparse'
|
12
|
-
require 'peach'
|
13
12
|
require 'java'
|
14
13
|
require libdir + 'ushuffle.jar'
|
15
14
|
java_import 'UShuffle'
|
@@ -188,7 +187,7 @@ if sequences
|
|
188
187
|
puts "\n>> Enumerating words in sequences"
|
189
188
|
wordscores = Array.new(all.size) {Array.new(wids.size,0)} # {Java::short[wids.size].new}
|
190
189
|
pbar = ProgressBar.new("progress",sequences.size)
|
191
|
-
all.
|
190
|
+
all.threach(threads) do |seqid,val|
|
192
191
|
us = UShuffle.new
|
193
192
|
seq=sequences[seqid]
|
194
193
|
seqidx=allorder[seqid]
|
@@ -286,7 +285,7 @@ analyze.each do |set,nm|
|
|
286
285
|
options[:permutations].times{|i| perms << (0..set.size-1).to_a.shuffle}
|
287
286
|
|
288
287
|
pbar = ProgressBar.new("progress",nwords)
|
289
|
-
wids.to_a.sort_by{|x| x[1]}.
|
288
|
+
wids.to_a.sort_by{|x| x[1]}.threach(threads) do |word,wid|
|
290
289
|
pbar.inc
|
291
290
|
next if options[:onlyanno] and not word_annotation.key?(word) #only process annotated words
|
292
291
|
next if options[:plot_words] and !options[:plot_words].include?(word)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 10
|
9
|
+
version: 0.1.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Anders Jacobsen
|
@@ -32,20 +32,6 @@ dependencies:
|
|
32
32
|
version: 0.9.0
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: peach
|
37
|
-
prerelease: false
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
- 2
|
45
|
-
- 0
|
46
|
-
version: 0.2.0
|
47
|
-
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
35
|
description: Word correlation analysis in ranked nucleotide sequences (bioinformatics)
|
50
36
|
email: andersmbj@gmail.com
|
51
37
|
executables:
|