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

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/psort/report.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.



446
447
448
449
450
# File 'lib/bio/appl/psort/report.rb', line 446

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



436
437
438
# File 'lib/bio/appl/psort/report.rb', line 436

def name
  @name
end

#organism_typeObject

plant, fungal or animal as a string



439
440
441
# File 'lib/bio/appl/psort/report.rb', line 439

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



444
445
446
# File 'lib/bio/appl/psort/report.rb', line 444

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



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/bio/appl/psort/report.rb', line 454

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

#==(another) ⇒ Object

Equivalence to another WoLF_PSORT report. Written mainly with testing in mind



478
479
480
481
482
483
# File 'lib/bio/appl/psort/report.rb', line 478

def ==(another)
  [:organism_type, :name, :score_hash].each do |attr|
    return false if self.send(attr) != another.send(attr)
  end
  return true
end

#highest_predicted_localizationObject

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



487
488
489
490
491
# File 'lib/bio/appl/psort/report.rb', line 487

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