[BioRuby-cvs] bioruby/lib/bio/shell/plugin psort.rb,NONE,1.1

Katayama Toshiaki k at dev.open-bio.org
Tue Jul 25 18:42:11 UTC 2006


Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin
In directory dev.open-bio.org:/tmp/cvs-serv27522/lib/bio/shell/plugin

Added Files:
	psort.rb 
Log Message:
* newly added shell plugin for psort


--- NEW FILE: psort.rb ---
#
# = bio/shell/plugin/psort.rb - plugin for PSORT
#
# Copyright::   Copyright (C) 2006
#               Toshiaki Katayama <k at bioruby.org>
# License::     Ruby's
#
# $Id: psort.rb,v 1.1 2006/07/25 18:42:09 k Exp $
#

module Bio::Shell

  private

  def psort1(str)
    seq = seq(str)
    if seq.is_a?(Bio::Sequence::NA)
      seq = seq.translate
    end

    psort = Bio::PSORT::PSORT1.imsut
    fasta = seq.to_fasta

    results = psort.exec(fasta).final_result
    results.each do |result|
      puts "#{result["certainty"].to_f*100.0}\t#{result["prediction"]}"
    end
    return results.first["prediction"]
  end

  def psort2(str)
    seq = seq(str)
    if seq.is_a?(Bio::Sequence::NA)
      seq = seq.translate
    end

    psort = Bio::PSORT::PSORT2.imsut
    fasta = seq.to_fasta

    results = psort.exec(fasta).prob.sort_by{|x, y| y}.reverse
    results.each do |loc, prob|
      next if prob <= 0.0
      puts "#{prob}\t#{Bio::PSORT::PSORT2::SclNames[loc]}"
    end
    return results.first.first
  end

  def psort2locations
    names = Bio::PSORT::PSORT2::SclNames
    names.sort.each do |loc, desc|
      puts "#{loc}\t#{desc}"
    end
    return names
  end
end





More information about the bioruby-cvs mailing list