]> git.donarmstrong.com Git - biopieces.git/commitdiff
clearning ruby dir
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 3 Jul 2009 14:40:18 +0000 (14:40 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 3 Jul 2009 14:40:18 +0000 (14:40 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@552 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/biopieces.rb [deleted file]
code_ruby/Maasha/lib/biopieces.rb [new file with mode: 0755]
code_ruby/Maasha/lib/seq.rb
code_ruby/Maasha/test/test_seq.rb
code_ruby/Maasha/test_module.rb [deleted file]

diff --git a/code_ruby/Maasha/biopieces.rb b/code_ruby/Maasha/biopieces.rb
deleted file mode 100755 (executable)
index 61d9cd7..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-class BioPieces
-       RECORD_DELIMITER = "\n---\n"
-
-       class Record
-               attr_reader :__hash__
-               def initialize( data )
-                       @__hash__ = data
-               end
-       
-               def method_missing( name, *args, &block )
-                       if args.empty? && @__hash__.has_key?( name ) then
-                               @__hash__[ name ]
-                       else
-                               super # get the original exception
-                       end
-               end
-       
-               def to_s
-                       @__hash__.map { | key, value | "#{ key }: #{ value }" }.join( "\n" ) + RECORD_DELIMITER
-               end
-       
-               def to_hash
-                       @__hash__.dup
-               end
-       end
-       def self.file( path )
-               bp = new( File.open( path ) )
-               yield bp if block_given?
-               bp
-       ensure
-               # if no block was given, the user wants the BioPieces instance
-               # with a still open File so he can read it, so only close if a block
-               # had been given.
-               bp.close if block_given?
-       end
-       def initialize( stream )
-               @stream = stream
-       end
-       def close
-               @stream.close if @stream.respond_to? :close
-       end
-       def record_get
-               return unless block = @stream.gets( RECORD_DELIMITER )
-               block.chomp!( RECORD_DELIMITER )
-               data = Hash[ *block.split( /: |\n/, 2 ) ]
-               Record.new( data )
-       end
-  
-       def each
-               yield record_get until @stream.eof?
-               self # not to have a messy return value
-       end
-end
-
-
-__END__
diff --git a/code_ruby/Maasha/lib/biopieces.rb b/code_ruby/Maasha/lib/biopieces.rb
new file mode 100755 (executable)
index 0000000..61d9cd7
--- /dev/null
@@ -0,0 +1,62 @@
+class BioPieces
+       RECORD_DELIMITER = "\n---\n"
+
+       class Record
+               attr_reader :__hash__
+               def initialize( data )
+                       @__hash__ = data
+               end
+       
+               def method_missing( name, *args, &block )
+                       if args.empty? && @__hash__.has_key?( name ) then
+                               @__hash__[ name ]
+                       else
+                               super # get the original exception
+                       end
+               end
+       
+               def to_s
+                       @__hash__.map { | key, value | "#{ key }: #{ value }" }.join( "\n" ) + RECORD_DELIMITER
+               end
+       
+               def to_hash
+                       @__hash__.dup
+               end
+       end
+       def self.file( path )
+               bp = new( File.open( path ) )
+               yield bp if block_given?
+               bp
+       ensure
+               # if no block was given, the user wants the BioPieces instance
+               # with a still open File so he can read it, so only close if a block
+               # had been given.
+               bp.close if block_given?
+       end
+       def initialize( stream )
+               @stream = stream
+       end
+       def close
+               @stream.close if @stream.respond_to? :close
+       end
+       def record_get
+               return unless block = @stream.gets( RECORD_DELIMITER )
+               block.chomp!( RECORD_DELIMITER )
+               data = Hash[ *block.split( /: |\n/, 2 ) ]
+               Record.new( data )
+       end
+  
+       def each
+               yield record_get until @stream.eof?
+               self # not to have a messy return value
+       end
+end
+
+
+__END__
index ba79c85cd31f729caaa2dbaff67c38dde02eff90..f80d397fbc6878388b725172e3af29e2533b0a46 100644 (file)
@@ -8,6 +8,11 @@ class Seq < String
                @seq_type = seq_type
        end
 
+       # Method for outputting sequence as a String.
+       def to_s
+               @seq
+       end
+
        # Guess the sequence type by analyzing the first 100 residues allowing for ambiguity codes.
        def seq_type_guess
                seq_beg = @seq[ 0, 100 ].upcase
index 7e8c89dd713085a3ac1080d7b02b55d25ff4e274..4297720dcfed260063b3d347a8c9613188ed2b17 100755 (executable)
@@ -28,6 +28,12 @@ class TestSeq < Test::Unit::TestCase
                assert_equal( :DNA, s.seq_type ) 
        end 
 
+       # Testing Seq#to_s
+       def test_to_s
+               s = Seq.new( "ATCG" )
+               assert_equal( "ATCG", s.to_s )
+       end
+
        # Testing Seq#seq_type_guess
 
        def test_seq_type_guess_DNA_uppercase
@@ -150,19 +156,19 @@ class TestSeq < Test::Unit::TestCase
        def test_wrap_with_0_args
                s = Seq.new( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACGACTACGACT" )
 
-               assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.wrap )
+               assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.wrap.to_s )
        end
 
        def test_wrap_with_1_args
                s = Seq.new( "ATCG" )
 
-               assert_equal( "AT\nCG", s.wrap( 2 ) )
+               assert_equal( "AT\nCG", s.wrap( 2 ).to_s )
        end
 
        def test_wrap_with_2_args
                s = Seq.new( "ATCG" )
 
-               assert_equal( "AT\rCG", s.wrap( 2, "\r" ) )
+               assert_equal( "AT\rCG", s.wrap( 2, "\r" ).to_s )
        end
 
        def test_wrap_dont_change_instance_var
@@ -170,7 +176,7 @@ class TestSeq < Test::Unit::TestCase
 
                s.wrap( 2 )
 
-               assert_equal( "ATCG", s.seq )
+               assert_equal( "ATCG", s.to_s )
        end
 
        # Testing Seq#wrap!
@@ -180,7 +186,7 @@ class TestSeq < Test::Unit::TestCase
 
                s.wrap!
 
-               assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.seq )
+               assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.to_s )
        end
 
        def test_wrap_with_1_args!
@@ -188,7 +194,7 @@ class TestSeq < Test::Unit::TestCase
 
                s.wrap!( 2 )
 
-               assert_equal( "AT\nCG", s.seq )
+               assert_equal( "AT\nCG", s.to_s )
        end
 
        def test_wrap_with_2_args!
@@ -196,7 +202,7 @@ class TestSeq < Test::Unit::TestCase
 
                s.wrap!( 2, "\r" )
 
-               assert_equal( "AT\rCG", s.seq )
+               assert_equal( "AT\rCG", s.to_s )
        end
 
        # Testing Seq#generate
@@ -227,7 +233,7 @@ class TestSeq < Test::Unit::TestCase
 
                seq = s.generate( 40 )
 
-               assert_equal( "", s.seq )
+               assert_equal( "", s.to_s )
        end
 
        # Testing Seq#generate!
@@ -235,11 +241,11 @@ class TestSeq < Test::Unit::TestCase
        def test_generate!
                s = Seq.new( "", :AA )
 
-               gen_seq = s.generate!( 40 )
+               gen_seq = s.generate!( 40 ).to_s
 
                assert_equal( 40, gen_seq.length )
                assert_equal( 40, s.seq.length )
-               assert_equal( gen_seq, s.seq )
+               assert_equal( gen_seq, s.to_s )
        end
 
        # Testing Seq::AA#initialize
@@ -247,14 +253,14 @@ class TestSeq < Test::Unit::TestCase
        # test marked for deletion - too simple and not informative
        def test_Seq_AA_initialize_with_0_args
                s = Seq::AA.new
-               assert_equal( "", s.seq )
+               assert_equal( "", s.to_s )
                assert_equal( :AA, s.seq_type )
        end
 
        # test marked for deletion - too simple and not informative
        def test_Seq_AA_initialize_with_1_args
                s = Seq::AA.new( "SEQ" )
-               assert_equal( "SEQ", s.seq )
+               assert_equal( "SEQ", s.to_s )
                assert_equal( :AA,  s.seq_type )
        end
 end
diff --git a/code_ruby/Maasha/test_module.rb b/code_ruby/Maasha/test_module.rb
deleted file mode 100755 (executable)
index a94e234..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class Test
-    puts "Modules Test1 loaded"
-
-    def greet_world
-        puts "Hello"
-    end
-end