Class: Bio::PSORT::PSORT1::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/psort/report.rb

Overview

Bio::PSORT::PSORT1::Report

Parser class for PSORT1 output report.

Example

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Report) initialize(entry_id = '', origin = '', title = '', sequence = '', result_info = '', reasoning = {}, final_result = [])

Constructs aBio::PSORT::PSORT1::Report object.



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/bio/appl/psort/report.rb', line 72

def initialize(entry_id = '', origin = '', title = '', sequence = '',
               result_info = '', reasoning = {}, final_result = [])
  @entry_id = entry_id
  @origin = origin
  @title = title
  @sequence = sequence
  @result_info = result_info
  @reasoning = reasoning
  @final_result = final_result
  @raw = ''
end

Instance Attribute Details

- (Object) entry_id

Returns the value of attribute entry_id



60
61
62
# File 'lib/bio/appl/psort/report.rb', line 60

def entry_id
  @entry_id
end

- (Object) final_result

Returns the value of attribute final_result



66
67
68
# File 'lib/bio/appl/psort/report.rb', line 66

def final_result
  @final_result
end

- (Object) origin

Returns the value of attribute origin



61
62
63
# File 'lib/bio/appl/psort/report.rb', line 61

def origin
  @origin
end

- (Object) raw

Returns the value of attribute raw



67
68
69
# File 'lib/bio/appl/psort/report.rb', line 67

def raw
  @raw
end

- (Object) reasoning

Returns the value of attribute reasoning



65
66
67
# File 'lib/bio/appl/psort/report.rb', line 65

def reasoning
  @reasoning
end

- (Object) result_info

Returns the value of attribute result_info



64
65
66
# File 'lib/bio/appl/psort/report.rb', line 64

def result_info
  @result_info
end

- (Object) sequence

Returns the value of attribute sequence



63
64
65
# File 'lib/bio/appl/psort/report.rb', line 63

def sequence
  @sequence
end

- (Object) title

Returns the value of attribute title



62
63
64
# File 'lib/bio/appl/psort/report.rb', line 62

def title
  @title
end

Class Method Details

+ (Object) default_parser(output_report)

Returns aBio::PSORT::PSORT1::Report.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bio/appl/psort/report.rb', line 36

def self.default_parser(output_report)
  rpt = self.new
  rpt.raw = output_report
  query_info = output_report.scan(/^Query Information\n\n(.+?)\n\n/m)[0][0].split(/\n/)
  result_info = output_report.scan(/^Result Information\n\n(.+?)\n\n\*/m)[0][0]
  step1 = output_report.scan(/^\*\*\* Reasoning Step: 1\n\n(.+?)\n\n/m)[0][0]
  step2 = output_report.scan(/^\*\*\* Reasoning Step: 2\n\n(.+?)\n\n/m)[0][0]
  final_result = output_report.scan(/\n\n----- Final Results -----\n\n(.+?)\n\n\n/m)[0][0]

  rpt.entry_id = query_info[2].scan(/^>(\S+) */).to_s
  rpt.origin   = query_info[0].scan(/ORIGIN (\w+)/).to_s
  rpt.sequence = Bio::Sequence::AA.new(query_info[3..query_info.size].to_s)
  # rpt.reasoning

  rpt.final_result = final_result.split(/\n/).map {|x|
    x = x.strip.split(/---/).map {|y| y.strip }
    { 'prediction' => x[0], 
      'certainty'  => x[1].scan(/Certainty= (\d\.\d{3})/).to_s,
      'comment'    => x[1].scan(/\((\w+)\)/).to_s
    }
  }
  return rpt
end

+ (Object) parser(output_report)

Returns aBio::PSORT::PSORT1::Report.



31
32
33
# File 'lib/bio/appl/psort/report.rb', line 31

def self.parser(output_report)
  self.default_parser(output_report)
end