scbi_blast 0.0.40 → 0.0.42

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.0.42 2013-09-19
2
+
3
+ Using PTY to avoid blocking of popen in newer systems
4
+
5
+ === 0.0.41 2013-06-19
6
+
7
+ Add query count check
8
+
1
9
  === 0.0.40 2013-05-24
2
10
 
3
11
  qlen en query
data/README.rdoc CHANGED
@@ -4,14 +4,14 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- scbi_blast is a ruby gem to handle blast+ executions without the need of temporary files,
7
+ scbi_blast is a ruby gem to handle blast+ executions using pipes when possible to read data without the need of temporary files,
8
8
  it has been developed at [SCBI](http://www.scbi.uma.es) by Almudena Bocinos & Dario Guerrero.
9
9
 
10
10
  == FEATURES:
11
11
 
12
- * Execute blast within ruby without creating temporary files (using pipes)
12
+ * Execute blast (using pipe to read output). Pipes cannot be used for input since it will block if writing more 64kb.
13
13
  * Parse XML and table results into Query and Hit objects
14
- * Execute DustMasker without temporary files (using pipes)
14
+ * Execute DustMasker without temporary files (using pipes for both input and output)
15
15
 
16
16
  == SYNOPSIS:
17
17
 
@@ -86,6 +86,10 @@ An example that shows how to use it to find dust into some sequences:
86
86
 
87
87
  * NCBI blast+ already installed
88
88
 
89
+ == ENVIRONMENT
90
+
91
+ You can set the SCBI_BLAST_TMPDIR environment variable to choose where input temfiles should be written.
92
+
89
93
  == INSTALL:
90
94
 
91
95
  gem install scbi_blast
data/lib/scbi_blast.rb CHANGED
@@ -48,7 +48,7 @@ require 'blast_hit'
48
48
  require 'blast_table_result'
49
49
 
50
50
  module ScbiBlast
51
- VERSION = '0.0.40'
51
+ VERSION = '0.0.42'
52
52
  end
53
53
 
54
54
 
@@ -31,7 +31,6 @@ class BatchBlast
31
31
  @database = database
32
32
  @extra_params = extra_params
33
33
 
34
-
35
34
  end
36
35
 
37
36
  # returns the blast cmd that will be used to launch blast
@@ -47,6 +46,13 @@ class BatchBlast
47
46
 
48
47
  if !file.nil? and !file.empty?
49
48
  out=" -out #{file}"
49
+ else
50
+ # if RUBY_PLATFORM.index('darwin')
51
+ # out =" | sed -l"
52
+ # else
53
+ # out =" | sed -l 0"
54
+ # end
55
+ # out =" | grep --line-buffered ''"
50
56
  end
51
57
 
52
58
  dust=''
@@ -111,17 +117,69 @@ class BatchBlast
111
117
  res=''
112
118
  if !seq_fasta.empty?
113
119
  # Ojo, que una vez nos ibamos a volver locos buscando porque esto no devolvia todos los hits que se encontraban al ejecutar el blast a mano, y era porque en el blast a mano le estabamos pasando la secuencia completa mientras que en el MID le estabamos pasando solo los 20 primeros nt.
114
- IO.popen(cmd,'w+') {|blast|
115
- blast.sync = true
116
- blast.write(seq_fasta)
117
- blast.close_write
118
- res = blast.readlines
119
- blast.close_read
120
- }
121
-
122
- if !$?.exitstatus.nil? && $?.exitstatus>0
123
- raise "Error doing blast #{cmd} to fasta: #{seq_fasta}"
120
+
121
+ # Change the buffering type in factor command,
122
+ # assuming that factor uses stdio for stdout buffering.
123
+ # If IO.pipe is used instead of PTY.open,
124
+ # this code deadlocks because factor's stdout is fully buffered.
125
+
126
+
127
+ # require 'pty'
128
+ # require 'io/console' # for IO#raw!
129
+ # res = []
130
+ # m, s = PTY.open
131
+ # s.raw! # disable newline conversion.
132
+ # r, w = IO.pipe
133
+ # pid = spawn(cmd, :in=>r, :out=>s)
134
+ # r.close
135
+ # s.close
136
+ # w.puts seq_fasta
137
+ # w.close
138
+ # while !m.eof do
139
+ # res << m.gets
140
+ # end
141
+
142
+
143
+
144
+ # puts "="*60
145
+ # puts res
146
+ # puts "="*60
147
+ require 'tempfile'
148
+ if !ENV['SCBI_BLAST_TMPDIR'].nil?
149
+ file = Tempfile.new('scbi_blast_',ENV['SCBI_BLAST_TMPDIR'])
150
+ else
151
+ file = Tempfile.new('scbi_blast_')
152
+ end
153
+ begin
154
+ file.puts seq_fasta
155
+ file.close
156
+
157
+ res=`#{cmd} -query #{file.path}`
158
+ res=res.split("\n")
159
+
160
+ if !$?.exitstatus.nil? && $?.exitstatus>0
161
+ raise "Error doing blast #{cmd} to fasta: #{seq_fasta}"
162
+ end
163
+
164
+ # puts "FILEPATH"+file.path
165
+ ensure
166
+ file.close! # Closes the file handle. If the file wasn't unlinked
167
+ # because #unlink failed, then this method will attempt
168
+ # to do so again.
169
+ file.unlink # On Windows this silently fails.
124
170
  end
171
+
172
+ # IO.popen(cmd,'w+') {|blast|
173
+ # blast.sync = true
174
+ # blast.write(seq_fasta)
175
+ # blast.close_write
176
+ # res = blast.readlines
177
+ # blast.close_read
178
+ # }
179
+ #
180
+ # if !$?.exitstatus.nil? && $?.exitstatus>0
181
+ # raise "Error doing blast #{cmd} to fasta: #{seq_fasta}"
182
+ # end
125
183
  end
126
184
 
127
185
  return res
@@ -131,8 +189,7 @@ class BatchBlast
131
189
  # do blast to an array of Sequence objects
132
190
  def do_blast_seqs(seqs, fmt = :table,parse_output=true, file=nil)
133
191
 
134
-
135
- cmd = get_blast_cmd(fmt)
192
+ # cmd = get_blast_cmd(fmt)
136
193
 
137
194
  fastas=[]
138
195
 
@@ -49,6 +49,9 @@ class BlastTableResult < BlastResult
49
49
 
50
50
  def parse(lines)
51
51
 
52
+ if !(lines.last =~ /# BLAST processed (\d+) queries/)
53
+ raise "Blast didn't processed your queries"
54
+ end
52
55
 
53
56
  query_name=''
54
57
 
@@ -8,6 +8,8 @@ class TestScbiBlast < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  def test_blast
11
+ puts "TEST BLAST"
12
+
11
13
  blast=BatchBlast.new('-db ~/progs/ruby/DB/formatted/mids.fasta -task blastn-short')
12
14
 
13
15
  seqs=[">GFIJCBT03F4XVR","ACGCGTCTAGTGACTACACGACGACCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTNTTTTTNTTTTATTTTATTTTATTTATTATATATATATATATATATATATATATANNNNCNCACACANACACNNGAGNGNGNGNGAGNGAGNGAGTAGTAGTAGTAGTGTATATATACTACTACTACTACTACACACGACGACGTACGTACGTACGTACGTACGTACGTACGTACGTAACGTAAGTAAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTATATATATATATAGTAGTAGTAGTAGTAGTAGTAGTACGTACGTACGTACGTACGTACGTACGTACGACGACGACGACGACGACGACGACGAGATATATACTACTAACTAACTAACAACGTACGACGACGACGACGACGACGTACGTACGTACGTACGTACGTACTACTACTACTACGTACGTACGTACGTACGTACGTACGTACGTAGTAGTAGTAGTACGTACGTACGTCGTCGTCGTCGTCGTCGTCGTCGTACGTACGACGACGACGAGAGNGNGNNNNNNNNNNNN",">GFIJCBT03G3M1I","GACTACACGACGACTTTATTTATTATTTATTTATTTATTTATTTATTTATTTATTTATTTATTTTATTTTATTTTATTTTTATTTTTATTTTTATTTTTATTTTTTATTTTTTATTTTTTATTTTTTATTTTTTTATTTTTTTATTTTTTTATTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTTATTTTTTTTTATTTTTTTTTAGTTTTTTTTTAGTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTACGTTTTTTTTTTTTTACGTTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTACGTTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTTTTTTTNNNNNNNN"]
@@ -18,6 +20,7 @@ class TestScbiBlast < Test::Unit::TestCase
18
20
  end
19
21
 
20
22
  def test_blast_outfile
23
+ puts "TEST BLAST OUTFILE"
21
24
  blast=BatchBlast.new('-db ~/progs/ruby/DB/formatted/mids.fasta -task blastn-short')
22
25
 
23
26
  seqs=[">GFIJCBT03F4XVR","ACGCGTCTAGTGACTACACGACGACCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTNTTTTTNTTTTATTTTATTTTATTTATTATATATATATATATATATATATATATANNNNCNCACACANACACNNGAGNGNGNGNGAGNGAGNGAGTAGTAGTAGTAGTGTATATATACTACTACTACTACTACACACGACGACGTACGTACGTACGTACGTACGTACGTACGTACGTAACGTAAGTAAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTAGTATATATATATATAGTAGTAGTAGTAGTAGTAGTAGTACGTACGTACGTACGTACGTACGTACGTACGACGACGACGACGACGACGACGACGAGATATATACTACTAACTAACTAACAACGTACGACGACGACGACGACGACGTACGTACGTACGTACGTACGTACTACTACTACTACGTACGTACGTACGTACGTACGTACGTACGTAGTAGTAGTAGTACGTACGTACGTCGTCGTCGTCGTCGTCGTCGTCGTACGTACGACGACGACGAGAGNGNGNNNNNNNNNNNN",">GFIJCBT03G3M1I","GACTACACGACGACTTTATTTATTATTTATTTATTTATTTATTTATTTATTTATTTATTTATTTTATTTTATTTTATTTTTATTTTTATTTTTATTTTTATTTTTTATTTTTTATTTTTTATTTTTTATTTTTTTATTTTTTTATTTTTTTATTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTATTTTTTTTTATTTTTTTTTATTTTTTTTTAGTTTTTTTTTAGTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTACGTTTTTTTTTTTTTACGTTTTTTTTTTTTTAGTTTTTTTTTTTTTACGTTTTTTTTTTTTACGTTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTACGTTTTTTTTTTTTAGTTTTTTTTTTTTAGTTTTTTTTTTTTTTTTTTTNNNNNNNN"]
@@ -25,6 +28,8 @@ class TestScbiBlast < Test::Unit::TestCase
25
28
  res=blast.do_blast(seqs,:table,true,'/tmp/blast.txt')
26
29
  puts "="*30
27
30
  puts res.inspect
31
+
32
+
28
33
  end
29
34
 
30
35
 
@@ -108,6 +113,22 @@ class TestScbiBlast < Test::Unit::TestCase
108
113
 
109
114
  end
110
115
 
116
+ def test_good_table
117
+ res = BlastTableResult.new(File.join(File.dirname(__FILE__),'table.txt'))
118
+
119
+ assert_equal(999,res.querys.count)
120
+
121
+
122
+ end
123
+
124
+
125
+ def test_bad_table
126
+ assert_raise RuntimeError do
127
+ BlastTableResult.new(File.join(File.dirname(__FILE__),'bad_table.txt'))
128
+ end
129
+
130
+ end
131
+
111
132
 
112
133
  def test_dust
113
134
  dust_masker=DustMasker.new()
@@ -147,7 +168,7 @@ class TestScbiBlast < Test::Unit::TestCase
147
168
 
148
169
  seqs=">GFIJCBT03G3M1I"
149
170
 
150
- res = dust_masker.do_dust(seqs)
171
+ dust_masker.do_dust(seqs)
151
172
  # puts res.to_json
152
173
  # assert_equal(res.count,2)
153
174
  # assert_equal(res[0].dust.count,4)
@@ -214,7 +235,7 @@ class TestScbiBlast < Test::Unit::TestCase
214
235
  # seqs.push 'actggtacgacgtacaccagtactacgatcgtacgtacggatcgatcgatcgttagtgtacgtacgttgtacgtactgac'
215
236
 
216
237
  assert_raise(RuntimeError) {
217
- res = dust_masker.do_dust("name")
238
+ dust_masker.do_dust("name")
218
239
  }
219
240
 
220
241
  end
metadata CHANGED
@@ -1,50 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: scbi_blast
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.40
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.42
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Dario Guerrero & Almudena Bocinos
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2013-06-05 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+ date: 2013-09-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
21
  version: 1.0.12
22
22
  type: :runtime
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: hoe
26
23
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: 2.8.0
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.12
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '4.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '4.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: newgem
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.5.3
32
54
  type: :development
33
- version_requirements: *id002
34
- description: |-
35
- scbi_blast is a ruby gem to handle blast+ executions without the need of temporary files,
36
- it has been developed at [SCBI](http://www.scbi.uma.es) by Almudena Bocinos & Dario Guerrero.
37
- email:
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.5.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.6'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.6'
78
+ description: ! "scbi_blast is a ruby gem to handle blast+ executions using pipes when
79
+ possible to read data without the need of temporary files, \nit has been developed
80
+ at [SCBI](http://www.scbi.uma.es) by Almudena Bocinos & Dario Guerrero."
81
+ email:
38
82
  - dariogf@gmail.com, alkoke@gmail.com
39
83
  executables: []
40
-
41
84
  extensions: []
42
-
43
- extra_rdoc_files:
85
+ extra_rdoc_files:
44
86
  - History.txt
45
87
  - Manifest.txt
46
88
  - PostInstall.txt
47
- files:
89
+ - README.rdoc
90
+ files:
48
91
  - History.txt
49
92
  - Manifest.txt
50
93
  - PostInstall.txt
@@ -68,33 +111,35 @@ files:
68
111
  - lib/scbi_blast/blast_streamxml_result.rb
69
112
  - lib/scbi_blast/batch_blast.rb
70
113
  - lib/scbi_blast/dust_masker.rb
114
+ - .gemtest
71
115
  homepage: http://www.scbi.uma.es/downloads
72
116
  licenses: []
73
-
74
- metadata: {}
75
-
76
117
  post_install_message:
77
- rdoc_options:
118
+ rdoc_options:
78
119
  - --main
79
120
  - README.rdoc
80
- require_paths:
121
+ require_paths:
81
122
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
83
- requirements:
84
- - &id003
85
- - ">="
86
- - !ruby/object:Gem::Version
87
- version: "0"
88
- required_rubygems_version: !ruby/object:Gem::Requirement
89
- requirements:
90
- - *id003
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
91
135
  requirements: []
92
-
93
136
  rubyforge_project: scbi_blast
94
- rubygems_version: 2.0.3
137
+ rubygems_version: 1.8.24
95
138
  signing_key:
96
- specification_version: 4
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.
98
- test_files:
139
+ specification_version: 3
140
+ summary: scbi_blast is a ruby gem to handle blast+ executions using pipes when possible
141
+ to read data without the need of temporary files, it has been developed at [SCBI](http://www.scbi.uma.es)
142
+ by Almudena Bocinos & Dario Guerrero.
143
+ test_files:
99
144
  - test/test_helper.rb
100
145
  - test/test_scbi_blast.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: abd62dc048e15cc41de0e5540c28cdb76b255823
4
- data.tar.gz: c7d96d24d714d3641fe144241a6e9c8d4c2d9add
5
- SHA512:
6
- metadata.gz: 2c9216022a183a69a5f6417ddc69a6bb70c95c646acf84e2a9c97150c5fca40cb3d02f3ad91551bf506f1deb338e44d5af603bcf64f8ca28a9476108bc0d70f2
7
- data.tar.gz: c54e86e65fbbb372e1c2e9c4031a2e05a2ac7b89daa47698c8e74398f4a3c7d74c94496ce1a7da2b332c7d8bc2e095fc79e8af2ecc96f46727840f40643ed95a