qu-cmdwrapper 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06dc1b3e383256e44c2046d1d1ce4b5d28aabbd6
4
- data.tar.gz: 0d16b35f5e3360b91a89327adfa9b5c45f86271f
3
+ metadata.gz: 22a58735233b9a808b30cbb3ec75c989fba69561
4
+ data.tar.gz: 76c421d95079d6550aba99429fc53565ff3c2656
5
5
  SHA512:
6
- metadata.gz: 88c34ab33fdea27c7cb33f47d355ac902d25ef2bbe2a86a24ee1ad554d7dbeecf6e9dbb5b845bf6437c51d9816734c6ca6f7ce13a1c79ffdffd942d5ce7103a3
7
- data.tar.gz: a54a5d0fd186d1234962749f9c93b49ee83426e124ad3d17f1db583679d4a70e9a1fc1e80dec1021f28c52432e7711fab8be2c019d9aff82714a4eabcc6ebf0b
6
+ metadata.gz: 6ab46f612eb9dbd84a67198c84a6ec3951ec7ed555f261282e10605b39b05bc229377ac4fadf1424bdd9b8b5f131f886b097aaf23e1fdd35331655bec069a009
7
+ data.tar.gz: f0faea15335157a4766f6eed4a38ed18d398dcfbedcf7e768f63af41a061f4b73296944b7ca36936e3c6552b83498161422d6af934ff4c3b88e5808b960549a7
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'open3'
3
+ require "open3"
4
+
4
5
  require 'tempfile'
5
6
  require 'qu/utils'
6
7
 
@@ -14,16 +15,21 @@ module Qu
14
15
 
15
16
  module_function
16
17
 
17
- def primer3_core(p3_input_file)
18
- begin
19
- cmd = File.join(BIN_PATH, 'primer3_core')
20
- begin
21
- return system_quietly("#{cmd} #{File.realpath(p3_input_file)}")
22
- rescue ShellError
23
- return ''
24
- end
25
- rescue IOError
26
- $stderr.puts "Primer3 input file not exists: #{p3_input_file}"
18
+ def primer3_core(paras)
19
+ cmd = File.join(BIN_PATH, 'primer3_core')
20
+
21
+ lines = []
22
+ paras.each_pair do |key, value|
23
+ next if value.to_s.empty?
24
+ lines << "#{key}=#{value}"
25
+ end
26
+ lines << "="
27
+
28
+ stdout, stderr, status = Open3.capture3(cmd, stdin_data: lines.join("\n"))
29
+ if status.success?
30
+ return stdout
31
+ else
32
+ $stderr.puts stderr
27
33
  exit
28
34
  end
29
35
  end
@@ -34,10 +40,10 @@ module Qu
34
40
  if s2
35
41
  # tm = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -r -path #{THERMO_PATH} -a #{mode}`
36
42
  # out = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -path #{THERMO_PATH} -a #{mode}`
37
- out = system_quietly("#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -path #{THERMO_PATH} -a #{mode}")
43
+ out = exec_cmd("#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -path #{THERMO_PATH} -a #{mode}")
38
44
  else
39
45
  # out = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -path #{THERMO_PATH} -a HAIRPIN`
40
- out = system_quietly("#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -path #{THERMO_PATH} -a HAIRPIN")
46
+ out = exec_cmd("#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -path #{THERMO_PATH} -a HAIRPIN")
41
47
  end
42
48
 
43
49
  begin
@@ -139,9 +145,17 @@ module Qu
139
145
  return amp_seq_list
140
146
  end
141
147
 
142
- class ShellError < StandardError; end
148
+ def exec_cmd(cmd)
149
+ stdout, stderr, status = Open3.capture3(cmd)
150
+ if status.success?
151
+ return stdout
152
+ else
153
+ puts stderr
154
+ exit
155
+ end
156
+ end
143
157
 
144
- def system_quietly(*cmd)
158
+ def system_quietly_old(*cmd)
145
159
  exit_status=nil
146
160
  err=nil
147
161
  out=nil
@@ -1,5 +1,5 @@
1
1
  module Qu
2
2
  module Cmdwrapper
3
- VERSION = "1.0.5"
3
+ VERSION = "1.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qu-cmdwrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wubin Qu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-09 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: qu-utils
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.2.0
140
+ rubygems_version: 2.2.2
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: A wrapper for command-line tools