bio-krona 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b05815b00deb3388e4c80630a62aa09eed51007
4
+ data.tar.gz: af4bf2f1f0101424c60c3a33f8b2af9f5456204b
5
+ SHA512:
6
+ metadata.gz: 60240f084a744c257bd5aa0f921593aebf2ec885b9d23f5b886c08c1372d99f910faffcb62affa65f8871695f60b683ac67ae5a6bbf1b6f52b1cac7ffe86a888
7
+ data.tar.gz: c5467498399e8578c52d46ad7db63433cbe0ebc05feb432982849ad0c96441ada4249c6b53384bb61993690294e64c4364682d964367be36253ebc62e599a132
data/Gemfile CHANGED
@@ -7,11 +7,10 @@ gem 'bio'
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
9
9
  group :development do
10
- gem "rspec", ">= 2.8.0"
10
+ gem "rspec", "~> 2.8.0"
11
11
  gem "yard", ">= 0.7"
12
12
  gem "rdoc", ">= 3.12"
13
- gem "cucumber", ">= 0"
14
13
  gem "jeweler", ">= 1.8.3"
15
14
  gem "bundler", ">= 1.0.21"
16
- gem "rdoc", ">= 3.12"
15
+ gem 'pry'
17
16
  end
data/Rakefile CHANGED
@@ -34,10 +34,6 @@ RSpec::Core::RakeTask.new(:test_without_wrapper) do |spec|
34
34
  spec.pattern = FileList['spec/**/*_spec.rb'].reject{|f| f=='spec/bio-krona_wrapper_spec.rb'}
35
35
  end
36
36
 
37
-
38
- require 'cucumber/rake/task'
39
- Cucumber::Rake::Task.new(:features)
40
-
41
37
  task :default => :spec
42
38
 
43
39
  require 'yard'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -8,12 +8,14 @@ module Bio
8
8
  # * options:
9
9
  # ** :krona_path: path to the ktImportText script in the krona directory (default 'ktImportText' i.e. assuming it is already in the PATH)
10
10
  # ** :resources_url: URL of krona resources (i.e. the -u option of ktImportText)
11
+ # ** :multiple_samples: count_hash is a hash of sample names to hash of Array => Numeric, when multiple samples are to be included [default false]
11
12
  def self.html(count_hash, options={})
12
13
  raise unless count_hash.kind_of?(Hash)
13
14
  options[:krona_path] ||= %(ktImportText)
14
15
 
15
- Tempfile.open('krona') do |tempfile|
16
- count_hash.each do |array, count|
16
+ get_tempfile_from_count_hash = lambda do |ch|
17
+ tempfile = Tempfile.new('krona')
18
+ ch.each do |array, count|
17
19
  raise unless array.kind_of?(Array)
18
20
  raise unless count.kind_of?(Numeric)
19
21
 
@@ -23,27 +25,49 @@ module Bio
23
25
  ].flatten.join("\t")
24
26
  end
25
27
  tempfile.close
28
+ tempfile
29
+ end
26
30
 
27
- Tempfile.open('krona_out') do |output|
28
- output.close
31
+ input_tempfiles = []
32
+ input_names = []
33
+ if options[:multiple_samples]
34
+ input_names = count_hash.keys
35
+ input_tempfiles = count_hash.values.collect{|ch| get_tempfile_from_count_hash.call(ch)}
36
+ else
37
+ input_names = [nil]
38
+ input_tempfiles = [get_tempfile_from_count_hash.call(count_hash)]
39
+ end
29
40
 
30
- command = [
31
- options[:krona_path],
32
- '-o',
33
- output.path,
34
- tempfile.path,
35
- ].flatten
36
- if options[:resources_url]
37
- command.push '-u'
38
- command.push options[:resources_url]
39
- end
40
- Bio::Command.call_command_open3(command) do |stdin, stdout, stderr|
41
- err = stderr.read
42
- raise err unless err==''
43
- end
41
+ pairs = []
42
+ input_names.each_with_index do |name, i|
43
+ tmpname = input_tempfiles[i].path
44
+ if name.nil?
45
+ pairs.push tmpname
46
+ else
47
+ pairs.push "#{tmpname},#{name}"
48
+ end
49
+ end
44
50
 
45
- return File.open(output.path).read
51
+ Tempfile.open('krona_out') do |output|
52
+ output.close
53
+
54
+ command = [
55
+ options[:krona_path],
56
+ '-o',
57
+ output.path,
58
+ pairs,
59
+ ].flatten
60
+ if options[:resources_url]
61
+ command.push '-u'
62
+ command.push options[:resources_url]
46
63
  end
64
+ Bio::Command.call_command_open3(command) do |stdin, stdout, stderr|
65
+ err = stderr.read
66
+ raise err unless err==''
67
+ end
68
+
69
+ input_tempfiles.each{|t| t.close}
70
+ return File.open(output.path).read
47
71
  end
48
72
  end
49
73
 
@@ -68,4 +68,55 @@ EOF
68
68
 
69
69
  html.should match('script src="http://dummy.com')
70
70
  end
71
+
72
+ it "should give a html with multiple samples" do
73
+ html = Bio::Krona.html({'sample1' => {
74
+ ['Sponge','Amphimedon']=>3,
75
+ ['Sponge','Calciums']=>4,
76
+ },
77
+ 'sample2' => {
78
+ ['Sponge','Amphimedon']=>30,
79
+ ['Sponge','Calciums']=>45,
80
+ }
81
+ }, :multiple_samples => true)
82
+ html.should == '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n <head>\n <meta charset=\"utf-8\"/>\n <link rel=\"shortcut icon\" href=\"http://krona.sourceforge.net/img/favicon.ico\"/>\n <script id=\"notfound\">window.onload=function(){document.body.innerHTML=\"Could not get resources from \\\"http://krona.sourceforge.net\\\".\"}</script>\n <script src=\"http://krona.sourceforge.net/src/krona-2.0.js\"></script>\n </head>\n <body>\n <img id=\"hiddenImage\" src=\"http://krona.sourceforge.net/img/hidden.png\" style=\"display:none\"/>\n <img id=\"loadingImage\" src=\"http://krona.sourceforge.net/img/loading.gif\" style=\"display:none\"/>\n <noscript>Javascript must be enabled to view this page.</noscript>\n <div style=\"display:none\">\n <krona collapse=\"true\" key=\"true\">\n <attributes magnitude=\"magnitude\">\n <list>members</list>\n <attribute display=\"Total\">magnitude</attribute>\n </attributes>\n <datasets>\n <dataset>sample1</dataset>\n <dataset>sample2</dataset>\n </datasets>\n<node name=\"all\">\n <magnitude><val>7</val><val>75</val></magnitude>\n <node name=\"Sponge\">\n <magnitude><val>7</val><val>75</val></magnitude>\n <node name=\"Amphimedon\">\n <magnitude><val>3</val><val>30</val></magnitude>\n </node>\n <node name=\"Calciums\">\n <magnitude><val>4</val><val>45</val></magnitude>\n </node>\n </node>\n</node>\n </krona>\n</div></body></html>\n" (using ==)
83
+ Diff:
84
+ @@ -1 +1,37 @@
85
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
86
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
87
+ <head>
88
+ <meta charset="utf-8"/>
89
+ <link rel="shortcut icon" href="http://krona.sourceforge.net/img/favicon.ico"/>
90
+ <script id="notfound">window.onload=function(){document.body.innerHTML="Could not get resources from \"http://krona.sourceforge.net\"."}</script>
91
+ <script src="http://krona.sourceforge.net/src/krona-2.0.js"></script>
92
+ </head>
93
+ <body>
94
+ <img id="hiddenImage" src="http://krona.sourceforge.net/img/hidden.png" style="display:none"/>
95
+ <img id="loadingImage" src="http://krona.sourceforge.net/img/loading.gif" style="display:none"/>
96
+ <noscript>Javascript must be enabled to view this page.</noscript>
97
+ <div style="display:none">
98
+ <krona collapse="true" key="true">
99
+ <attributes magnitude="magnitude">
100
+ <list>members</list>
101
+ <attribute display="Total">magnitude</attribute>
102
+ </attributes>
103
+ <datasets>
104
+ <dataset>sample1</dataset>
105
+ <dataset>sample2</dataset>
106
+ </datasets>
107
+ <node name="all">
108
+ <magnitude><val>7</val><val>75</val></magnitude>
109
+ <node name="Sponge">
110
+ <magnitude><val>7</val><val>75</val></magnitude>
111
+ <node name="Amphimedon">
112
+ <magnitude><val>3</val><val>30</val></magnitude>
113
+ </node>
114
+ <node name="Calciums">
115
+ <magnitude><val>4</val><val>45</val></magnitude>
116
+ </node>
117
+ </node>
118
+ </node>
119
+ </krona>
120
+ +</div></body></html>'
121
+ end
71
122
  end
metadata CHANGED
@@ -1,144 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-krona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ben J. Woodcroft
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-16 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bio
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.8.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.8.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: yard
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0.7'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0.7'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rdoc
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '3.12'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '3.12'
78
- - !ruby/object:Gem::Dependency
79
- name: cucumber
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: jeweler
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
- - - ! '>='
73
+ - - ">="
100
74
  - !ruby/object:Gem::Version
101
75
  version: 1.8.3
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
- - - ! '>='
80
+ - - ">="
108
81
  - !ruby/object:Gem::Version
109
82
  version: 1.8.3
110
83
  - !ruby/object:Gem::Dependency
111
84
  name: bundler
112
85
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
86
  requirements:
115
- - - ! '>='
87
+ - - ">="
116
88
  - !ruby/object:Gem::Version
117
89
  version: 1.0.21
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
93
  requirements:
123
- - - ! '>='
94
+ - - ">="
124
95
  - !ruby/object:Gem::Version
125
96
  version: 1.0.21
126
97
  - !ruby/object:Gem::Dependency
127
- name: rdoc
98
+ name: pry
128
99
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
100
  requirements:
131
- - - ! '>='
101
+ - - ">="
132
102
  - !ruby/object:Gem::Version
133
- version: '3.12'
103
+ version: '0'
134
104
  type: :development
135
105
  prerelease: false
136
106
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
107
  requirements:
139
- - - ! '>='
108
+ - - ">="
140
109
  - !ruby/object:Gem::Version
141
- version: '3.12'
110
+ version: '0'
142
111
  description: This biogem is built around Krona, a flashy way of representing hierarchical
143
112
  data.
144
113
  email: donttrustben near gmail.com
@@ -148,9 +117,9 @@ extra_rdoc_files:
148
117
  - LICENSE.txt
149
118
  - README.md
150
119
  files:
151
- - .document
152
- - .rspec
153
- - .travis.yml
120
+ - ".document"
121
+ - ".rspec"
122
+ - ".travis.yml"
154
123
  - Gemfile
155
124
  - LICENSE.txt
156
125
  - README.md
@@ -166,30 +135,26 @@ files:
166
135
  homepage: http://github.com/wwood/bioruby-krona
167
136
  licenses:
168
137
  - MIT
138
+ metadata: {}
169
139
  post_install_message:
170
140
  rdoc_options: []
171
141
  require_paths:
172
142
  - lib
173
143
  required_ruby_version: !ruby/object:Gem::Requirement
174
- none: false
175
144
  requirements:
176
- - - ! '>='
145
+ - - ">="
177
146
  - !ruby/object:Gem::Version
178
147
  version: '0'
179
- segments:
180
- - 0
181
- hash: -432620685
182
148
  required_rubygems_version: !ruby/object:Gem::Requirement
183
- none: false
184
149
  requirements:
185
- - - ! '>='
150
+ - - ">="
186
151
  - !ruby/object:Gem::Version
187
152
  version: '0'
188
153
  requirements: []
189
154
  rubyforge_project:
190
- rubygems_version: 1.8.25
155
+ rubygems_version: 2.2.2
191
156
  signing_key:
192
- specification_version: 3
157
+ specification_version: 4
193
158
  summary: This biogem is built around Krona, a flashy way of representing hierarchical
194
159
  data.
195
160
  test_files: []