qu-cmdwrapper 1.0.0

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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +32 -0
  6. data/Rakefile +1 -0
  7. data/lib/qu/cmdwrapper.rb +10 -0
  8. data/lib/qu/cmdwrapper/cmd.rb +109 -0
  9. data/lib/qu/cmdwrapper/ext_bin/linux/32/faToTwoBit +0 -0
  10. data/lib/qu/cmdwrapper/ext_bin/linux/32/ntdpal +0 -0
  11. data/lib/qu/cmdwrapper/ext_bin/linux/32/ntthal +0 -0
  12. data/lib/qu/cmdwrapper/ext_bin/linux/32/oligotm +0 -0
  13. data/lib/qu/cmdwrapper/ext_bin/linux/32/primer3_core +0 -0
  14. data/lib/qu/cmdwrapper/ext_bin/linux/32/twoBitToFa +0 -0
  15. data/lib/qu/cmdwrapper/ext_bin/linux/64/faToTwoBit +0 -0
  16. data/lib/qu/cmdwrapper/ext_bin/linux/64/ntdpal +0 -0
  17. data/lib/qu/cmdwrapper/ext_bin/linux/64/ntthal +0 -0
  18. data/lib/qu/cmdwrapper/ext_bin/linux/64/oligotm +0 -0
  19. data/lib/qu/cmdwrapper/ext_bin/linux/64/primer3_core +0 -0
  20. data/lib/qu/cmdwrapper/ext_bin/linux/64/twoBitToFa +0 -0
  21. data/lib/qu/cmdwrapper/ext_bin/mac/32/faToTwoBit +0 -0
  22. data/lib/qu/cmdwrapper/ext_bin/mac/32/ntthal +0 -0
  23. data/lib/qu/cmdwrapper/ext_bin/mac/32/oligotm +0 -0
  24. data/lib/qu/cmdwrapper/ext_bin/mac/32/primer3_core +0 -0
  25. data/lib/qu/cmdwrapper/ext_bin/mac/32/twoBitToFa +0 -0
  26. data/lib/qu/cmdwrapper/ext_bin/mac/64/faToTwoBit +0 -0
  27. data/lib/qu/cmdwrapper/ext_bin/mac/64/ntthal +0 -0
  28. data/lib/qu/cmdwrapper/ext_bin/mac/64/oligotm +0 -0
  29. data/lib/qu/cmdwrapper/ext_bin/mac/64/primer3_core +0 -0
  30. data/lib/qu/cmdwrapper/ext_bin/mac/64/twoBitToFa +0 -0
  31. data/lib/qu/cmdwrapper/primer3_config/dangle.dh +128 -0
  32. data/lib/qu/cmdwrapper/primer3_config/dangle.ds +128 -0
  33. data/lib/qu/cmdwrapper/primer3_config/interpretations/dangle_i.dh +131 -0
  34. data/lib/qu/cmdwrapper/primer3_config/interpretations/dangle_i.ds +131 -0
  35. data/lib/qu/cmdwrapper/primer3_config/interpretations/loops_i.dh +34 -0
  36. data/lib/qu/cmdwrapper/primer3_config/interpretations/loops_i.ds +31 -0
  37. data/lib/qu/cmdwrapper/primer3_config/interpretations/stack_i.dh +257 -0
  38. data/lib/qu/cmdwrapper/primer3_config/interpretations/stack_i.ds +256 -0
  39. data/lib/qu/cmdwrapper/primer3_config/interpretations/stackmm_i_mm.dh +257 -0
  40. data/lib/qu/cmdwrapper/primer3_config/interpretations/stackmm_i_mm.ds +256 -0
  41. data/lib/qu/cmdwrapper/primer3_config/interpretations/tetraloop_i.dh +79 -0
  42. data/lib/qu/cmdwrapper/primer3_config/interpretations/tetraloop_i.ds +81 -0
  43. data/lib/qu/cmdwrapper/primer3_config/interpretations/triloop_i.dh +21 -0
  44. data/lib/qu/cmdwrapper/primer3_config/interpretations/triloop_i.ds +18 -0
  45. data/lib/qu/cmdwrapper/primer3_config/interpretations/tstack2_i.dh +256 -0
  46. data/lib/qu/cmdwrapper/primer3_config/interpretations/tstack2_i.ds +256 -0
  47. data/lib/qu/cmdwrapper/primer3_config/interpretations/tstack_i.dh +256 -0
  48. data/lib/qu/cmdwrapper/primer3_config/interpretations/tstack_i.ds +256 -0
  49. data/lib/qu/cmdwrapper/primer3_config/interpretations/tstack_tm_inf_i.dh +256 -0
  50. data/lib/qu/cmdwrapper/primer3_config/interpretations/tstack_tm_inf_i.ds +256 -0
  51. data/lib/qu/cmdwrapper/primer3_config/loops.dh +30 -0
  52. data/lib/qu/cmdwrapper/primer3_config/loops.ds +30 -0
  53. data/lib/qu/cmdwrapper/primer3_config/stack.dh +256 -0
  54. data/lib/qu/cmdwrapper/primer3_config/stack.ds +256 -0
  55. data/lib/qu/cmdwrapper/primer3_config/stackmm.dh +256 -0
  56. data/lib/qu/cmdwrapper/primer3_config/stackmm.ds +256 -0
  57. data/lib/qu/cmdwrapper/primer3_config/tetraloop.dh +77 -0
  58. data/lib/qu/cmdwrapper/primer3_config/tetraloop.ds +77 -0
  59. data/lib/qu/cmdwrapper/primer3_config/triloop.dh +16 -0
  60. data/lib/qu/cmdwrapper/primer3_config/triloop.ds +16 -0
  61. data/lib/qu/cmdwrapper/primer3_config/tstack.dh +256 -0
  62. data/lib/qu/cmdwrapper/primer3_config/tstack2.dh +256 -0
  63. data/lib/qu/cmdwrapper/primer3_config/tstack2.ds +256 -0
  64. data/lib/qu/cmdwrapper/primer3_config/tstack_tm_inf.ds +256 -0
  65. data/lib/qu/cmdwrapper/version.rb +5 -0
  66. data/qu-cmdwrapper.gemspec +24 -0
  67. metadata +137 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 015f571c68964fef5759d4e3e488648c18d4679d
4
+ data.tar.gz: 5603214e7b879d898338bcc121193e810e0eb224
5
+ SHA512:
6
+ metadata.gz: 38ad0cd4e1e7d05687159ba181b37246760294e6724f42a09468ed45e068911be733aaba7c31d54c10677a6a95b5ce0c403f0a18c1f5904a3167262b42b0addd
7
+ data.tar.gz: c129fd8025b9f8c58608a446a7aea40b801f8d44d49f6dc0ce5f7f9621efb7a5f151daecaf9712a184890cd7854d3994d789baef08148e4f67a8d71d8fbf4dea
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in qu-cmdwrapper.gemspec
4
+ gemspec
5
+ gem 'qu/utils'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Wubin Qu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Qu::Cmdwrapper
2
+
3
+ qu-cmdwrapper: A wrapper for command-line tools, mostly are bioinformatics related tools
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'qu-cmdwrapper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install qu-cmdwrapper
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ # retrieve sequence from two bit formated database with twoBitToFa command
23
+ amp_seq_list = Cmdwrapper::twoBitToFa(fh.path, db + Qu::Mfeindex::DB_2BIT)
24
+ ```
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ require 'qu/utils'
2
+
3
+ require_relative "cmdwrapper/cmd"
4
+ require_relative "cmdwrapper/version"
5
+
6
+ module Qu
7
+ module Cmdwrapper
8
+ # Your code goes here...
9
+ end
10
+ end
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'open3'
4
+ require 'tempfile'
5
+
6
+ module Qu
7
+ module Cmdwrapper
8
+ BIN_ROOT = File.join(__dir__, 'ext_bin')
9
+ BIN_PATH = File.join(BIN_ROOT, Utils::platform_os, Utils::platform_bit.to_s)
10
+
11
+
12
+ THERMO_PATH = File.join(__dir__, 'primer3_config') + '/'
13
+
14
+ module_function
15
+
16
+ def primer3_core(p3_input_file)
17
+ begin
18
+ cmd = File.join(BIN_PATH, 'primer3_core')
19
+ begin
20
+ return system_quietly("#{cmd} #{File.realpath(p3_input_file)}")
21
+ rescue ShellError
22
+ return ''
23
+ end
24
+ rescue IOError
25
+ $stderr.puts "Primer3 input file not exists: #{p3_input_file}"
26
+ exit
27
+ end
28
+ end
29
+
30
+ def ntthal(s1, s2=nil, mv=50, dv=1.5, d=50, n=0.25, mode='ANY')
31
+ cmd = File.join(BIN_PATH, 'ntthal')
32
+ if s2
33
+ tm = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -r -path #{THERMO_PATH} -a #{mode}`
34
+ else
35
+ tm = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -r -path #{THERMO_PATH} -a HAIRPIN`
36
+ end
37
+
38
+ return tm.to_f
39
+ end
40
+
41
+ def faToTwoBit(fasta, twobit)
42
+ cmd = File.join(BIN_PATH, 'faToTwoBit')
43
+ `#{cmd} #{fasta} #{twobit}`
44
+ end
45
+
46
+ def twoBitToFa(seq_list_file, twobit_file)
47
+ cmd = File.join(BIN_PATH, 'twoBitToFa')
48
+
49
+ records = []
50
+ begin
51
+ out_file = Tempfile.new('twobit')
52
+ `#{cmd} -seqList=#{seq_list_file} #{twobit_file} #{out_file.path}`
53
+ out_file.rewind
54
+
55
+ Bio::FlatFile.new(Bio::FastaFormat, out_file).each do |record|
56
+ records << record.naseq.seq
57
+ end
58
+ ensure
59
+ out_file.close
60
+ out_file.unlink
61
+ end
62
+
63
+ return records
64
+ end
65
+
66
+ def get_binding_seq_list(binding_range_list, twobit_file)
67
+ amp_seq_list = []
68
+
69
+ return amp_seq_list if binding_range_list.empty?
70
+
71
+ begin
72
+ fh = Tempfile.new('binding_range_list')
73
+ fh.write(binding_range_list.join("\n"))
74
+ fh.close
75
+ amp_seq_list = twoBitToFa(fh.path, twobit_file)
76
+ ensure
77
+ fh.unlink
78
+ end
79
+ return amp_seq_list
80
+ end
81
+
82
+ class ShellError < StandardError; end
83
+
84
+ def system_quietly(*cmd)
85
+ exit_status=nil
86
+ err=nil
87
+ out=nil
88
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thread|
89
+ err = stderr.gets(nil)
90
+ out = stdout.gets(nil)
91
+ [stdin, stdout, stderr].each{|stream| stream.send('close')}
92
+ exit_status = wait_thread.value
93
+ end
94
+ if exit_status.to_i > 0
95
+ err = err.chomp if err
96
+ raise ShellError, err
97
+ elsif out
98
+ return out.chomp
99
+ else
100
+ return true
101
+ end
102
+ end
103
+
104
+ end
105
+ end
106
+
107
+ if $0 == __FILE__
108
+ puts Qu::Cmdwrapper::BIN_PATH
109
+ end
@@ -0,0 +1,128 @@
1
+ 0
2
+ 0
3
+ 0
4
+ 0
5
+ 0
6
+ 0
7
+ 0
8
+ 0
9
+ 0
10
+ 0
11
+ 0
12
+ 0
13
+ -500
14
+ 4700
15
+ -4100
16
+ -3800
17
+ 0
18
+ 0
19
+ 0
20
+ 0
21
+ 0
22
+ 0
23
+ 0
24
+ 0
25
+ -5900
26
+ -2600
27
+ -3200
28
+ -5200
29
+ 0
30
+ 0
31
+ 0
32
+ 0
33
+ 0
34
+ 0
35
+ 0
36
+ 0
37
+ -2100
38
+ -200
39
+ -3900
40
+ -4400
41
+ 0
42
+ 0
43
+ 0
44
+ 0
45
+ 0
46
+ 0
47
+ 0
48
+ 0
49
+ -700
50
+ 4400
51
+ -1600
52
+ 2900
53
+ 0
54
+ 0
55
+ 0
56
+ 0
57
+ 0
58
+ 0
59
+ 0
60
+ 0
61
+ 0
62
+ 0
63
+ 0
64
+ 0
65
+ 0
66
+ 0
67
+ 0
68
+ 0
69
+ 0
70
+ 0
71
+ 0
72
+ 0
73
+ 0
74
+ 0
75
+ 0
76
+ 0
77
+ -2900
78
+ -4100
79
+ -4200
80
+ -200
81
+ 0
82
+ 0
83
+ 0
84
+ 0
85
+ 0
86
+ 0
87
+ 0
88
+ 0
89
+ -3700
90
+ -4000
91
+ -3900
92
+ -4900
93
+ 0
94
+ 0
95
+ 0
96
+ 0
97
+ 0
98
+ 0
99
+ 0
100
+ 0
101
+ -6300
102
+ -4400
103
+ -5100
104
+ -4000
105
+ 0
106
+ 0
107
+ 0
108
+ 0
109
+ 0
110
+ 0
111
+ 0
112
+ 0
113
+ 200
114
+ 600
115
+ -1100
116
+ -6900
117
+ 0
118
+ 0
119
+ 0
120
+ 0
121
+ 0
122
+ 0
123
+ 0
124
+ 0
125
+ 0
126
+ 0
127
+ 0
128
+ 0
@@ -0,0 +1,128 @@
1
+ inf
2
+ inf
3
+ inf
4
+ inf
5
+ inf
6
+ inf
7
+ inf
8
+ inf
9
+ inf
10
+ inf
11
+ inf
12
+ inf
13
+ -1.1
14
+ 14.2
15
+ -13.1
16
+ -12.6
17
+ inf
18
+ inf
19
+ inf
20
+ inf
21
+ inf
22
+ inf
23
+ inf
24
+ inf
25
+ -16.5
26
+ -7.4
27
+ -10.4
28
+ -15
29
+ inf
30
+ inf
31
+ inf
32
+ inf
33
+ inf
34
+ inf
35
+ inf
36
+ inf
37
+ -3.9
38
+ -0.1
39
+ -11.2
40
+ -13.1
41
+ inf
42
+ inf
43
+ inf
44
+ inf
45
+ inf
46
+ inf
47
+ inf
48
+ inf
49
+ -0.8
50
+ 14.9
51
+ -3.6
52
+ 10.4
53
+ inf
54
+ inf
55
+ inf
56
+ inf
57
+ inf
58
+ inf
59
+ inf
60
+ inf
61
+ inf
62
+ inf
63
+ inf
64
+ inf
65
+ inf
66
+ inf
67
+ inf
68
+ inf
69
+ inf
70
+ inf
71
+ inf
72
+ inf
73
+ inf
74
+ inf
75
+ inf
76
+ inf
77
+ -7.6
78
+ -13
79
+ -15
80
+ -0.5
81
+ inf
82
+ inf
83
+ inf
84
+ inf
85
+ inf
86
+ inf
87
+ inf
88
+ inf
89
+ -10
90
+ -11.9
91
+ -10.9
92
+ -13.8
93
+ inf
94
+ inf
95
+ inf
96
+ inf
97
+ inf
98
+ inf
99
+ inf
100
+ inf
101
+ -17.1
102
+ -12.6
103
+ -14
104
+ -10.9
105
+ inf
106
+ inf
107
+ inf
108
+ inf
109
+ inf
110
+ inf
111
+ inf
112
+ inf
113
+ 2.3
114
+ 3.3
115
+ -1.6
116
+ -20
117
+ inf
118
+ inf
119
+ inf
120
+ inf
121
+ inf
122
+ inf
123
+ inf
124
+ inf
125
+ inf
126
+ inf
127
+ inf
128
+ inf