bio-restriction_enzyme 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/.document +5 -0
  2. data/COPYING.txt +121 -0
  3. data/Gemfile +10 -0
  4. data/LICENSE.txt +7 -0
  5. data/README.rdoc +22 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/bio-restriction_enzyme.gemspec +99 -0
  9. data/lib/bio-restriction_enzyme.rb +1 -0
  10. data/lib/bio/util/restriction_enzyme.rb +218 -0
  11. data/lib/bio/util/restriction_enzyme/analysis.rb +241 -0
  12. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +209 -0
  13. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +99 -0
  14. data/lib/bio/util/restriction_enzyme/double_stranded.rb +313 -0
  15. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +127 -0
  16. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +95 -0
  17. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +30 -0
  18. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +68 -0
  19. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +99 -0
  20. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +16 -0
  21. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +39 -0
  22. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +59 -0
  23. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +249 -0
  24. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +236 -0
  25. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +43 -0
  26. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +33 -0
  27. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +69 -0
  28. data/lib/bio/util/restriction_enzyme/single_strand.rb +193 -0
  29. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +127 -0
  30. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +15 -0
  31. data/lib/bio/util/restriction_enzyme/string_formatting.rb +103 -0
  32. data/test/bio-restriction_enzyme/analysis/test_calculated_cuts.rb +281 -0
  33. data/test/bio-restriction_enzyme/analysis/test_cut_ranges.rb +87 -0
  34. data/test/bio-restriction_enzyme/analysis/test_sequence_range.rb +223 -0
  35. data/test/bio-restriction_enzyme/double_stranded/test_aligned_strands.rb +84 -0
  36. data/test/bio-restriction_enzyme/double_stranded/test_cut_location_pair.rb +58 -0
  37. data/test/bio-restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +56 -0
  38. data/test/bio-restriction_enzyme/double_stranded/test_cut_locations.rb +35 -0
  39. data/test/bio-restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +87 -0
  40. data/test/bio-restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +66 -0
  41. data/test/bio-restriction_enzyme/test_analysis.rb +228 -0
  42. data/test/bio-restriction_enzyme/test_cut_symbol.rb +27 -0
  43. data/test/bio-restriction_enzyme/test_double_stranded.rb +98 -0
  44. data/test/bio-restriction_enzyme/test_single_strand.rb +131 -0
  45. data/test/bio-restriction_enzyme/test_single_strand_complement.rb +131 -0
  46. data/test/bio-restriction_enzyme/test_string_formatting.rb +43 -0
  47. data/test/helper.rb +17 -0
  48. data/test/test_bio-restriction_enzyme.rb +21 -0
  49. metadata +153 -0
@@ -0,0 +1,27 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/cut_symbol'
4
+
5
+ class TestBioRestrictionEnzymeCutSymbol < Test::Unit::TestCase
6
+
7
+ include Bio::RestrictionEnzyme::CutSymbol
8
+
9
+ def setup
10
+ end
11
+
12
+ def test_methods
13
+ assert_equal('^', cut_symbol)
14
+ assert_equal('|', set_cut_symbol('|'))
15
+ assert_equal('|', cut_symbol)
16
+ assert_equal('\\|', escaped_cut_symbol)
17
+ assert_equal(/\|/, re_cut_symbol)
18
+ assert_equal('^', set_cut_symbol('^'))
19
+
20
+ assert_equal(3, "abc^de" =~ re_cut_symbol)
21
+ assert_equal(nil, "abc^de" =~ re_cut_symbol_adjacent)
22
+ assert_equal(3, "abc^^de" =~ re_cut_symbol_adjacent)
23
+ assert_equal(4, "a^bc^^de" =~ re_cut_symbol_adjacent)
24
+ assert_equal(nil, "a^bc^de" =~ re_cut_symbol_adjacent)
25
+ end
26
+
27
+ end
@@ -0,0 +1,98 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/double_stranded'
4
+ require 'bio/sequence'
5
+
6
+ class TestBioRestrictionEnzymeDoubleStranded < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @t = Bio::RestrictionEnzyme::DoubleStranded
10
+ @cl = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation
11
+ @s = String
12
+
13
+
14
+ @obj_1 = @t.new(@s.new('gata'), [1,2])
15
+ @obj_2 = @t.new('gata', [1,2])
16
+ @obj_3 = @t.new('garraxt', [1,2])
17
+ @obj_4 = @t.new('nnnnnnngarraxtnn', [1,2])
18
+
19
+ @obj_5 = @t.new('garraxt', @cl.new(3,2), @cl.new(-2,-1), @cl.new(9,11))
20
+ @obj_6 = @t.new('garraxt', @cl.new(3,2))
21
+ @obj_7 = @t.new('garraxt', @cl.new(3,2), @cl.new(9,11))
22
+
23
+ # @obj_8 = @t.new('garraxt', 3..2, 9..11)
24
+ @obj_9 = @t.new('garraxt', [3,2], [9,11])
25
+
26
+ @obj_10 = @t.new('garraxt', [3,2], [9,11])
27
+
28
+ @obj_11 = @t.new('n^ngar^raxtnn^n')
29
+ @obj_12 = @t.new('nnnn^ngar^raxtnn^nnnn')
30
+
31
+ @obj_13 = @t.new(Bio::RestrictionEnzyme.rebase['EcoRII'])
32
+ @obj_14 = @t.new('EcoRII')
33
+ @obj_15 = @t.new('ecorii')
34
+ end
35
+
36
+ def test_primary
37
+ assert_equal('nngarraxtnnn', @obj_5.primary)
38
+ end
39
+
40
+ def test_primary_with_cut_symbols
41
+ assert_equal('n^ngar^raxtnn^n', @obj_5.primary.with_cut_symbols)
42
+ assert_equal('gar^raxt', @obj_6.primary.with_cut_symbols)
43
+ assert_equal('gar^raxtnn^n', @obj_7.primary.with_cut_symbols)
44
+
45
+ # assert_equal('gar^raxtnn^n', @obj_8.primary.with_cut_symbols)
46
+ assert_equal('gar^raxtnn^n', @obj_9.primary.with_cut_symbols)
47
+
48
+ assert_equal('gar^raxtnn^n', @obj_10.primary.with_cut_symbols)
49
+
50
+ assert_equal('n^ngar^raxtnn^n', @obj_11.primary.with_cut_symbols)
51
+ assert_equal('n^ngar^raxtnn^n', @obj_12.primary.with_cut_symbols)
52
+
53
+ assert_equal('n^ccwgg', @obj_13.primary.with_cut_symbols)
54
+ assert_equal('n^ccwgg', @obj_14.primary.with_cut_symbols)
55
+ assert_equal('n^ccwgg', @obj_15.primary.with_cut_symbols)
56
+ end
57
+
58
+ def test_complement_with_cut_symbols
59
+ assert_equal('n^ct^yytxannnn^n', @obj_5.complement.with_cut_symbols)
60
+ assert_equal('ct^yytxa', @obj_6.complement.with_cut_symbols)
61
+ assert_equal('ct^yytxannnn^n', @obj_7.complement.with_cut_symbols)
62
+
63
+ # assert_equal('ct^yytxannnn^n', @obj_8.complement.with_cut_symbols)
64
+ assert_equal('ct^yytxannnn^n', @obj_9.complement.with_cut_symbols)
65
+
66
+ assert_equal('ct^yytxannnn^n', @obj_10.complement.with_cut_symbols)
67
+
68
+ assert_equal('n^nnctyy^txan^n', @obj_11.complement.with_cut_symbols)
69
+ assert_equal('n^nnctyy^txan^n', @obj_12.complement.with_cut_symbols)
70
+
71
+ assert_equal('ggwcc^n', @obj_13.complement.with_cut_symbols)
72
+ assert_equal('ggwcc^n', @obj_14.complement.with_cut_symbols)
73
+ assert_equal('ggwcc^n', @obj_15.complement.with_cut_symbols)
74
+ end
75
+
76
+ def test_complement
77
+ assert_equal('nctyytxannnnn', @obj_5.complement)
78
+ end
79
+
80
+ def test_cut_locations
81
+ assert_equal([[4, 3], [0, 1], [10, 12]], @obj_5.cut_locations)
82
+ end
83
+
84
+ def test_cut_locations_in_enzyme_notation
85
+ assert_equal([[3, 2], [-2, -1], [9, 11]], @obj_5.cut_locations_in_enzyme_notation)
86
+ end
87
+
88
+ def test_argument_error
89
+ assert_raise(ArgumentError) { @t.new('garraxt', [3,2,9,11]) }
90
+ assert_raise(ArgumentError) { @t.new(Bio::RestrictionEnzyme.rebase['ecorii'] )}
91
+ assert_raise(ArgumentError) { @t.new(Bio::RestrictionEnzyme.rebase['EzzRII']) }
92
+ end
93
+
94
+ # NOTE
95
+ def test_to_re
96
+ end
97
+
98
+ end
@@ -0,0 +1,131 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/single_strand'
4
+
5
+ class TestBioRestrictionEnzymeSingleStrand < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @t = Bio::RestrictionEnzyme::SingleStrand
9
+ @cl = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
10
+ @s = Bio::Sequence::NA
11
+
12
+ @obj_1 = @t.new(@s.new('gata'), @cl.new(-2,1,3))
13
+ @obj_2 = @t.new('gata', -2, 1, 3)
14
+ @obj_3 = @t.new('garraxt', [-2, 1, 7])
15
+ @obj_4 = @t.new('nnnnnnngarraxtnn', [-2, 1, 7])
16
+
17
+ @obj_5 = @t.new('ga^rr^axt')
18
+ @obj_6 = @t.new('^ga^rr^axt')
19
+ @obj_7 = @t.new('n^ngar^raxtnn^n')
20
+ end
21
+
22
+ def test_pattern_palindromic?
23
+ assert_equal(true, @t.new('atgcat', 1).palindromic?)
24
+ assert_equal(false, @t.new('atgcgta', 1).palindromic?)
25
+
26
+ assert_equal(false, @obj_1.palindromic?)
27
+ assert_equal(false, @obj_2.palindromic?)
28
+ assert_equal(false, @obj_3.palindromic?)
29
+ assert_equal(false, @obj_4.palindromic?)
30
+ end
31
+
32
+ def test_stripped
33
+ assert_equal('gata', @obj_1.stripped)
34
+ assert_equal('gata', @obj_2.stripped)
35
+ assert_equal('garraxt', @obj_3.stripped)
36
+ assert_equal('garraxt', @obj_4.stripped)
37
+ end
38
+
39
+ def test_pattern
40
+ assert_equal('nngata', @obj_1.pattern)
41
+ assert_equal('nngata', @obj_2.pattern)
42
+ assert_equal('nngarraxtn', @obj_3.pattern)
43
+ assert_equal('nngarraxtn', @obj_4.pattern)
44
+
45
+ assert_equal('nngata', @obj_1)
46
+ assert_equal('nngata', @obj_2)
47
+ assert_equal('nngarraxtn', @obj_3)
48
+ assert_equal('nngarraxtn', @obj_4)
49
+ end
50
+
51
+ def test_with_cut_symbols
52
+ assert_equal('n^ng^at^a', @obj_1.with_cut_symbols)
53
+ assert_equal('n^ng^at^a', @obj_2.with_cut_symbols)
54
+ assert_equal('n^ng^arraxt^n', @obj_3.with_cut_symbols)
55
+ assert_equal('n^ng^arraxt^n', @obj_4.with_cut_symbols)
56
+ end
57
+
58
+ def test_with_spaces
59
+ assert_equal('n^n g^a t^a', @obj_1.with_spaces)
60
+ assert_equal('n^n g^a t^a', @obj_2.with_spaces)
61
+ assert_equal('n^n g^a r r a x t^n', @obj_3.with_spaces)
62
+ assert_equal('n^n g^a r r a x t^n', @obj_4.with_spaces)
63
+ end
64
+
65
+ def test_cut_locations_in_enzyme_notation
66
+ assert_equal([-2,1,3], @obj_1.cut_locations_in_enzyme_notation)
67
+ assert_equal([-2,1,3], @obj_2.cut_locations_in_enzyme_notation)
68
+ assert_equal([-2,1,7], @obj_3.cut_locations_in_enzyme_notation)
69
+ assert_equal([-2,1,7], @obj_4.cut_locations_in_enzyme_notation)
70
+
71
+ assert_equal([2,4], @obj_5.cut_locations_in_enzyme_notation)
72
+ assert_equal([-1,2,4], @obj_6.cut_locations_in_enzyme_notation)
73
+ assert_equal([-2,3,9], @obj_7.cut_locations_in_enzyme_notation)
74
+ end
75
+
76
+ def test_cut_locations
77
+ assert_equal([0,2,4], @obj_1.cut_locations)
78
+ assert_equal([0,2,4], @obj_2.cut_locations)
79
+ assert_equal([0,2,8], @obj_3.cut_locations)
80
+ assert_equal([0,2,8], @obj_4.cut_locations)
81
+
82
+ assert_equal([1,3], @obj_5.cut_locations)
83
+ assert_equal([0,2,4], @obj_6.cut_locations)
84
+ assert_equal([0,4,10], @obj_7.cut_locations)
85
+ end
86
+
87
+ def test_orientation
88
+ assert_equal([5,3], @obj_1.orientation)
89
+ assert_equal([5,3], @obj_2.orientation)
90
+ assert_equal([5,3], @obj_3.orientation)
91
+ assert_equal([5,3], @obj_4.orientation)
92
+ end
93
+
94
+ def test_creation_with_no_cuts
95
+ @obj_8 = @t.new('garraxt')
96
+ assert_equal([5,3], @obj_8.orientation)
97
+ assert_equal([], @obj_8.cut_locations)
98
+ assert_equal([], @obj_8.cut_locations_in_enzyme_notation)
99
+ assert_equal('garraxt', @obj_8.pattern)
100
+ end
101
+
102
+ # NOTE
103
+ def test_to_re
104
+ end
105
+
106
+ def test_argument_error
107
+ assert_raise(ArgumentError) { @t.new('a', [0,1,2]) }
108
+ assert_raise(ArgumentError) { @t.new('a', 0,1,2,0) }
109
+
110
+ assert_raise(ArgumentError) { @t.new('a', [nil,1,2]) }
111
+ assert_raise(ArgumentError) { @t.new('a', nil,1,2,nil) }
112
+
113
+ assert_raise(ArgumentError) { @t.new('a', [1,1,2]) }
114
+ assert_raise(ArgumentError) { @t.new('a', 1,1,2,2) }
115
+
116
+ # NOTE t| 2009-09-19 commented out for library efficiency
117
+ # re: validate_args(sequence, c) in util/restriction_enzyme/single_strand/single_strand.rb
118
+ # assert_raise(ArgumentError) { @t.new(1, [1,2,3]) }
119
+ # assert_raise(ArgumentError) { @t.new('gaat^aca', [1,2,3]) }
120
+ # assert_raise(ArgumentError) { @t.new('gaat^^aca') }
121
+ # assert_raise(ArgumentError) { @t.new('z', [1,2,3]) }
122
+ #
123
+ # assert_raise(ArgumentError) { @t.new('g', [0,1,2]) }
124
+ # assert_raise(ArgumentError) { @t.new('g', 0,1,2,0) }
125
+ # assert_raise(ArgumentError) { @t.new('g', [0,1,1,2]) }
126
+ # assert_raise(ArgumentError) { @t.new('g', 0,1,1,2,2) }
127
+ # assert_raise(ArgumentError) { @t.new(1,2,3) }
128
+ # assert_raise(ArgumentError) { @t.new(1,2,'g') }
129
+ end
130
+
131
+ end
@@ -0,0 +1,131 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/single_strand_complement'
4
+
5
+ class TestBioRestrictionEnzymeSingleStrandComplement < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @t = Bio::RestrictionEnzyme::SingleStrandComplement
9
+ @cl = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
10
+ @s = Bio::Sequence::NA
11
+
12
+ @obj_1 = @t.new(@s.new('gata'), @cl.new(-2,1,3))
13
+ @obj_2 = @t.new('gata', -2, 1, 3)
14
+ @obj_3 = @t.new('garraxt', [-2, 1, 7])
15
+ @obj_4 = @t.new('nnnnnnngarraxtnn', [-2, 1, 7])
16
+
17
+ @obj_5 = @t.new('ga^rr^axt')
18
+ @obj_6 = @t.new('^ga^rr^axt')
19
+ @obj_7 = @t.new('n^ngar^raxtnn^n')
20
+ end
21
+
22
+ def test_pattern_palindromic?
23
+ assert_equal(true, @t.new('atgcat', 1).palindromic?)
24
+ assert_equal(false, @t.new('atgcgta', 1).palindromic?)
25
+
26
+ assert_equal(false, @obj_1.palindromic?)
27
+ assert_equal(false, @obj_2.palindromic?)
28
+ assert_equal(false, @obj_3.palindromic?)
29
+ assert_equal(false, @obj_4.palindromic?)
30
+ end
31
+
32
+ def test_stripped
33
+ assert_equal('gata', @obj_1.stripped)
34
+ assert_equal('gata', @obj_2.stripped)
35
+ assert_equal('garraxt', @obj_3.stripped)
36
+ assert_equal('garraxt', @obj_4.stripped)
37
+ end
38
+
39
+ def test_pattern
40
+ assert_equal('nngata', @obj_1.pattern)
41
+ assert_equal('nngata', @obj_2.pattern)
42
+ assert_equal('nngarraxtn', @obj_3.pattern)
43
+ assert_equal('nngarraxtn', @obj_4.pattern)
44
+
45
+ assert_equal('nngata', @obj_1)
46
+ assert_equal('nngata', @obj_2)
47
+ assert_equal('nngarraxtn', @obj_3)
48
+ assert_equal('nngarraxtn', @obj_4)
49
+ end
50
+
51
+ def test_with_cut_symbols
52
+ assert_equal('n^ng^at^a', @obj_1.with_cut_symbols)
53
+ assert_equal('n^ng^at^a', @obj_2.with_cut_symbols)
54
+ assert_equal('n^ng^arraxt^n', @obj_3.with_cut_symbols)
55
+ assert_equal('n^ng^arraxt^n', @obj_4.with_cut_symbols)
56
+ end
57
+
58
+ def test_with_spaces
59
+ assert_equal('n^n g^a t^a', @obj_1.with_spaces)
60
+ assert_equal('n^n g^a t^a', @obj_2.with_spaces)
61
+ assert_equal('n^n g^a r r a x t^n', @obj_3.with_spaces)
62
+ assert_equal('n^n g^a r r a x t^n', @obj_4.with_spaces)
63
+ end
64
+
65
+ def test_cut_locations_in_enzyme_notation
66
+ assert_equal([-2,1,3], @obj_1.cut_locations_in_enzyme_notation)
67
+ assert_equal([-2,1,3], @obj_2.cut_locations_in_enzyme_notation)
68
+ assert_equal([-2,1,7], @obj_3.cut_locations_in_enzyme_notation)
69
+ assert_equal([-2,1,7], @obj_4.cut_locations_in_enzyme_notation)
70
+
71
+ assert_equal([2,4], @obj_5.cut_locations_in_enzyme_notation)
72
+ assert_equal([-1,2,4], @obj_6.cut_locations_in_enzyme_notation)
73
+ assert_equal([-2,3,9], @obj_7.cut_locations_in_enzyme_notation)
74
+ end
75
+
76
+ def test_cut_locations
77
+ assert_equal([0,2,4], @obj_1.cut_locations)
78
+ assert_equal([0,2,4], @obj_2.cut_locations)
79
+ assert_equal([0,2,8], @obj_3.cut_locations)
80
+ assert_equal([0,2,8], @obj_4.cut_locations)
81
+
82
+ assert_equal([1,3], @obj_5.cut_locations)
83
+ assert_equal([0,2,4], @obj_6.cut_locations)
84
+ assert_equal([0,4,10], @obj_7.cut_locations)
85
+ end
86
+
87
+ def test_orientation
88
+ assert_equal([3,5], @obj_1.orientation)
89
+ assert_equal([3,5], @obj_2.orientation)
90
+ assert_equal([3,5], @obj_3.orientation)
91
+ assert_equal([3,5], @obj_4.orientation)
92
+ end
93
+
94
+ def test_creation_with_no_cuts
95
+ @obj_8 = @t.new('garraxt')
96
+ assert_equal([3,5], @obj_8.orientation)
97
+ assert_equal([], @obj_8.cut_locations)
98
+ assert_equal([], @obj_8.cut_locations_in_enzyme_notation)
99
+ assert_equal('garraxt', @obj_8.pattern)
100
+ end
101
+
102
+ # NOTE
103
+ def test_to_re
104
+ end
105
+
106
+ def test_argument_error
107
+ assert_raise(ArgumentError) { @t.new('a', [0,1,2]) }
108
+ assert_raise(ArgumentError) { @t.new('a', 0,1,2,0) }
109
+
110
+ assert_raise(ArgumentError) { @t.new('a', [nil,1,2]) }
111
+ assert_raise(ArgumentError) { @t.new('a', nil,1,2,nil) }
112
+
113
+ assert_raise(ArgumentError) { @t.new('a', [1,1,2]) }
114
+ assert_raise(ArgumentError) { @t.new('a', 1,1,2,2) }
115
+
116
+ # NOTE t| 2009-09-19 commented out for library efficiency
117
+ # re: validate_args(sequence, c) in util/restriction_enzyme/single_strand/single_strand.rb
118
+ # assert_raise(ArgumentError) { @t.new(1, [1,2,3]) }
119
+ # assert_raise(ArgumentError) { @t.new('gaat^aca', [1,2,3]) }
120
+ # assert_raise(ArgumentError) { @t.new('gaat^^aca') }
121
+ # assert_raise(ArgumentError) { @t.new('z', [1,2,3]) }
122
+ #
123
+ # assert_raise(ArgumentError) { @t.new('g', [0,1,2]) }
124
+ # assert_raise(ArgumentError) { @t.new('g', 0,1,2,0) }
125
+ # assert_raise(ArgumentError) { @t.new('g', [0,1,1,2]) }
126
+ # assert_raise(ArgumentError) { @t.new('g', 0,1,1,2,2) }
127
+ # assert_raise(ArgumentError) { @t.new(1,2,3) }
128
+ # assert_raise(ArgumentError) { @t.new(1,2,'g') }
129
+ end
130
+
131
+ end
@@ -0,0 +1,43 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/string_formatting'
4
+
5
+ class TestBioRestrictionEnzymeStringFormatting < Test::Unit::TestCase
6
+
7
+ include Bio::RestrictionEnzyme::StringFormatting
8
+
9
+ def setup
10
+ @t = String
11
+ @obj_1 = @t.new('gata')
12
+ @obj_2 = @t.new('garraxt')
13
+ @obj_3 = @t.new('gArraXT')
14
+ @obj_4 = @t.new('nnnnnnngarraxtnn')
15
+ end
16
+
17
+ def test_strip_padding
18
+ assert_equal('gata', strip_padding(@obj_1))
19
+ assert_equal('garraxt', strip_padding(@obj_2))
20
+ assert_equal('gArraXT', strip_padding(@obj_3))
21
+ assert_equal('garraxt', strip_padding(@obj_4))
22
+ end
23
+
24
+ def test_left_padding
25
+ assert_equal('', left_padding(@obj_1))
26
+ assert_equal('', left_padding(@obj_2))
27
+ assert_equal('', left_padding(@obj_3))
28
+ assert_equal('nnnnnnn', left_padding(@obj_4))
29
+ end
30
+
31
+ def test_right_padding
32
+ assert_equal('', right_padding(@obj_1))
33
+ assert_equal('', right_padding(@obj_2))
34
+ assert_equal('', right_padding(@obj_3))
35
+ assert_equal('nn', right_padding(@obj_4))
36
+ end
37
+
38
+ def test_add_spacing
39
+ assert_equal('n^n g^a t^a', add_spacing('n^ng^at^a') )
40
+ assert_equal('n^n g^a r r a x t^n', add_spacing('n^ng^arraxt^n') )
41
+ end
42
+
43
+ end
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'bio-restriction_enzyme'
15
+
16
+ class Test::Unit::TestCase
17
+ end