bio-gadget 0.2.2 → 0.2.3

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.
@@ -32,7 +32,7 @@ module Bio
32
32
  ts = Array.new
33
33
  qs = Array.new
34
34
  (wells + ['other']).each { |well|
35
- q = SizedQueue.new(1000)
35
+ q = Queue.new
36
36
  t = Thread.new(well, q) do |well, q|
37
37
  tc = Thread.current
38
38
  tc[:file] = "#{options['output-dir']}/#{well}.fq.xz"
@@ -52,28 +52,21 @@ module Bio
52
52
  ts.push(t)
53
53
  }
54
54
 
55
- rq = SizedQueue.new(1000)
56
- Thread.new(rq) {
57
- Bio::Faster.new(:stdin).each_record(:quality => :raw) do |seqid, seq, qvs|
58
- rq.push([seqid, seq, qvs])
59
- end
60
- rq.push('')
61
- }
62
-
63
- seqs = Array.new
64
- while vals = rq.shift
65
- if vals != ""
66
- seqs.push(vals)
67
- end
68
- if vals == "" || seqs.size == 10000 * Parallel.processor_count
69
- parallel_Levenshtein(seqs, bcs, ofs, bclen, qs)
70
- seqs = Array.new
71
- end
72
- if vals == ""
73
- qs.each { |q| q.push('') }
74
- break
55
+ Bio::Faster.new(:stdin).each_record(:quality => :raw) do |seqid, seq, qvs|
56
+ tmpdists = Hash.new
57
+ bcs.each_index { |bcidx|
58
+ tmpdists[bcidx] = Levenshtein.distance(bcs[bcidx], seq[ofs, bclen])
59
+ }
60
+ dists = tmpdists.sort { |a, b| a[1] <=> b[1] }
61
+ if dists[0][1] < 2 && dists[0][1] < dists[1][1]
62
+ qs[dists[0][0]].push("@#{seqid}\n#{seq}\n+\n#{qvs}")
63
+ else
64
+ qs[-1].push("@#{seqid}\n#{seq}\n+\n#{qvs}")
75
65
  end
66
+ Thread.pass
76
67
  end
68
+
69
+ qs.each { |q| q.push('') }
77
70
  ts.each { |t| t.join }
78
71
 
79
72
  total = 0
@@ -91,35 +84,5 @@ module Bio
91
84
 
92
85
  end
93
86
 
94
- protected
95
-
96
- def parallel_Levenshtein(seqs, bcs, ofs, bclen, qs)
97
-
98
- tmpdists = Parallel.map_with_index(bcs, :in_processes => Parallel.processor_count) do |bc, bcidx|
99
- tmpdist = Array.new
100
- seqs.each_index do |seqidx|
101
- seqbc = seqs[seqidx][1][ofs, bclen]
102
- tmpdist.push(Levenshtein.distance(bc, seqbc))
103
- end
104
- tmpdist
105
- end
106
-
107
- tmpdist = Hash.new
108
- seqs.each_index do |seqidx|
109
- seqid, seq, qvs = seqs[seqidx]
110
- bcs.each_index do |bcidx|
111
- tmpdist[bcidx] = tmpdists[bcidx][seqidx]
112
- end
113
- dists = tmpdist.sort { |a, b| a[1] <=> b[1] }
114
- if dists[0][1] < dists[1][1] && dists[0][1] < 2
115
- idx = dists[0][0]
116
- qs[idx].push("@#{seqid}\n#{seq}\n+\n#{qvs}")
117
- else
118
- qs[-1].push("@#{seqid}\n#{seq}\n+\n#{qvs}")
119
- end
120
- end
121
-
122
- end
123
-
124
87
  end
125
88
  end
@@ -3,7 +3,7 @@ require 'thor'
3
3
  module Bio
4
4
  class Gadget < Thor
5
5
 
6
- VERSION = "0.2.2"
6
+ VERSION = "0.2.3"
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-13 00:00:00.000000000 Z
12
+ date: 2013-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gthor