qu-cmdwrapper 1.0.1 → 1.0.5

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: b2e8254f5abeab1607488192e8b8a0fd304fbbf3
4
- data.tar.gz: ba835fd2868daff6583ed5743398c5e31eaa0254
3
+ metadata.gz: 06dc1b3e383256e44c2046d1d1ce4b5d28aabbd6
4
+ data.tar.gz: 0d16b35f5e3360b91a89327adfa9b5c45f86271f
5
5
  SHA512:
6
- metadata.gz: 6ad5513b2402fabbc047f2ab1d5b6bb066834d61776e85edd89d585559d6769d566a107f4e84195604fd691654987ceecfd7c00a7ec926560a7401b9c6632d96
7
- data.tar.gz: 297c321d028b6275fb82834cf0f81c9989366bd514a8dddc70399996789e51e71fee53010ce4fce48aed7d817ce006a202c32c61e8e26b35d22ea147e25f52c1
6
+ metadata.gz: 88c34ab33fdea27c7cb33f47d355ac902d25ef2bbe2a86a24ee1ad554d7dbeecf6e9dbb5b845bf6437c51d9816734c6ca6f7ce13a1c79ffdffd942d5ce7103a3
7
+ data.tar.gz: a54a5d0fd186d1234962749f9c93b49ee83426e124ad3d17f1db583679d4a70e9a1fc1e80dec1021f28c52432e7711fab8be2c019d9aff82714a4eabcc6ebf0b
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in qu-cmdwrapper.gemspec
4
4
  gemspec
5
- gem 'qu/utils'
5
+ gem 'qu-utils'
6
+ gem 'rspec'
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'open3'
4
4
  require 'tempfile'
5
+ require 'qu/utils'
5
6
 
6
7
  module Qu
7
8
  module Cmdwrapper
@@ -27,15 +28,74 @@ module Qu
27
28
  end
28
29
  end
29
30
 
30
- def ntthal(s1, s2=nil, mv=50, dv=1.5, d=50, n=0.25, mode='ANY')
31
+ def ntthal(s1:, s2: nil, mv: 50, dv: 1.5, d: 50, n: 0.25, mode: 'ANY', tm_only: false)
31
32
  cmd = File.join(BIN_PATH, 'ntthal')
33
+
32
34
  if s2
33
- tm = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -r -path #{THERMO_PATH} -a #{mode}`
35
+ # tm = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -s2 #{s2} -r -path #{THERMO_PATH} -a #{mode}`
36
+ # 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}")
34
38
  else
35
- tm = `#{cmd} -mv #{mv} -dv #{dv} -d #{d} -n #{n} -s1 #{s1} -r -path #{THERMO_PATH} -a HAIRPIN`
39
+ # 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")
41
+ end
42
+
43
+ begin
44
+ lines = out.lines
45
+
46
+ tm = nil
47
+ dg = nil
48
+ if lines.shift =~ /.*dG\s+=\s+(-?\d+\.?\d+)\s+t\s+=\s+(\d+\.?\d+)/
49
+ dg = $1.to_f / 1000
50
+ tm = $2.to_f
51
+ end
52
+
53
+ if tm_only
54
+ return tm
55
+ end
56
+
57
+ lines = lines.map {|line| line.split("\t")[1].chomp}
58
+
59
+ if s2
60
+ seq_1 = ''
61
+ align = ''
62
+ seq_2 = ''
63
+ # puts lines
64
+ (0...lines[0].size).each do |index|
65
+ if lines[1][index] != ' '
66
+ seq_1 << lines[1][index]
67
+ seq_2 << lines[2][index]
68
+ align << '|'
69
+ else
70
+ align << ' '
71
+ seq_1 << lines[0][index]
72
+ seq_2 << lines[3][index]
73
+ end
74
+ end
75
+
76
+ seq_1.sub!(/\-+$/, '')
77
+ return tm, dg, seq_1, align, seq_2
78
+
79
+ else
80
+ align = lines[0]
81
+ seq = lines[1]
82
+
83
+ return tm, dg, seq, align
84
+ end
85
+
86
+ rescue Exception => e
87
+
88
+ if tm_only
89
+ return 0
90
+ else
91
+ if s2
92
+ return nil, nil, '', '', ''
93
+ else
94
+ return nil, nil, '', ''
95
+ end
96
+ end
36
97
  end
37
98
 
38
- return tm.to_f
39
99
  end
40
100
 
41
101
  def faToTwoBit(fasta, twobit)
@@ -105,5 +165,14 @@ module Qu
105
165
  end
106
166
 
107
167
  if $0 == __FILE__
108
- puts Qu::Cmdwrapper::BIN_PATH
168
+
169
+ p1 = 'tccctcctctacaactACCTCGC'
170
+ p2 = 'TTGGTCGAGGGGAACAGCAGGT'
171
+ p3 = 'TGTGTGCAGCTGCTGGTGGC'
172
+ # p1 = 'act'
173
+ # p2 = 'ctt'
174
+ puts Qu::Cmdwrapper::ntthal(s1: p1, s2: p2, tm_only: false)
175
+ puts Qu::Cmdwrapper::ntthal(s1: p1)
176
+ puts Qu::Cmdwrapper::ntthal(s1: p2)
177
+ puts Qu::Cmdwrapper::ntthal(s1: p3)
109
178
  end
@@ -1,5 +1,5 @@
1
1
  module Qu
2
2
  module Cmdwrapper
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency 'qu-utils', '~> 1.0'
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rspec"
24
25
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ describe Qu::Cmdwrapper do
3
+ it 'should return a list' do
4
+ p1 = 'tccctcctctacaactACCTCGC'
5
+ p2 = 'TTGGTCGAGGGGAACAGCAGGT'
6
+ p3 = 'TGTGTGCAGCTGCTGGTGGC'
7
+ # p1 = 'act'
8
+ # p2 = 'ctt'
9
+ # p Qu::Cmdwrapper::ntthal(s1: p1, s2: p2, tm_only: true)
10
+ # p Qu::Cmdwrapper::ntthal(s1: p1)
11
+ # p Qu::Cmdwrapper::ntthal(s1: p2)
12
+ Qu::Cmdwrapper::ntthal(s1: p3)[-1].should eq '------//-/----\\-\\\\--'
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'qu/cmdwrapper' # and any other gems you need
5
+ require 'qu/utils' # and any other gems you need
6
+
7
+ RSpec.configure do |config|
8
+ # some (optional) config here
9
+ 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.1
4
+ version: 1.0.5
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-04-30 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: qu-utils
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: A wrapper for command-line tools, mostly are bioinformatics related tools
42
56
  email:
43
57
  - quwubin@gmail.com
@@ -46,6 +60,7 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
63
+ - ".rspec"
49
64
  - Gemfile
50
65
  - LICENSE.txt
51
66
  - README.md
@@ -100,6 +115,8 @@ files:
100
115
  - lib/qu/cmdwrapper/primer3_config/tstack_tm_inf.ds
101
116
  - lib/qu/cmdwrapper/version.rb
102
117
  - qu-cmdwrapper.gemspec
118
+ - spec/qu_cmdwrapper_spec.rb
119
+ - spec/spec_helper.rb
103
120
  homepage: https://github.com/quwubin/qu-cmdwrapper
104
121
  licenses:
105
122
  - MIT
@@ -124,4 +141,6 @@ rubygems_version: 2.2.0
124
141
  signing_key:
125
142
  specification_version: 4
126
143
  summary: A wrapper for command-line tools
127
- test_files: []
144
+ test_files:
145
+ - spec/qu_cmdwrapper_spec.rb
146
+ - spec/spec_helper.rb