rbbt-util 5.19.11 → 5.19.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/util/R/plot.rb +49 -2
- data/lib/rbbt/util/log/progress/report.rb +8 -2
- data/lib/rbbt/util/simpleopt/parse.rb +6 -1
- data/lib/rbbt/workflow/usage.rb +12 -0
- data/share/rbbt_commands/app/start +41 -1
- data/share/rbbt_commands/app/template +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d50592693c2e72df449b2bed576cfce4a6791d5
|
4
|
+
data.tar.gz: 31f019642b140c119e08c2e4eb465b6775f4e89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad859664ea8715a701c3273bc536af07fb139b80c71e69be3a0bf55d53882c0fe821fbbe87da5369a2ad81deceb14fb8866d5ba6d58f377ed92557e5bdf30922
|
7
|
+
data.tar.gz: 9ead4f2c55309687b45f0877a3700c06883bab045c1f7f0013d2656f0f6de53a830c111772b07176db49e2f4c3d9de3594e66c2f1d05a5f9405984a082f42df6
|
data/lib/rbbt/util/R/plot.rb
CHANGED
@@ -44,13 +44,16 @@ module R
|
|
44
44
|
end
|
45
45
|
|
46
46
|
TmpFile.with_file nil, true, :extension => 'svg' do |tmpfile|
|
47
|
+
|
47
48
|
data.R <<-EOF, sources, options
|
48
49
|
plot = { #{script} }
|
49
50
|
|
50
51
|
rbbt.SVG.save('#{tmpfile}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height})
|
51
52
|
data = NULL
|
52
53
|
EOF
|
53
|
-
|
54
|
+
|
55
|
+
Open.read(tmpfile).gsub(/(glyph\d+-\d+)/, '\1-' + File.basename(tmpfile))
|
56
|
+
|
54
57
|
end
|
55
58
|
else
|
56
59
|
|
@@ -68,7 +71,6 @@ module R
|
|
68
71
|
end
|
69
72
|
|
70
73
|
module PNG
|
71
|
-
|
72
74
|
def self.ggplotPNG(filename, data, script = nil, width = nil, height = nil, options = {})
|
73
75
|
width ||= 3
|
74
76
|
height ||= 3
|
@@ -107,6 +109,51 @@ module R
|
|
107
109
|
plot = { #{script} }
|
108
110
|
|
109
111
|
ggsave('#{filename}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height})
|
112
|
+
data = NULL
|
113
|
+
EOF
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.plot(filename, data, script = nil, width = nil, height = nil, options = {})
|
117
|
+
width ||= 3
|
118
|
+
height ||= 3
|
119
|
+
values = []
|
120
|
+
|
121
|
+
sources = [:plot, options[:source]].flatten.compact
|
122
|
+
|
123
|
+
data.each do |k,v|
|
124
|
+
v = Array === v ? v : [v]
|
125
|
+
next if v == "NA" or v.nil? or v.include? "NA" or v.include? nil
|
126
|
+
values = v
|
127
|
+
break
|
128
|
+
end
|
129
|
+
|
130
|
+
values = [values] unless Array === values
|
131
|
+
|
132
|
+
field_classes = values.collect do |v|
|
133
|
+
case v
|
134
|
+
when FalseClass, TrueClass
|
135
|
+
"'logical'"
|
136
|
+
when Fixnum, Float
|
137
|
+
"'numeric'"
|
138
|
+
when String
|
139
|
+
if v.strip =~ /^[-+]?[\d\.]+$/
|
140
|
+
"'numeric'"
|
141
|
+
else
|
142
|
+
"'character'"
|
143
|
+
end
|
144
|
+
when Symbol
|
145
|
+
"'factor'"
|
146
|
+
else
|
147
|
+
":NA"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
options[:R_open] ||= "colClasses=c('character'," + field_classes * ", " + ')' if field_classes.any?
|
152
|
+
|
153
|
+
data.R <<-EOF, :plot, options
|
154
|
+
png("#{ filename }", #{ width }, #{ height })
|
155
|
+
{ #{script} }
|
156
|
+
dev.off()
|
110
157
|
data = NULL
|
111
158
|
EOF
|
112
159
|
end
|
@@ -43,8 +43,14 @@ module Log
|
|
43
43
|
@mean_max = mean if mean > @mean_max
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
if mean.nil? or mean.to_i > 1
|
47
|
+
str = "#{ Log.color :blue, thr.to_i.to_s } per sec."
|
48
|
+
str << " #{ Log.color :yellow, mean.to_i.to_s } avg. #{Log.color :yellow, @mean_max.to_i.to_s} max." if @mean_max > 0
|
49
|
+
else
|
50
|
+
str = "#{ Log.color :blue, (1/thr).ceil.to_s } secs each"
|
51
|
+
str << " #{ Log.color :yellow, (1/mean).ceil.to_s } avg. #{Log.color :yellow, (1/@mean_max).ceil.to_s} min." if @mean_max > 0
|
52
|
+
end
|
53
|
+
|
48
54
|
str
|
49
55
|
end
|
50
56
|
|
@@ -41,7 +41,12 @@ module SOPT
|
|
41
41
|
info = {}
|
42
42
|
|
43
43
|
inputs = []
|
44
|
-
opt_str.
|
44
|
+
if opt_str.include? "\n"
|
45
|
+
re = /\n+/
|
46
|
+
else
|
47
|
+
re = /:/
|
48
|
+
end
|
49
|
+
opt_str.split(re).each do |entry|
|
45
50
|
entry.strip!
|
46
51
|
next if entry.empty?
|
47
52
|
names, _sep, description = entry.partition /\s+/
|
data/lib/rbbt/workflow/usage.rb
CHANGED
@@ -19,7 +19,9 @@ module Task
|
|
19
19
|
puts
|
20
20
|
end
|
21
21
|
|
22
|
+
selects = []
|
22
23
|
if inputs.any?
|
24
|
+
inputs.zip(input_types.values_at(*inputs)).select{|i,t| t.to_sym == :select and input_options[i][:select_options] }.each{|i,t| selects << [i, input_options[i][:select_options]] }
|
23
25
|
puts SOPT.input_doc(inputs, input_types, input_descriptions, input_defaults, true)
|
24
26
|
puts
|
25
27
|
end
|
@@ -30,6 +32,7 @@ module Task
|
|
30
32
|
seen = []
|
31
33
|
task_inputs = dep_inputs deps, workflow
|
32
34
|
task_inputs.each do |task,new_inputs|
|
35
|
+
task.inputs.zip(task.input_types.values_at(*task.inputs)).select{|i,t| t.to_sym == :select and task.input_options[i][:select_options] }.each{|i,t| selects << [i, task.input_options[i][:select_options]] }
|
33
36
|
puts " #{Log.color :yellow, task.name.to_s}:"
|
34
37
|
puts
|
35
38
|
puts SOPT.input_doc(new_inputs, task.input_types, task.input_descriptions, task.input_defaults, true)
|
@@ -39,6 +42,15 @@ module Task
|
|
39
42
|
|
40
43
|
puts Log.color(:magenta, "Returns: ") << Log.color(:blue, result_type.to_s) << "\n"
|
41
44
|
puts
|
45
|
+
|
46
|
+
if selects.any?
|
47
|
+
puts Log.color(:magenta, "Input options: ") << Log.color(:blue, result_type.to_s) << "\n"
|
48
|
+
puts
|
49
|
+
selects.each do |input,options|
|
50
|
+
puts Log.color(:blue, input.to_s + ": ") << Misc.format_paragraph(options.collect{|o| o.to_s} * ", ") << "\n"
|
51
|
+
puts
|
52
|
+
end
|
53
|
+
end
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
@@ -3,7 +3,36 @@
|
|
3
3
|
require 'rbbt-util'
|
4
4
|
require 'rbbt/util/simpleopt'
|
5
5
|
|
6
|
-
options = SOPT.get "-e--environment*:-p--port*:-s--server*:-f--finder:-R--Rserve_session*:-ho--host*:--views*"
|
6
|
+
#options = SOPT.get "-e--environment*:-p--port*:-s--server*:-f--finder:-R--Rserve_session*:-ho--host*:--views*"
|
7
|
+
|
8
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
9
|
+
|
10
|
+
options = SOPT.setup <<EOF
|
11
|
+
Description
|
12
|
+
|
13
|
+
$ rbbt command command [options] <filename.tsv|->
|
14
|
+
|
15
|
+
Use - to read from STDIN
|
16
|
+
|
17
|
+
-h--help Print this help
|
18
|
+
-e--environment* Execution environment: production or development
|
19
|
+
-ho--host* Host name
|
20
|
+
-p--port* TCP port
|
21
|
+
-s--server* Server type: thin, webrick, unicorn, etc
|
22
|
+
-f--finder Start server with finder functionality
|
23
|
+
-R--Rserve_session* Rserve session to use, otherwise start new one
|
24
|
+
--views* Directory with view templates
|
25
|
+
EOF
|
26
|
+
|
27
|
+
if options[:help]
|
28
|
+
if defined? rbbt_usage
|
29
|
+
rbbt_usage
|
30
|
+
else
|
31
|
+
puts SOPT.usage
|
32
|
+
end
|
33
|
+
exit 0
|
34
|
+
end
|
35
|
+
|
7
36
|
options[:Port] ||= options[:port]
|
8
37
|
options[:Host] ||= "0.0.0.0"
|
9
38
|
options[:Bind] ||= "0.0.0.0"
|
@@ -32,3 +61,14 @@ Misc.in_dir(app_dir) do
|
|
32
61
|
Rack::Server.start(options)
|
33
62
|
end
|
34
63
|
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
#!/usr/bin/env ruby
|
69
|
+
|
70
|
+
require 'rbbt-util'
|
71
|
+
require 'rbbt/util/simpleopt'
|
72
|
+
|
73
|
+
|
74
|
+
|
@@ -22,6 +22,7 @@ template = template.sub('.haml','')
|
|
22
22
|
|
23
23
|
ENV["RBBT_FINDER"] = "true" if options.include?(:finder)
|
24
24
|
ENV["RServe-session"] = options[:RServe_session]
|
25
|
+
ENV["RACK_ENV"] = options[:environment] if options.include?(:environment)
|
25
26
|
|
26
27
|
raise rbbt_usage unless template
|
27
28
|
|
@@ -45,7 +46,7 @@ app.helpers Sinatra::RbbtMiscHelpers
|
|
45
46
|
app.helpers Sinatra::RbbtToolHelper
|
46
47
|
|
47
48
|
app.get '/' do
|
48
|
-
template_render(template, @clean_params)
|
49
|
+
template_render(template, @clean_params, "Template cache", :cache_type => :asynchronous)
|
49
50
|
end
|
50
51
|
app.instance_eval Rbbt.etc['app.d/base.rb'].read
|
51
52
|
app.use Rack::Deflater
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.19.
|
4
|
+
version: 5.19.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|