Class: SequenceServer::BLAST::Report

Inherits:
Report
  • Object
show all
Defined in:
lib/sequenceserver/blast/report.rb

Overview

Captures results of a BLAST search.

A report is constructed from a search id. Search id is simply the basename of the temporary file that holds BLAST results in binary BLAST archive format.

For a given search id, result is obtained in XML format using the Formatter class, parsed into a simple intermediate representation (Array of values and Arrays) and information extracted from the intermediate representation (ir).

Instance Attribute Summary

Attributes inherited from Report

#job

Instance Method Summary collapse

Methods inherited from Report

generate

Constructor Details

#initialize(job) ⇒ Report

Returns a new instance of Report.



25
26
27
28
29
# File 'lib/sequenceserver/blast/report.rb', line 25

def initialize(job)
  super do
    @querydb = job.databases
  end
end

Instance Method Details

#dbtypeObject



70
71
72
# File 'lib/sequenceserver/blast/report.rb', line 70

def dbtype
  @dbtype ||= querydb&.first&.type || dbtype_from_program
end

#done?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
# File 'lib/sequenceserver/blast/report.rb', line 50

def done?
  return true if job.imported_xml_file

  File.exist?(xml_formatter.filepath) && File.exist?(tsv_formatter.filepath)
end

#paramsObject



74
75
76
# File 'lib/sequenceserver/blast/report.rb', line 74

def params
  @params ||= extract_params
end

#programObject



56
57
58
# File 'lib/sequenceserver/blast/report.rb', line 56

def program
  @program ||= xml_ir[0]
end

#program_versionObject



60
61
62
# File 'lib/sequenceserver/blast/report.rb', line 60

def program_version
  @program_version ||= xml_ir[1]
end

#queriesObject



82
83
84
85
86
87
88
89
# File 'lib/sequenceserver/blast/report.rb', line 82

def queries
  @queries ||= xml_ir[8].map do |n|
    query = Query.new(self, n[0], n[2], n[3], [])
    query.hits = query_hits(n[4], tsv_ir[query.id], query)

    query
  end
end

#querydbObject



64
65
66
67
68
# File 'lib/sequenceserver/blast/report.rb', line 64

def querydb
  @querydb ||= xml_ir[3].split.map do |path|
    { title: File.basename(path) }
  end
end

#statsObject



78
79
80
# File 'lib/sequenceserver/blast/report.rb', line 78

def stats
  @stats ||= extract_stats
end

#to_json(*_args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sequenceserver/blast/report.rb', line 31

def to_json(*_args)
  %i[querydb program program_version params stats
     queries].inject({}) do |h, k|
    h[k] = send(k)
    h
  end.update(search_id: job.id,
             submitted_at: job..utc,
             imported_xml: !job.imported_xml_file.nil?,
             seqserv_version: SequenceServer::VERSION,
             cloud_sharing_enabled: SequenceServer.config[:cloud_share_url].start_with?('http'),
             non_parse_seqids: !!job.databases&.any?(&:non_parse_seqids?)).to_json
end

#xml_file_sizeObject



44
45
46
47
48
# File 'lib/sequenceserver/blast/report.rb', line 44

def xml_file_size
  return File.size(job.imported_xml_file) if job.imported_xml_file

  xml_formatter.size
end