lib/sequenceserver/blast/query.rb in sequenceserver-1.0.14 vs lib/sequenceserver/blast/query.rb in sequenceserver-1.1.0.beta

- old
+ new

@@ -7,21 +7,24 @@ # @member [Fixnum] length # @member [Array(Hit)] hits Query = Struct.new(:report, :number, :def, :length, :hits) do def initialize(*args) args[1] = args[1].to_i - args[2] = "Query_#{args[1]}" if args[2] == 'No definition line' + if args[2] == 'No definition line' || + args[2] == 'unnamed protein product' + args[2] = "Query_#{args[1]}" + end args[3] = args[3].to_i @id, *rest = args[2].split @title = rest.join(' ') super end - def sort_hits_by_evalue! - # change made here - @hits = hits.sort_by { |h| [h.evalue, h.score] } - end - attr_reader :id, :title + + def to_json(*args) + [:number, :id, :title, :length, :hits] + .inject({}) { |h, k| h[k] = send(k); h }.to_json(*args) + end end end end