Class: Bio::PSORT::WoLF_PSORT::Report

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, organism_type = nil, score_hash = {}) ⇒ Report

Returns a new instance of Report.



69
70
71
72
73
# File 'lib/bio/appl/psort/wolf_psort_wrapper.rb', line 69

def initialize(name=nil, organism_type=nil, score_hash={})
  @name = name
  @organism_type = organism_type
  @score_hash = score_hash
end

Instance Attribute Details

#nameObject

Name of the sequence that has been analyzed, according to WoLF_PSORT output



59
60
61
# File 'lib/bio/appl/psort/wolf_psort_wrapper.rb', line 59

def name
  @name
end

#organism_typeObject

plant, fungal or animal as a string



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

def organism_type
  @organism_type
end

#score_hashObject

A hash of scores output, for example => 12 keys of the hash are strings representing localisations values of the hash are float output scores



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

def score_hash
  @score_hash
end

Class Method Details

.parse_from_summary(organism_type, line) ⇒ Object

Given an output line from a the runWolfPsortSummary script, return a report with all the included information in it.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bio/appl/psort/wolf_psort_wrapper.rb', line 77

def self.parse_from_summary(organism_type, line)
  line.strip!
  return nil if line.match(/^\#/) #ignore the first comment line
  
  rep = self.new
  rep.organism_type = organism_type
  
  line.split(', ').each_with_index do |fraction, index|
    splits = fraction.split(' ')
    if index == 0
      raise ArgumentError, "invalid format\n[#{line}]" if splits.length != 3
      rep.name = splits[0]
      rep.score_hash[splits[1]] = splits[2].to_f
    else
      raise ArgumentError, "invalid format\n[#{line}]" if splits.length != 2
      rep.score_hash[splits[0]] = splits[1].to_f
    end
  end
  
  return rep
end

Instance Method Details

#highest_predicted_localizationObject

Return the string of the highest predicted localisation recorded in the score hash



101
102
103
104
105
# File 'lib/bio/appl/psort/wolf_psort_wrapper.rb', line 101

def highest_predicted_localization
  @score_hash.max{ |a,b|
    a[1] <=> b[1]
  }[0]
end