scbi_blast 0.0.37 → 0.0.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.txt +12 -0
- data/lib/scbi_blast.rb +16 -1
- data/lib/scbi_blast/batch_blast.rb +17 -8
- data/lib/scbi_blast/blast_hit.rb +14 -3
- data/lib/scbi_blast/blast_table_result.rb +7 -3
- data/test/test_scbi_blast.rb +13 -2
- metadata +9 -13
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abd62dc048e15cc41de0e5540c28cdb76b255823
|
4
|
+
data.tar.gz: c7d96d24d714d3641fe144241a6e9c8d4c2d9add
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c9216022a183a69a5f6417ddc69a6bb70c95c646acf84e2a9c97150c5fca40cb3d02f3ad91551bf506f1deb338e44d5af603bcf64f8ca28a9476108bc0d70f2
|
7
|
+
data.tar.gz: c54e86e65fbbb372e1c2e9c4031a2e05a2ac7b89daa47698c8e74398f4a3c7d74c94496ce1a7da2b332c7d8bc2e095fc79e8af2ecc96f46727840f40643ed95a
|
data/History.txt
CHANGED
data/lib/scbi_blast.rb
CHANGED
@@ -22,6 +22,21 @@
|
|
22
22
|
|
23
23
|
$: << File.join(File.dirname(__FILE__),File.basename(__FILE__,File.extname(__FILE__)))
|
24
24
|
|
25
|
+
v='0.0.0'
|
26
|
+
begin
|
27
|
+
s=`blastn -version`
|
28
|
+
v=s.split("\n").first.split(' ').last.gsub('+','')
|
29
|
+
|
30
|
+
rescue Exception => e
|
31
|
+
raise "Blast not installed"
|
32
|
+
end
|
33
|
+
|
34
|
+
if Gem::Version.new(v) < Gem::Version.new('2.2.28')
|
35
|
+
puts "Blast #{v} is older than 2.2.28+, please use scbi_blast version 0.0.37 or upgrade your blast to 2.2.28 or greater"
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
|
39
|
+
|
25
40
|
require 'batch_blast'
|
26
41
|
require 'dust_masker'
|
27
42
|
require 'blast_query'
|
@@ -33,7 +48,7 @@ require 'blast_hit'
|
|
33
48
|
require 'blast_table_result'
|
34
49
|
|
35
50
|
module ScbiBlast
|
36
|
-
VERSION = '0.0.
|
51
|
+
VERSION = '0.0.40'
|
37
52
|
end
|
38
53
|
|
39
54
|
|
@@ -35,24 +35,30 @@ class BatchBlast
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# returns the blast cmd that will be used to launch blast
|
38
|
-
def get_blast_cmd(fmt = :table)
|
38
|
+
def get_blast_cmd(fmt = :table, file=nil)
|
39
39
|
|
40
40
|
if fmt==:table
|
41
|
-
format = ' -outfmt "7 qseqid sacc pident length mismatch gapopen qstart qend sstart send evalue bitscore score qframe sframe qseq sseq" '
|
41
|
+
format = ' -outfmt "7 qseqid sacc pident length mismatch gapopen qstart qend sstart send evalue bitscore score qframe sframe qseq sseq qlen slen stitle" '
|
42
42
|
elsif fmt ==:xml
|
43
43
|
format = ' -outfmt 5 '
|
44
44
|
end
|
45
|
+
|
46
|
+
out=''
|
47
|
+
|
48
|
+
if !file.nil? and !file.empty?
|
49
|
+
out=" -out #{file}"
|
50
|
+
end
|
45
51
|
|
46
52
|
dust=''
|
47
53
|
|
48
|
-
cmd = @blast_type+' '+dust+@extra_params + format + @database
|
54
|
+
cmd = @blast_type+' '+dust+@extra_params + format + @database + out
|
49
55
|
|
50
56
|
return cmd
|
51
57
|
|
52
58
|
end
|
53
59
|
|
54
60
|
# do a blast to seqs
|
55
|
-
def do_blast(seqs, fmt = :table,parse_output=true)
|
61
|
+
def do_blast(seqs, fmt = :table,parse_output=true,file=nil)
|
56
62
|
|
57
63
|
if seqs.is_a?(Array)
|
58
64
|
seq_fasta=seqs.join("\n")
|
@@ -60,10 +66,13 @@ class BatchBlast
|
|
60
66
|
seq_fasta=seqs
|
61
67
|
end
|
62
68
|
|
63
|
-
cmd = get_blast_cmd(fmt)
|
69
|
+
cmd = get_blast_cmd(fmt,file)
|
64
70
|
|
65
71
|
if !seqs.empty?
|
66
|
-
|
72
|
+
res = BatchBlast.do_blast_cmd(seq_fasta,cmd)
|
73
|
+
if !file.nil? and !file.empty?
|
74
|
+
res=file
|
75
|
+
end
|
67
76
|
else
|
68
77
|
res=''
|
69
78
|
end
|
@@ -120,7 +129,7 @@ class BatchBlast
|
|
120
129
|
end
|
121
130
|
|
122
131
|
# do blast to an array of Sequence objects
|
123
|
-
def do_blast_seqs(seqs, fmt = :table,parse_output=true)
|
132
|
+
def do_blast_seqs(seqs, fmt = :table,parse_output=true, file=nil)
|
124
133
|
|
125
134
|
|
126
135
|
cmd = get_blast_cmd(fmt)
|
@@ -132,7 +141,7 @@ class BatchBlast
|
|
132
141
|
fastas.push seq.seq_fasta
|
133
142
|
end
|
134
143
|
|
135
|
-
return do_blast(fastas,fmt,parse_output)
|
144
|
+
return do_blast(fastas,fmt,parse_output,file)
|
136
145
|
|
137
146
|
end
|
138
147
|
|
data/lib/scbi_blast/blast_hit.rb
CHANGED
@@ -35,6 +35,9 @@ class BlastHit
|
|
35
35
|
@s_beg = s_beg.to_i-1
|
36
36
|
@s_end = s_end.to_i-1
|
37
37
|
# puts "Set limits2 #{[@q_beg,@q_end,@s_beg,@s_end].join(',')}"
|
38
|
+
|
39
|
+
@s_len=0
|
40
|
+
@q_len=0
|
38
41
|
|
39
42
|
@reversed = false
|
40
43
|
|
@@ -109,14 +112,22 @@ class BlastHit
|
|
109
112
|
@q_seq = v
|
110
113
|
end
|
111
114
|
|
115
|
+
def s_len=(v)
|
116
|
+
@s_len = v.to_i
|
117
|
+
end
|
118
|
+
|
119
|
+
def q_len=(v)
|
120
|
+
@q_len = v.to_i
|
121
|
+
end
|
122
|
+
|
112
123
|
def full_subject_length=(v)
|
113
|
-
@full_subject_length = v
|
124
|
+
@full_subject_length = v.to_i
|
114
125
|
end
|
115
126
|
|
116
127
|
# puts all hit info on a string
|
117
128
|
def inspect
|
118
129
|
res = "Hit: #{@subject_id.ljust(10)} #{@ident.to_s.rjust(4)} #{@align_len.to_s.rjust(2)} #{@mismatches.to_s.rjust(2)} #{@gaps.to_s.rjust(2)} #{@q_beg.to_s.rjust(5)} #{@q_end.to_s.rjust(5)} #{@s_beg.to_s.rjust(5)} #{@s_end.to_s.rjust(5)} #{@e_val.to_s.rjust(5)} #{@bit_score.to_s.rjust(5)} #{@reversed.to_s.rjust(5)}"
|
119
|
-
res += " #{@score.to_s.rjust(5)} #{@acc.ljust(10)} #{@definition.ljust(10)} #{@q_frame.to_s.rjust(2)} #{@s_frame.to_s.rjust(2)} #{@full_subject_length.to_s.rjust(5)} #{@q_seq}.#{@s_seq}
|
130
|
+
res += " #{@score.to_s.rjust(5)} #{@acc.ljust(10)} #{@definition.ljust(10)} #{@q_frame.to_s.rjust(2)} #{@s_frame.to_s.rjust(2)} #{@full_subject_length.to_s.rjust(5)} #{@q_seq}.#{@s_seq}.#{@q_len}.#{@s_len}"
|
120
131
|
|
121
132
|
return res
|
122
133
|
end
|
@@ -179,6 +190,6 @@ class BlastHit
|
|
179
190
|
attr_reader :subject_id, :align_len, :gaps, :mismatches
|
180
191
|
attr_accessor :reversed
|
181
192
|
attr_reader :score, :acc, :definition, :q_frame, :s_frame, :full_subject_length, :ident, :e_val, :bit_score
|
182
|
-
attr_reader :q_seq, :s_seq
|
193
|
+
attr_reader :q_seq, :s_seq, :s_len, :q_len
|
183
194
|
|
184
195
|
end
|
@@ -108,7 +108,7 @@ class BlastTableResult < BlastResult
|
|
108
108
|
# if the query doesn't exist, then create a new one,
|
109
109
|
# else the hit will be added to the last query
|
110
110
|
|
111
|
-
qseqid,sacc,pident,length,mismatch,gapopen,qstart,qend,sstart,send,evalue,bitscore,score,qframe,sframe,qseq,sseq = params
|
111
|
+
qseqid,sacc,pident,length,mismatch,gapopen,qstart,qend,sstart,send,evalue,bitscore,score,qframe,sframe,qseq,sseq,qlen,slen,stitle = params
|
112
112
|
|
113
113
|
# creates the hit
|
114
114
|
hit = BlastHit.new(qstart,qend,sstart,send)
|
@@ -126,11 +126,14 @@ class BlastTableResult < BlastResult
|
|
126
126
|
hit.s_frame = sframe
|
127
127
|
|
128
128
|
hit.subject_id = sacc
|
129
|
-
hit.full_subject_length=0
|
130
|
-
hit.definition=sacc
|
129
|
+
hit.full_subject_length=slen # era 0
|
130
|
+
hit.definition=stitle # era sacc
|
131
131
|
hit.acc=sacc
|
132
132
|
hit.q_seq=qseq
|
133
133
|
hit.s_seq=sseq
|
134
|
+
hit.q_len=qlen
|
135
|
+
hit.s_len=slen
|
136
|
+
|
134
137
|
|
135
138
|
query=find_query(@querys,qseqid)
|
136
139
|
|
@@ -143,6 +146,7 @@ class BlastTableResult < BlastResult
|
|
143
146
|
@querys.push query
|
144
147
|
end
|
145
148
|
|
149
|
+
query.full_query_length=qlen
|
146
150
|
|
147
151
|
#Description
|
148
152
|
|
data/test/test_scbi_blast.rb
CHANGED
@@ -8,15 +8,26 @@ class TestScbiBlast < Test::Unit::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_blast
|
11
|
-
blast=BatchBlast.new('-db ~/progs/ruby/DB/formatted/mids.fasta')
|
11
|
+
blast=BatchBlast.new('-db ~/progs/ruby/DB/formatted/mids.fasta -task blastn-short')
|
12
12
|
|
13
|
-
seqs=[">GFIJCBT03F4XVR","
|
13
|
+
seqs=[">GFIJCBT03F4XVR","ACGCGTCTAGTGACTACACGACGACCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTNTTTTTNTTTTATTTTATTTTATTTATTATATATATATATATATATATATATATANNNNCNCACACANACACNNGAGNGNGNGNGAGNGAGNGAGTAGTAGTAGTAGTGTATATATACTACTACTACTACTACACACGACGACGTACGTACGTACGTACGTACGTACGTACGTACGTAACGTAAGTAAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTATATATATATATAGTAGTAGTAGTAGTAGTAGTAGTACGTACGTACGTACGTACGTACGTACGTACGACGACGACGACGACGACGACGACGAGATATATACTACTAACTAACTAACAACGTACGACGACGACGACGACGACGTACGTACGTACGTACGTACGTACTACTACTACTACG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N"]
|
14
14
|
|
15
15
|
res=blast.do_blast(seqs)
|
16
16
|
|
17
17
|
puts res.inspect
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_blast_outfile
|
21
|
+
blast=BatchBlast.new('-db ~/progs/ruby/DB/formatted/mids.fasta -task blastn-short')
|
22
|
+
|
23
|
+
seqs=[">GFIJCBT03F4XVR","ACGCGTCTAGTGACTACACGACGACCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTNTTTTTNTTTTATTTTATTTTATTTATTATATATATATATATATATATATATATANNNNCNCACACANACACNNGAGNGNGNGNGAGNGAGNGAGTAGTAGTAGTAGTGTATATATACTACTACTACTACTACACACGACGACGTACGTACGTACGTACGTACGTACGTACGTACGTAACGTAAGTAAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTATATATATATATAGTAGTAGTAGTAGTAGTAGTAGTACGTACGTACGTACGTACGTACGTACGTACGACGACGACGACGACGACGACGACGAGATATATACTACTAACTAACTAACAACGTACGACGACGACGACGACGACGTACGTACGTACGTACGTACGTACTACTACTACTACGTACGTACGTACGTACGTACGTACGTACGTAGTAGTAGTAGTACGTACGTACGTCGTCGTCGTCGTCGTCGTCGTCGTACGTACGACGACGACGAGAGNGNGNNNNNNNNNNNN",">GFIJCBT03G3M1I","GACTACACGACGACTTTATTTATTATTTATTTATTTATTTATTTATTTATTTATTTATTTATTTTATTTTATTTTATTTTTATTTTTATTTTTATTTTTATTTTTTATTTTTTATTTTTTATTTTTTATTTTTTTATTTTTTTATTTTTTTATTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTTATTTTTTTTTATTTTTTTTTAGTTTTTTTTTAGTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTACGTTTTTTTTTTTTTACGTTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTACGTTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTTTTTTTNNNNNNNN"]
|
24
|
+
|
25
|
+
res=blast.do_blast(seqs,:table,true,'/tmp/blast.txt')
|
26
|
+
puts "="*30
|
27
|
+
puts res.inspect
|
28
|
+
end
|
29
|
+
|
30
|
+
|
20
31
|
def test_querys
|
21
32
|
res = BlastSimplexmlResult.new(File.join(File.dirname(__FILE__),'blast.xml'))
|
22
33
|
# puts "BLAST.XML"
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scbi_blast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.37
|
4
|
+
version: 0.0.40
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Dario Guerrero & Almudena Bocinos
|
@@ -10,13 +9,12 @@ autorequire:
|
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date:
|
12
|
+
date: 2013-06-05 00:00:00 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: xml-simple
|
17
16
|
prerelease: false
|
18
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
19
|
- - ">="
|
22
20
|
- !ruby/object:Gem::Version
|
@@ -27,7 +25,6 @@ dependencies:
|
|
27
25
|
name: hoe
|
28
26
|
prerelease: false
|
29
27
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
-
none: false
|
31
28
|
requirements:
|
32
29
|
- - ">="
|
33
30
|
- !ruby/object:Gem::Version
|
@@ -74,6 +71,8 @@ files:
|
|
74
71
|
homepage: http://www.scbi.uma.es/downloads
|
75
72
|
licenses: []
|
76
73
|
|
74
|
+
metadata: {}
|
75
|
+
|
77
76
|
post_install_message:
|
78
77
|
rdoc_options:
|
79
78
|
- --main
|
@@ -81,23 +80,20 @@ rdoc_options:
|
|
81
80
|
require_paths:
|
82
81
|
- lib
|
83
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
83
|
requirements:
|
86
|
-
-
|
84
|
+
- &id003
|
85
|
+
- ">="
|
87
86
|
- !ruby/object:Gem::Version
|
88
87
|
version: "0"
|
89
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
89
|
requirements:
|
92
|
-
-
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: "0"
|
90
|
+
- *id003
|
95
91
|
requirements: []
|
96
92
|
|
97
93
|
rubyforge_project: scbi_blast
|
98
|
-
rubygems_version:
|
94
|
+
rubygems_version: 2.0.3
|
99
95
|
signing_key:
|
100
|
-
specification_version:
|
96
|
+
specification_version: 4
|
101
97
|
summary: scbi_blast is a ruby gem to handle blast+ executions without the need of temporary files, it has been developed at [SCBI](http://www.scbi.uma.es) by Almudena Bocinos & Dario Guerrero.
|
102
98
|
test_files:
|
103
99
|
- test/test_helper.rb
|