Sha256: 84815f8042773b6fc30a9770ac247ccc3a4ed026086f36aa470a76c514a95440

Contents?: true

Size: 1.27 KB

Versions: 11

Compression:

Stored size: 1.27 KB

Contents

module SequenceServer
  # Define BLAST::Hit.
  module BLAST
    # Hit Object to store all the hits per Query.
    Hit = Struct.new(:query, :number, :id, :accession, :title,
                     :length, :hsps) do
      include Links

      def initialize(*args)
        args[1] = args[1].to_i
        args[4] = '' if args[4] == 'No definition line'
        args[5] = args[5].to_i
        super
      end

      # Hit evalue is the minimum evalue of all HSP(s).
      def evalue
        hsps.map(&:evalue).min
      end

      # Hit score is the sum of bit scores of all HSP(s).
      def score
        hsps.map(&:bit_score).reduce(:+)
      end

      def links
        links = Links.instance_methods.map { |m| send m }
        links.compact!
        links.sort_by { |link| [link[:order], link[:title]] }
      end

      # Returns an array of database objects which contain the queried sequence
      # id.
      #
      # NOTE:
      #   This function may return more than one database object for a single
      #   sequence id.
      #
      # e.g., which_blastdb('SI_2.2.23') => [<Database: ...>, ...]
      def whichdb
        querydb.select { |db| db.include? id }
      end

      def report
        query.report
      end

      def querydb
        report.querydb
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sequenceserver-1.0.14 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.13 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.12 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.11 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.10 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.9 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.8 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.7 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.6 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.5 lib/sequenceserver/blast/hit.rb
sequenceserver-1.0.4 lib/sequenceserver/blast/hit.rb