[BioRuby-cvs] bioruby/sample na2aa.rb,NONE,1.1

Pjotr Prins pjotr at dev.open-bio.org
Wed Feb 6 16:26:05 UTC 2008


Update of /home/repository/bioruby/bioruby/sample
In directory dev.open-bio.org:/tmp/cvs-serv5421

Added Files:
	na2aa.rb 
Log Message:
Simple example to translate any NA to AA fasta

--- NEW FILE: na2aa.rb ---
#!/usr/bin/env ruby
#
# translate.rb - translate any NA input into AA FASTA format
#
#   Copyright (C) 2008 KATAYAMA Toshiaki <k at bioruby.org> & Pjotr Prins
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  $Id: na2aa.rb,v 1.1 2008/02/06 16:25:53 pjotr Exp $
#

require 'bio'
require 'pp'

include Bio

ARGV.each do | fn |
  Bio::FlatFile.auto(fn).each do | item |
    seq = Sequence::NA.new(item.data)
    aa = seq.translate
    aa.gsub!(/X/,'-')
    rec = Bio::FastaFormat.new('> '+item.definition+"\n"+aa)
    print rec
  end
end





More information about the bioruby-cvs mailing list