scbi_blast 0.0.34 → 0.0.37

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 0.0.37 2012-11-28
2
+
3
+ Fixed empty seqs
4
+
5
+ === 0.0.36 2012-11-28
6
+
7
+ Protect against empty seqs and results
8
+
9
+ === 0.0.35 2012-11-28
10
+
11
+ Protect against empty seqs
12
+
1
13
  === 0.0.34 2012-04-30
2
14
 
3
15
  Added streamed XML parser to reduce memory usage with xml tree
data/lib/scbi_blast.rb CHANGED
@@ -33,7 +33,7 @@ require 'blast_hit'
33
33
  require 'blast_table_result'
34
34
 
35
35
  module ScbiBlast
36
- VERSION = '0.0.34'
36
+ VERSION = '0.0.37'
37
37
  end
38
38
 
39
39
 
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2010 Dario Guerrero & Almudena Bocinos
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # 'Software'), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -19,6 +19,7 @@
19
19
  # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
20
  # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
+ # TODO - Hacer algo cuando llegan secuencias vacias
22
23
 
23
24
  # class to execute Blast without temporary files (it uses pipes)
24
25
  class BatchBlast
@@ -60,9 +61,13 @@ class BatchBlast
60
61
  end
61
62
 
62
63
  cmd = get_blast_cmd(fmt)
63
-
64
- res = BatchBlast.do_blast_cmd(seq_fasta,cmd)
65
-
64
+
65
+ if !seqs.empty?
66
+ res = BatchBlast.do_blast_cmd(seq_fasta,cmd)
67
+ else
68
+ res=''
69
+ end
70
+
66
71
  # check if all sequences where processed
67
72
  if parse_output
68
73
  if fmt == :table
@@ -88,27 +93,28 @@ class BatchBlast
88
93
  end
89
94
 
90
95
  end
91
-
96
+
92
97
  return res
93
-
98
+
94
99
  end
95
-
100
+
96
101
  def self.do_blast_cmd(seq_fasta, cmd)
97
102
  res=''
98
-
99
- # 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.
100
- IO.popen(cmd,'w+') {|blast|
101
- blast.sync = true
102
- blast.write(seq_fasta)
103
- blast.close_write
104
- res = blast.readlines
105
- blast.close_read
106
- }
107
-
108
- if !$?.exitstatus.nil? && $?.exitstatus>0
109
- raise "Error doing blast #{cmd} to fasta: #{seq_fasta}"
103
+ if !seq_fasta.empty?
104
+ # 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.
105
+ IO.popen(cmd,'w+') {|blast|
106
+ blast.sync = true
107
+ blast.write(seq_fasta)
108
+ blast.close_write
109
+ res = blast.readlines
110
+ blast.close_read
111
+ }
112
+
113
+ if !$?.exitstatus.nil? && $?.exitstatus>0
114
+ raise "Error doing blast #{cmd} to fasta: #{seq_fasta}"
115
+ end
110
116
  end
111
-
117
+
112
118
  return res
113
119
 
114
120
  end
@@ -28,6 +28,7 @@ class BlastStreamxmlResult < BlastResult
28
28
 
29
29
  # @state = nil # (values :in_query,:in_hit)
30
30
 
31
+ return if input.empty?
31
32
 
32
33
  if input.is_a?(Array)
33
34
  lines=input.join("\n")
@@ -32,7 +32,8 @@ class BlastTableResult < BlastResult
32
32
 
33
33
  super(input)
34
34
 
35
-
35
+ return if input.empty?
36
+
36
37
  if input.is_a?(Array)
37
38
  lines=input
38
39
 
@@ -47,6 +48,8 @@ class BlastTableResult < BlastResult
47
48
  end
48
49
 
49
50
  def parse(lines)
51
+
52
+
50
53
  query_name=''
51
54
 
52
55
  lines.each do |line|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: scbi_blast
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.34
5
+ version: 0.0.37
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dario Guerrero & Almudena Bocinos
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-30 00:00:00 Z
13
+ date: 2012-11-28 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: xml-simple
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements: []
96
96
 
97
97
  rubyforge_project: scbi_blast
98
- rubygems_version: 1.7.2
98
+ rubygems_version: 1.8.24
99
99
  signing_key:
100
100
  specification_version: 3
101
101
  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.