rbbt-util 5.21.81 → 5.21.83

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 766488431c24999dc06dbf6b06f7541e1ce0c0da
4
- data.tar.gz: ef2edb51a1ea3d2591ba43aa3350162a043724ac
3
+ metadata.gz: 9a9203165804c6c7d43397d02aada2d6b9c99649
4
+ data.tar.gz: f8e2c8ed913e3a01cb27bbc8d2d9751a213ca78e
5
5
  SHA512:
6
- metadata.gz: b902a43f746f2c0eb1b0340b320c149487c8bab0edaff78d21950296e0565955ca342a1624e0d1f38a2065dbe6a9f7e2ccf578dfe6f2043a531154628be35312
7
- data.tar.gz: 9cb934bec141ad0870e3644d25bf5c31f19ea26427ce1a74f1991fcc56e0ea7fac3961b2f455ddcb838dac74ad3549f8155ecb5b5fd2576d7139e552624f702a
6
+ metadata.gz: 54ab5caf41e7e0b8e3b6d98cd0016f043161e137c3cf78596cc94239797a41d09fdb23fc41d0851e42c250c0422560c850b2c6b18679ad7cb859cfc2441bd20c
7
+ data.tar.gz: 0057b7bf24c1506791b26b071ea94f5366f242b405464a6fc24c3c4e0307650fbb71fee4c3534f68c383a5bb8b942fc22db9cad929834df63937207a7b5630d3
@@ -53,7 +53,7 @@ class WorkflowRESTClient
53
53
  end
54
54
 
55
55
  return @result if no_load == :stream
56
- no_load ? path + '?_format=raw' : @result
56
+ no_load ? Misc.add_GET_param(path, "_format", "raw") : @result
57
57
  end
58
58
 
59
59
 
@@ -220,7 +220,7 @@ class WorkflowRESTClient
220
220
 
221
221
  def path
222
222
  if @url
223
- @url + '?_format=raw'
223
+ Misc.add_GET_param(@url, "_format", "raw")
224
224
  else
225
225
  [base_url, task, @base_name + '-' + Misc.fingerprint(inputs)] * "/"
226
226
  end
@@ -116,7 +116,10 @@ module TSV
116
116
  f.puts "#" + header * "\t"
117
117
  end
118
118
 
119
- rows.each do |row| f.puts row * "\t" end
119
+ rows.each do |row|
120
+ values = row.collect{|c| c.respond_to?(:value) ? c.value : c }
121
+ f.puts values * "\t"
122
+ end
120
123
  end
121
124
 
122
125
  TSV.open(filename, options)
data/lib/rbbt/util/R.rb CHANGED
@@ -121,7 +121,7 @@ source('#{UTIL}');
121
121
  when Array
122
122
  "c(#{object.collect{|e| ruby2R(e) } * ", "})"
123
123
  when Hash
124
- object.collect{|k,v| [k, ruby2R(v)] * "="} * ", "
124
+ "list(" << object.collect{|k,v| [k, ruby2R(v)] * "="} * ", " << ")"
125
125
  else
126
126
  raise "Type of object not known: #{ object.inspect }"
127
127
  end
@@ -352,8 +352,8 @@ module Misc
352
352
  pos2 = f2.pos
353
353
 
354
354
  sline2, schr2, sstart2, seend2, srest2 = line2, chr2, start2, eend2, rest2
355
- while chr1 == chr2 and ((start1 <= eend2 and eend1 >= start2))
356
- out.puts line1 + "\t" + line2
355
+ while chr1 == chr2 and eend1 >= start2
356
+ out.puts line1 + "\t" + line2 if start1 <= eend2
357
357
  if f2.eof?
358
358
  chr2 = 'next2'
359
359
  else
@@ -75,6 +75,14 @@ module Misc
75
75
  }.compact * "&"
76
76
  end
77
77
 
78
+ def self.add_GET_param(url, param, value)
79
+ clean_url, param_str = url.split("?")
80
+ hash = param_str.nil? ? {} : self.GET_params2hash(param_str)
81
+ IndiferentHash.setup hash
82
+ hash[param] = value
83
+ clean_url << "?" << hash2GET_params(hash)
84
+ end
85
+
78
86
  def self.hash_to_html_tag_attributes(hash)
79
87
  return "" if hash.nil? or hash.empty?
80
88
  hash.collect{|k,v|
@@ -656,8 +656,8 @@ module Misc
656
656
  end
657
657
  end
658
658
 
659
- def self.sort_mutation_stream(stream)
660
- CMD.cmd('grep ":" | sort -u | sed "s/^M:/MT:/" | env LC_ALL=C sort -k1,1 -k2,2n -k3,3n -t:', :in => stream, :pipe => true, :no_fail => true)
659
+ def self.sort_mutation_stream(stream, sep=":")
660
+ CMD.cmd("grep '#{sep}' | sort -u | sed 's/^M:/MT:/' | env LC_ALL=C sort -k1,1 -k2,2n -k3,3n -t'#{sep}'", :in => stream, :pipe => true, :no_fail => true)
661
661
  end
662
662
 
663
663
 
@@ -208,5 +208,14 @@ module NamedArray
208
208
  end * "\n"
209
209
  end
210
210
 
211
+ def to_hash
212
+ hash = {}
213
+ self.fields.zip(self) do |field,value|
214
+ hash[field] = value
215
+ end
216
+ IndiferentHash.setup hash
217
+ hash
218
+ end
219
+
211
220
  end
212
221
 
@@ -689,83 +689,103 @@ module Workflow
689
689
  }.tap{|h| IndiferentHash.setup(h)}
690
690
  end
691
691
 
692
- def real_dependencies(task, jobname, inputs, dependencies)
693
- real_dependencies = []
694
- path_deps = {}
695
- dependencies.each do |dependency|
696
- real_dep = case dependency
697
- when Array
698
- workflow, dep_task, options = dependency
699
-
700
- _inputs = IndiferentHash.setup(inputs.dup)
701
- compute = options[:compute] if options
702
- options.each{|i,v|
703
- next if i == :compute or i == "compute"
704
- case v
705
- when :compute
706
- compute = v
707
- when Symbol
708
- all_d = (real_dependencies + real_dependencies.collect{|d| d.rec_dependencies} ).flatten.compact.uniq
709
- rec_dependency = all_d.select{|d| d.task_name.to_sym == v }.first
710
-
711
- if rec_dependency.nil?
712
- if inputs.include? v
713
- _inputs[i] = _inputs.delete(v)
714
- else
715
- _inputs[i] = v unless _inputs.include? i
716
- end
717
- else
718
- input_options = workflow.task_info(dep_task)[:input_options][i] || {}
719
- if input_options[:stream] or true
720
- #rec_dependency.run(true).grace unless rec_dependency.done? or rec_dependency.running?
721
- _inputs[i] = rec_dependency
722
- else
723
- rec_dependency.abort if rec_dependency.streaming? and not rec_dependency.running?
724
- rec_dependency.clean if rec_dependency.error? or rec_dependency.aborted?
725
- if rec_dependency.streaming? and rec_dependency.running?
726
- _inputs[i] = rec_dependency.join.load
727
- else
728
- rec_dependency.run(true)
729
- rec_dependency.join
730
- _inputs[i] = rec_dependency.load
731
- end
732
- end
733
- end
692
+ def assign_dep_inputs(_inputs, options, all_d, task_info)
693
+ options.each{|i,v|
694
+ next if i == :compute or i == "compute"
695
+ case v
696
+ when :compute
697
+ compute = v
698
+ when Symbol
699
+ rec_dependency = all_d.select{|d| d.task_name.to_sym == v }.first
700
+
701
+ if rec_dependency.nil?
702
+ if inputs.include? v
703
+ _inputs[i] = _inputs.delete(v)
734
704
  else
735
- _inputs[i] = v
705
+ _inputs[i] = v unless _inputs.include? i
736
706
  end
737
- } if options
738
-
739
- job = workflow.job(dep_task, jobname, _inputs)
740
- ComputeDependency.setup(job, compute) if compute
741
- job
742
- when Step
743
- dependency
744
- when Symbol
745
- _inputs = IndiferentHash.setup(inputs.dup)
746
- job(dependency, jobname, _inputs)
747
- when Proc
748
- _inputs = IndiferentHash.setup(inputs.dup)
749
- dep = dependency.call jobname, _inputs, real_dependencies
750
-
751
- if DependencyBlock === dependency
752
- orig_dep = dependency.dependency
753
- if Hash === orig_dep.last
754
- options = orig_dep.last
755
- compute = options[:compute]
756
-
757
- if Array === dep
758
- dep.each{|d| ComputeDependency.setup(d, compute)}
759
- elsif dep
760
- ComputeDependency.setup(dep, compute)
761
- end if compute
707
+ else
708
+ input_options = task_info[:input_options][i] || {}
709
+ if input_options[:stream] or true
710
+ #rec_dependency.run(true).grace unless rec_dependency.done? or rec_dependency.running?
711
+ _inputs[i] = rec_dependency
712
+ else
713
+ rec_dependency.abort if rec_dependency.streaming? and not rec_dependency.running?
714
+ rec_dependency.clean if rec_dependency.error? or rec_dependency.aborted?
715
+ if rec_dependency.streaming? and rec_dependency.running?
716
+ _inputs[i] = rec_dependency.join.load
717
+ else
718
+ rec_dependency.run(true)
719
+ rec_dependency.join
720
+ _inputs[i] = rec_dependency.load
721
+ end
762
722
  end
763
723
  end
764
-
765
- dep
766
724
  else
767
- raise "Dependency for #{task.name} not understood: #{Misc.fingerprint dependency}"
725
+ _inputs[i] = v
768
726
  end
727
+ } if options
728
+
729
+ _inputs
730
+ end
731
+
732
+ def real_dependencies(task, jobname, inputs, dependencies)
733
+ real_dependencies = []
734
+ path_deps = {}
735
+ dependencies.each do |dependency|
736
+ _inputs = IndiferentHash.setup(inputs.dup)
737
+ real_dep = case dependency
738
+ when Array
739
+ workflow, dep_task, options = dependency
740
+
741
+ compute = options[:compute] if options
742
+
743
+ all_d = (real_dependencies + real_dependencies.collect{|d| d.rec_dependencies} ).flatten.compact.uniq
744
+
745
+ _inputs = assign_dep_inputs(_inputs, options, all_d, workflow.task_info(dep_task))
746
+
747
+ job = workflow.job(dep_task, jobname, _inputs)
748
+ ComputeDependency.setup(job, compute) if compute
749
+ job
750
+ when Step
751
+ dependency
752
+ when Symbol
753
+ job(dependency, jobname, _inputs)
754
+ when Proc
755
+ if DependencyBlock === dependency
756
+ orig_dep = dependency.dependency
757
+ if Hash === orig_dep.last
758
+ options = orig_dep.last
759
+ compute = options[:compute]
760
+ else
761
+ options = {}
762
+ compute = nil
763
+ end
764
+
765
+ dep = dependency.call jobname, options.merge(_inputs), real_dependencies
766
+
767
+ dep = [dep] unless Array === dep
768
+
769
+ new_=[]
770
+ dep.each{|d|
771
+ inputs = assign_dep_inputs({}, options.merge(d[:inputs]), real_dependencies, d[:workflow].task_info(d[:task]))
772
+ d = d[:workflow].job(d[:task], d[:jobname], inputs) if Hash === d
773
+ ComputeDependency.setup(d, compute) if compute
774
+ new_ << d
775
+ }
776
+ dep = new_
777
+ else
778
+ dep = dependency.call jobname, _inputs, real_dependencies
779
+ if Hash === dep
780
+ inputs = assign_dep_inputs({}, dep[:inputs], real_dependencies, dep[:workflow].task_info(dep[:task]))
781
+ dep = dep[:workflow].job(dep[:task], dep[:jobname], inputs)
782
+ end
783
+ end
784
+
785
+ dep
786
+ else
787
+ raise "Dependency for #{task.name} not understood: #{Misc.fingerprint dependency}"
788
+ end
769
789
 
770
790
  real_dependencies << real_dep
771
791
  end
@@ -46,7 +46,7 @@ module Task
46
46
  if selects.any?
47
47
  puts Log.color(:magenta, "Input select options")
48
48
  puts
49
- selects.each do |input,options|
49
+ selects.collect{|p| p}.uniq.each do |input,options|
50
50
  puts Log.color(:blue, input.to_s + ": ") << Misc.format_paragraph(options.collect{|o| o.to_s} * ", ") << "\n"
51
51
  puts
52
52
  end
data/share/Rlib/util.R CHANGED
@@ -621,3 +621,8 @@ rbbt.plot.text_scatter <- function(formula, data) {
621
621
  plot(formula, data=data, cex = 0)
622
622
  text(formula, data=data, cex = 0.6, labels=rownames(data))
623
623
  }
624
+
625
+ install.bioc <-function(pkg){
626
+ source("http://bioconductor.org/biocLite.R")
627
+ biocLite(pkg)
628
+ }
@@ -171,7 +171,7 @@ build(){
171
171
 
172
172
  versioned?(){
173
173
  local name="$1"
174
- echo $name | grep ':' &>/dev/null
174
+ [[ $name =~ : ]]
175
175
  }
176
176
 
177
177
  opt_dir(){
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.21.81
4
+ version: 5.21.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-11 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake