From 5b3ac0e55143387e6e1490e2b28dcff1ac0eb73d Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 30 Jun 2009 20:33:33 +0000 Subject: [PATCH] updated ruby code git-svn-id: http://biopieces.googlecode.com/svn/trunk@549 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/Maasha/lib/seq.rb | 6 +++--- code_ruby/Maasha/test/test_seq.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index ddfd4cd..da28e10 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -3,7 +3,7 @@ class Seq < String attr_accessor :seq, :seq_type # Method to initialize a new sequence. - def initialize( seq = nil, seq_type = nil ) + def initialize( seq = "", seq_type = nil ) @seq = seq @seq_type = seq_type end @@ -45,7 +45,7 @@ class Seq < String raise "ERROR: Wrap width must be an integer." unless width.is_a? Fixnum raise "ERROR: Cannot wrap sequence to negative width: #{ width }." if width <= 0 @seq.tr!( " \t\n\r", '' ) - @seq.gsub( /.{#{ width }}/, "\\0#{ delimit }" ) + @seq.gsub( /.{#{ width }}/, "\\0#{ delimit }" ).sub( /#{ delimit }$/, "" ) end # Method to wrap and replace a sequence to a given width using a given delimiter. @@ -70,7 +70,7 @@ class Seq < String # Class containing methods specific for amino acid (AA) sequences. class AA < Seq # Method to initialize a new amino acid sequence. - def initialize( seq = nil ) + def initialize( seq = "" ) @seq = seq @seq_type = "AA" end diff --git a/code_ruby/Maasha/test/test_seq.rb b/code_ruby/Maasha/test/test_seq.rb index afda8ab..35565f1 100755 --- a/code_ruby/Maasha/test/test_seq.rb +++ b/code_ruby/Maasha/test/test_seq.rb @@ -245,13 +245,13 @@ class TestSeq < Test::Unit::TestCase # Testing Seq::AA#initialize - def test_Seq#AA_initialize_with_0_args + def test_Seq_AA_initialize_with_0_args s = Seq::AA.new assert_equal( "", s.seq ) assert_equal( "AA", s.seq_type ) end - def test_Seq#AA_initialize_with_1_args + def test_Seq_AA_initialize_with_1_args s = Seq::AA.new( "SEQ" ) assert_equal( "SEQ", s.seq ) assert_equal( "AA", s.seq_type ) -- 2.39.5