Sha256: 22b0eebb2e0a9e46bd0a8dc81d8e935245cece5b5fcb14ce1e297de11dc95cdd

Contents?: true

Size: 835 Bytes

Versions: 10

Compression:

Stored size: 835 Bytes

Contents

module SequenceServer
  # Define BLAST::Query.
  module BLAST
    # Capture results per query of a BLAST search.
    # @member [String]     number
    # @member [String]     def
    # @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
        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

      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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sequenceserver-1.1.0.beta11 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta10 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta8 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta7 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta6 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta5 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta4 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta3 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta2 lib/sequenceserver/blast/query.rb
sequenceserver-1.1.0.beta lib/sequenceserver/blast/query.rb