bio-kmer_counter 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.1.0
data/bin/kmer_counter.rb CHANGED
@@ -18,8 +18,6 @@ options = {
18
18
  :contig_name => false,
19
19
  :sequence_length => false,
20
20
  :logger => 'stderr',
21
- :threads => 1,
22
- :processes => 1,
23
21
  :progressbar => true,
24
22
  }
25
23
 
@@ -67,20 +65,6 @@ o = OptionParser.new do |opts|
67
65
  options[:sequence_length] = true
68
66
  end
69
67
 
70
- opts.on("-p", "--processes NUM_PROCESSES", "Use this many processes. Currently setting multiple processes means there is no progress bar [default #{options[:processes]}]") do |v|
71
- options[:processes] = v.to_i
72
- if options[:processes] < 1
73
- raise "Unexpected number of processes specified (after converting to integer) - '#{options[:processes]}'"
74
- end
75
- end
76
-
77
- opts.on("-t", "--threads NUM_THREADS", "Use this many threads. This currently only makes sense if you are running on JRuby, since the standard MRI ruby 1.9 can't use multiple cores. Maybe use --processes instead? [default #{options[:threads]}]") do |v|
78
- options[:threads] = v.to_i
79
- if options[:threads] < 1
80
- raise "Unexpected number of threads specified (after converting to integer) - '#{options[:threads]}'"
81
- end
82
- end
83
-
84
68
 
85
69
  # logger options
86
70
  opts.on("-q", "--quiet", "Run quietly, set logging to ERROR level [default INFO]") do |q|
@@ -97,8 +81,6 @@ if ARGV.length != 1
97
81
  $stderr.puts o
98
82
  exit 1
99
83
  end
100
- # multiple processes doesn't work well with ProgressBar
101
- options[:progressbar] = false if options[:processes] != 1
102
84
 
103
85
  LOG_NAME = 'bio-kmer_counter'
104
86
  Bio::Log::CLI.logger(options[:logger]) #bio-logger defaults to STDERR not STDOUT, I disagree
@@ -120,7 +102,6 @@ process_window = lambda do |window,kmer,sequence_name,contig_name|
120
102
 
121
103
  window.window_search(options[:kmer],1) do |tetranucleotide|
122
104
  str = tetranucleotide.to_s
123
- str.upcase!
124
105
  next unless str.gsub(/[ATGC]+/,'') == ''
125
106
  num_kmers_counted += 1
126
107
  counts[str]+=1
@@ -147,9 +128,10 @@ fasta_filename = ARGV[0]
147
128
  progress = nil
148
129
  progress = ProgressBar.new('kmer_counter', `grep -c '>' '#{fasta_filename}'`.to_i) if options[:progressbar]
149
130
  ff = Bio::FlatFile.open(fasta_filename)
150
- Parallel.each(ff, :in_processes => options[:processes], :threads => options[:threads]) do |sequence|
151
- #ff.each do |sequence|
131
+
132
+ ff.each do |sequence|
152
133
  window_counter = 0
134
+ sequence.seq.upcase!
153
135
  sequence.seq.window_search(options[:window_size],options[:window_offset]) do |window|
154
136
  process_window.call(window, options[:kmer], "#{sequence.definition}_#{window_counter}",sequence.definition)
155
137
  window_counter += 1
@@ -61,41 +61,6 @@ class TestBioKmerCounter < Test::Unit::TestCase
61
61
  end
62
62
  end
63
63
 
64
- should "not give a progressbar with multiple processes" do
65
- Tempfile.open('one') do |tempfile|
66
- tempfile.puts '>one'
67
- tempfile.puts 'ATGCATGCAT' #10 letters long
68
- tempfile.close
69
-
70
- expected = ["ID\tA\tC\n",
71
- "one_0\t0.5\t0.5\n",
72
- "one_1\t0.5\t0.5\n",
73
- "one_leftover_2\t1.0\t0.0\n"]
74
-
75
- # execute command and capture both stdout, and stderr
76
- # no extra processes
77
- command = "#{script_path} -w 4 -k 1 -m 2 #{tempfile.path}"
78
- Open3.popen3(command) do |stdin, stdout, stderr|
79
- result = stdout.readlines # convert to string?
80
- error = stderr.readlines
81
-
82
- assert_not_equal [], error
83
- assert_equal expected, result
84
- end
85
-
86
- # execute command and capture both stdout, and stderr
87
- # extra processes
88
- command = "#{script_path} -p 2 -w 4 -k 1 -m 2 #{tempfile.path}"
89
- Open3.popen3(command) do |stdin, stdout, stderr|
90
- result = stdout.readlines # convert to string?
91
- error = stderr.readlines
92
-
93
- assert_equal [], error
94
- assert_equal expected, result
95
- end
96
- end
97
- end
98
-
99
64
  should "print help when no arguments are given" do
100
65
  command = "#{script_path}"
101
66
  Open3.popen3(command) do |stdin, stdout, stderr|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-kmer_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-09 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bio
16
- requirement: &79074710 !ruby/object:Gem::Requirement
16
+ requirement: &85076110 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.4.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *79074710
24
+ version_requirements: *85076110
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: progressbar
27
- requirement: &79238200 !ruby/object:Gem::Requirement
27
+ requirement: &85075540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.11.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *79238200
35
+ version_requirements: *85075540
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: parallel
38
- requirement: &79249880 !ruby/object:Gem::Requirement
38
+ requirement: &85075130 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.5.17
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *79249880
46
+ version_requirements: *85075130
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bio-logger
49
- requirement: &79249150 !ruby/object:Gem::Requirement
49
+ requirement: &85074690 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *79249150
57
+ version_requirements: *85074690
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: shoulda
60
- requirement: &79246850 !ruby/object:Gem::Requirement
60
+ requirement: &85074250 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *79246850
68
+ version_requirements: *85074250
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
- requirement: &79245070 !ruby/object:Gem::Requirement
71
+ requirement: &85073740 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '3.12'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *79245070
79
+ version_requirements: *85073740
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &79286630 !ruby/object:Gem::Requirement
82
+ requirement: &85093940 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.8.3
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *79286630
90
+ version_requirements: *85093940
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bundler
93
- requirement: &79285430 !ruby/object:Gem::Requirement
93
+ requirement: &85093260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.0.21
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *79285430
101
+ version_requirements: *85093260
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &79284460 !ruby/object:Gem::Requirement
104
+ requirement: &85092790 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '3.12'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *79284460
112
+ version_requirements: *85092790
113
113
  description: A biogem for counting small kmers for fingerprinting nucleotide sequences.
114
114
  See README for details.
115
115
  email: gmail.com after donttrustben
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: -548048899
150
+ hash: 285575987
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements: