Sha256: 6f9f8b358f0d3506e342b76ff8e4e6ca01372c2908f0e1ce97ac462c7d7499c1

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

module SequenceServer
  # Define BLAST::HSP and BLAST::HSP::*.
  module BLAST
    # Structure to hold data for each HSP.
    HSP = Struct.new(:hit, :number, :bit_score, :score, :evalue, :qstart, :qend,
                     :sstart, :send, :qframe, :sframe, :identity, :positives,
                     :gaps, :length, :qcovhsp, :qseq, :sseq, :midline) do
      INTEGER_ARGS = [1, 3].concat((5..15).to_a)
      FLOAT_ARGS   = [2, 4]

      def initialize(*args)
        INTEGER_ARGS.each do |i|
          args[i] = args[i].to_i
        end

        FLOAT_ARGS.each do |i|
          args[i] = args[i].to_f
        end

        super
      end

      def to_json(*args)
        [:number, :bit_score, :score, :evalue, :qstart, :qend,
         :sstart, :send, :qframe, :sframe, :identity, :positives,
         :gaps, :length, :qcovhsp, :qseq, :sseq, :midline].inject({}) { |h, k| h[k] = self[k]; h }.to_json(*args)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sequenceserver-1.1.0.beta11 lib/sequenceserver/blast/hsp.rb
sequenceserver-1.1.0.beta10 lib/sequenceserver/blast/hsp.rb