bio-rocker 1.3.1 → 1.4.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.
- checksums.yaml +4 -4
- data/bin/ROCker +6 -0
- data/lib/rocker.rb +65 -65
- data/lib/rocker/step/filter.rb +23 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cf59c3a66eb06806a91fd768c0ec6202149b7b4b16090bc7be19e96b073fcd3
|
4
|
+
data.tar.gz: 513a5c4de89965d9a852b87ce5b0d7d3da9fb9246471e919fe337dc571cdbe3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95cd32ec66b65516c6253ea5396354b621ac05a945f4a743fefafb9eb9b9b6df67eb0badc93a8dd7329643a7ecadc32a15c3aedd3ef683ef57cfe51a6ddbe304
|
7
|
+
data.tar.gz: 8528c3c5f10b4b5a8a895c51de9368aeafef413edf2931ab9ac5d5f4d92f211f2289636a9b6efbb98573ac305afacf1a127ed27482639f1e3a14496699eb9578
|
data/bin/ROCker
CHANGED
@@ -238,6 +238,9 @@ opts = OptionParser.new do |opt|
|
|
238
238
|
"kept."){ |v| o[:qblast]=v }
|
239
239
|
opt.on('-L', '--length-correction',
|
240
240
|
'Apply read-length correction to bit scores.'){ |v| o[:lencorr] = v }
|
241
|
+
opt.on('-M', '--max-length-correction FLOAT',
|
242
|
+
'Maximum length correction, as a read length fraction.'
|
243
|
+
){ |v| o[:lencorr_max] = v.to_f }
|
241
244
|
|
242
245
|
opt.separator ""
|
243
246
|
opt.separator "+ EXTERNAL SOFTWARE OPTIONS"
|
@@ -276,6 +279,9 @@ opts = OptionParser.new do |opt|
|
|
276
279
|
opt.on('-L', '--length-correction PATH',
|
277
280
|
'Path to the query reads, used to apply read-length correction to ' +
|
278
281
|
'bit scores.'){ |v| o[:lencorr] = v }
|
282
|
+
opt.on('-M', '--max-length-correction FLOAT',
|
283
|
+
'Maximum length correction, as a read length fraction.'
|
284
|
+
){ |v| o[:lencorr_max] = v.to_f }
|
279
285
|
when "plot"
|
280
286
|
opt.separator "+ PLOTTING ARGUMENTS"
|
281
287
|
opt.on("-k", "--rocker PATH",
|
data/lib/rocker.rb
CHANGED
@@ -4,83 +4,83 @@
|
|
4
4
|
# @license Artistic-2.0
|
5
5
|
#
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require 'rocker/blasthit'
|
8
|
+
require 'rocker/rocdata'
|
9
9
|
|
10
10
|
class ROCker
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
11
|
+
#================================[ Class ]
|
12
|
+
@@VERSION = '1.4.0'
|
13
|
+
@@CITATION = [
|
14
|
+
'Orellana, Rodriguez-R & Konstantinidis, 2016. DOI:10.1093/nar/gkw900.',
|
15
|
+
'ROCker: accurate detection and quantification of target genes in',
|
16
|
+
'short-read metagenomic data sets by modeling sliding-window bitscores.',
|
17
|
+
'Nucleic Acids Research 45(3):e14.']
|
18
|
+
@@DATE = '2019-07-20'
|
19
|
+
@@DEFAULTS = {
|
20
|
+
# General
|
21
|
+
q: false, r: 'R', nucl: false, debug: false, thr: 2, search: :blast,
|
22
|
+
# External software
|
23
|
+
searchbins: '',
|
24
|
+
searchcmd: {
|
25
|
+
blast: '%1$s%2$s -query "%3$s" -db "%4$s" -out "%5$s" ' +
|
26
|
+
'-num_threads %6$d -outfmt 6 -max_target_seqs 1',
|
27
|
+
diamond: '%1$sdiamond %2$s -q "%3$s" -d "%4$s" -a "%5$s.daa" -p %6$d' +
|
28
|
+
' -k 1 --min-score 20 --sensitive && %1$sdiamond view -a "%5$s"' +
|
29
|
+
' -o "%5$s"'},
|
30
|
+
makedbcmd: {
|
31
|
+
blast: '%1$smakeblastdb -dbtype %2$s -in "%3$s" -out "%4$s"',
|
32
|
+
diamond: '%1$sdiamond makedb --in "%3$s" -d "%4$s"'}
|
33
|
+
}
|
34
|
+
def self.defaults() @@DEFAULTS ; end
|
35
|
+
def self.default(k) @@DEFAULTS[k] ; end
|
36
|
+
def self.VERSION; @@VERSION ; end
|
37
|
+
def self.DATE; @@DATE ; end
|
38
|
+
def self.CITATION(j = ' ') @@CITATION.join(j) ; end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
#================================[ Instance ]
|
41
|
+
attr_reader :o
|
42
|
+
def initialize(opts)
|
43
|
+
@o = ROCker.defaults
|
44
|
+
opts.each{ |k,v| @o[k] = v }
|
45
|
+
RInterface.R_BIN = opts[:r] unless opts[:r].nil?
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
48
|
+
#================================[ Utilities ]
|
49
|
+
def blast2table(blast_f, table_f, aln, minscore)
|
50
|
+
ifh = File.open(blast_f, 'r')
|
51
|
+
ofh = File.open(table_f, 'w')
|
52
|
+
while ln = ifh.gets
|
53
|
+
bh = BlastHit.new(ln, aln)
|
54
|
+
ofh.print bh.to_s if bh.bits >= minscore
|
55
|
+
end
|
56
|
+
ifh.close
|
57
|
+
ofh.close
|
58
|
+
end
|
59
|
+
def bash(cmd, err_msg=nil)
|
60
|
+
o = `#{cmd} 2>&1 && echo '{'`
|
61
|
+
raise (err_msg.nil? ? "Error executing: #{cmd}\n\n#{o}" : err_msg) unless
|
62
|
+
o[-2]=="{"
|
63
|
+
true
|
64
|
+
end
|
65
65
|
end
|
66
66
|
|
67
67
|
#================================[ Extensions ]
|
68
68
|
# To ROCker
|
69
|
-
require
|
70
|
-
require
|
71
|
-
require
|
72
|
-
require
|
73
|
-
require
|
69
|
+
require 'rocker/step/build'
|
70
|
+
require 'rocker/step/compile'
|
71
|
+
require 'rocker/step/search'
|
72
|
+
require 'rocker/step/filter'
|
73
|
+
require 'rocker/step/plot'
|
74
74
|
|
75
75
|
# To other
|
76
76
|
class Numeric
|
77
|
-
|
77
|
+
def ordinalize
|
78
78
|
n= self.to_s
|
79
|
-
s= n[-2]=='1' ?
|
80
|
-
n[-1]=='1' ?
|
81
|
-
n[-1]=='2' ?
|
82
|
-
n[-1]=='3' ?
|
79
|
+
s= n[-2]=='1' ? 'th' :
|
80
|
+
n[-1]=='1' ? 'st' :
|
81
|
+
n[-1]=='2' ? 'nd' :
|
82
|
+
n[-1]=='3' ? 'rd' : 'th'
|
83
83
|
n + s
|
84
|
-
|
84
|
+
end
|
85
85
|
end
|
86
86
|
|
data/lib/rocker/step/filter.rb
CHANGED
@@ -20,20 +20,21 @@ class ROCker
|
|
20
20
|
puts "Loading ROCker file: #{@o[:rocker]}." unless @o[:q]
|
21
21
|
data = ROCData.new @o[:rocker]
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
readlengths = {}
|
24
|
+
exp_readlen = 0
|
25
25
|
unless @o[:lencorr].nil?
|
26
|
+
@o[:lencorr_max] ||= 0.4
|
26
27
|
raise "Unsigned length in model, please re-compile model to use -L" if
|
27
28
|
data.signatures[:l].nil?
|
28
|
-
|
29
|
+
exp_readlen = data.signatures[:l].to_i
|
29
30
|
File.open(@o[:lencorr], 'r') do |fh|
|
30
31
|
k = nil
|
31
32
|
fh.each_line do |ln|
|
32
33
|
if ln =~ /^>(\S+)/
|
33
34
|
k = $1
|
34
|
-
|
35
|
+
readlengths[k] = 0
|
35
36
|
else
|
36
|
-
|
37
|
+
readlengths[k] += ln.chomp.size
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -45,16 +46,26 @@ class ROCker
|
|
45
46
|
File.open(@o[:qblast], 'r') do |ih|
|
46
47
|
ih.each_line do |ln|
|
47
48
|
bh = BlastHit.new(ln, data.aln)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
oh.print ln if
|
54
|
-
not(bh.sfrom.nil?) and bs >= data.win_at_col(bh.midpoint).thr
|
49
|
+
next if bh.sbj.nil? # <- When the hit is not against a known target
|
50
|
+
bs = @o[:lencorr].nil? ? bh.bits :
|
51
|
+
correct_bs(bh, readlengths[bh.qry], exp_readlen, @o[:lencorr_max])
|
52
|
+
oh.print ln if not(bh.sfrom.nil?) and
|
53
|
+
bs >= data.win_at_col(bh.midpoint).thr
|
55
54
|
end
|
56
55
|
end
|
57
56
|
oh.close
|
58
57
|
end # filter!
|
58
|
+
|
59
|
+
def correct_bs(bh, readlen, exp_readlen, max_corr)
|
60
|
+
bs = bh.bits
|
61
|
+
return bs if @o[:lencorr].nil? or readlen.nil? or readlen >= exp_readlen
|
62
|
+
bits_per_aa = bs.to_f / readlen
|
63
|
+
miss = exp_readlen - readlen
|
64
|
+
max_tri = max_corr * readlen * bits_per_aa / 2
|
65
|
+
extra = [0.0, readlen * (max_corr + 1.0) - exp_readlen].max
|
66
|
+
tanTheta = max_corr > 0.0 ? bits_per_aa / (max_corr * readlen) : 0.0
|
67
|
+
extra_tri = extra * extra * tanTheta / 2
|
68
|
+
bs + (max_tri - extra_tri)
|
69
|
+
end
|
59
70
|
end # ROCker
|
60
71
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bio-rocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis (Coto) Orellana
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|