]> git.donarmstrong.com Git - biopieces.git/commitdiff
updated ruby code
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 30 Jun 2009 20:33:33 +0000 (20:33 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 30 Jun 2009 20:33:33 +0000 (20:33 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@549 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/lib/seq.rb
code_ruby/Maasha/test/test_seq.rb

index ddfd4cd982d11e1fcb3e6148f4947c547eeb510e..da28e104c704387eab9cbc60bebdb460ea3042d5 100644 (file)
@@ -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
index afda8ab7b1d7292c33babf1671e550ddde36184d..35565f1d37fbf074d6a0bf8f6408c645469cc609 100755 (executable)
@@ -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 )