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,56 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..']*2, 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation'
4
+
5
+ class TestBioRestrictionEnzymeDoubleStrandedCutLocationPairInEnzymeNotation < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation
9
+
10
+ @obj_1 = @t.new([3,5])
11
+ @obj_2 = @t.new(3, 5)
12
+ @obj_3 = @t.new((3..5))
13
+ @obj_4 = @t.new(-3..5)
14
+ @obj_5 = @t.new(3)
15
+ @obj_6 = @t.new(nil,3)
16
+ @obj_7 = @t.new(3,nil)
17
+ end
18
+
19
+ def test_contents
20
+ assert_equal([3,5], @obj_1)
21
+ assert_equal([3,5], @obj_2)
22
+ assert_equal([3,5], @obj_3)
23
+ assert_equal([-3,5], @obj_4)
24
+ assert_equal([3,nil], @obj_5)
25
+ assert_equal([nil,3], @obj_6)
26
+ assert_equal([3,nil], @obj_7)
27
+ end
28
+
29
+ def test_primary
30
+ assert_equal(3, @obj_1.primary)
31
+ assert_equal(3, @obj_2.primary)
32
+ assert_equal(3, @obj_3.primary)
33
+ assert_equal(-3, @obj_4.primary)
34
+ assert_equal(3, @obj_5.primary)
35
+ assert_equal(nil, @obj_6.primary)
36
+ assert_equal(3, @obj_7.primary)
37
+ end
38
+
39
+ def test_complement
40
+ assert_equal(5, @obj_1.complement)
41
+ assert_equal(5, @obj_2.complement)
42
+ assert_equal(5, @obj_3.complement)
43
+ assert_equal(5, @obj_4.complement)
44
+ assert_equal(nil, @obj_5.complement)
45
+ assert_equal(3, @obj_6.complement)
46
+ assert_equal(nil, @obj_7.complement)
47
+ end
48
+
49
+ def test_argument_error
50
+ assert_raise(ArgumentError) { @t.new([3,5,6]) }
51
+ assert_raise(ArgumentError) { @t.new(0,1) }
52
+ assert_raise(ArgumentError) { @t.new(0,0) }
53
+ assert_raise(ArgumentError) { @t.new('3',5) }
54
+ end
55
+
56
+ end
@@ -0,0 +1,35 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..']*2, 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/double_stranded/cut_locations'
4
+
5
+ class TestBioRestrictionEnzymeDoubleStrandedCutLocations < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair
9
+ @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocations
10
+
11
+ @obj_1 = @t.new([3,5])
12
+ @obj_2 = @t.new(3, 5)
13
+ @obj_3 = @t.new((3..5))
14
+ @obj_4 = @t.new(3..5)
15
+ @obj_5 = @t.new(3)
16
+ @obj_6 = @t.new(nil,3)
17
+ @obj_7 = @t.new(3,nil)
18
+
19
+ @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7)
20
+ end
21
+
22
+ def test_contents
23
+ assert_equal([3,5], @locations[0])
24
+ assert_equal([3,nil], @locations[-1])
25
+ end
26
+
27
+ def test_primary
28
+ assert_equal([3, 3, 3, 3, 3, nil, 3], @locations.primary)
29
+ end
30
+
31
+ def test_complement
32
+ assert_equal([5, 5, 5, 5, nil, 3, nil], @locations.complement)
33
+ end
34
+
35
+ end
@@ -0,0 +1,87 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..']*2, 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation'
4
+
5
+ class TestBioRestrictionEnzymeDoubleStrandedCutLocationsInEnzymeNotation < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @t = Bio::RestrictionEnzyme::DoubleStranded::CutLocationPairInEnzymeNotation
9
+ @tt = Bio::RestrictionEnzyme::DoubleStranded::CutLocationsInEnzymeNotation
10
+
11
+ @obj_1 = @t.new([3,5])
12
+ @obj_2 = @t.new(3, 5)
13
+ @obj_3 = @t.new((3..5))
14
+ @obj_4 = @t.new(-3..5)
15
+ @obj_5 = @t.new(3)
16
+ @obj_6 = @t.new(nil,3)
17
+ @obj_7 = @t.new(3,nil)
18
+ @obj_8 = @t.new(-8, -7)
19
+
20
+ @locations = @tt.new(@obj_1, @obj_2, @obj_3, @obj_4, @obj_5, @obj_6, @obj_7, @obj_8)
21
+ @loc_2 = @tt.new(@t.new(-2,-2), @t.new(1,1))
22
+ @loc_3 = @tt.new(@t.new(1,2))
23
+ end
24
+
25
+ def test_contents
26
+ assert_equal([3,5], @locations[0])
27
+ assert_equal([3,nil], @locations[-2])
28
+ end
29
+
30
+ def test_primary
31
+ assert_equal([3, 3, 3, -3, 3, nil, 3, -8], @locations.primary)
32
+ end
33
+
34
+ def test_complement
35
+ assert_equal([5, 5, 5, 5, nil, 3, nil, -7], @locations.complement)
36
+ end
37
+
38
+ def test_primary_to_array_index
39
+ assert_equal([10, 10, 10, 5, 10, nil, 10, 0], @locations.primary_to_array_index)
40
+ assert_equal([0,2], @loc_2.primary_to_array_index)
41
+ assert_equal([0], @loc_3.primary_to_array_index)
42
+ end
43
+
44
+ def test_primary_to_array_index_class
45
+ assert_equal(Array, @locations.primary_to_array_index.class)
46
+ assert_equal(Array, @loc_2.primary_to_array_index.class)
47
+ end
48
+
49
+ def test_complement_to_array_index
50
+ assert_equal([12, 12, 12, 12, nil, 10, nil, 1], @locations.complement_to_array_index)
51
+ assert_equal([0,2], @loc_2.complement_to_array_index)
52
+ assert_equal([1], @loc_3.complement_to_array_index)
53
+ end
54
+
55
+ def test_complement_to_array_index_class
56
+ assert_equal(Array, @locations.complement_to_array_index.class)
57
+ assert_equal(Array, @loc_2.complement_to_array_index.class)
58
+ end
59
+
60
+ def test_to_array_index
61
+ assert_equal(
62
+ [
63
+ [10, 12],
64
+ [10, 12],
65
+ [10, 12],
66
+ [5, 12],
67
+ [10, nil],
68
+ [nil, 10],
69
+ [10, nil],
70
+ [0, 1]
71
+ ], @locations.to_array_index)
72
+
73
+ assert_equal(
74
+ [
75
+ [0, 0],
76
+ [2, 2],
77
+ ], @loc_2.to_array_index)
78
+
79
+ assert_equal([[0,1]], @loc_3.to_array_index)
80
+ end
81
+
82
+ def test_to_array_index_class
83
+ assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @locations.to_array_index.class)
84
+ assert_equal(Bio::RestrictionEnzyme::DoubleStranded::CutLocations, @loc_2.to_array_index.class)
85
+ end
86
+
87
+ end
@@ -0,0 +1,66 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..']*2, 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation'
4
+
5
+ class TestBioRestrictionEnzymeSingleStrandCutLocationsInEnzymeNotation < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @t = Bio::RestrictionEnzyme::SingleStrand::CutLocationsInEnzymeNotation
9
+ @obj_1 = @t.new([-2,1,3])
10
+ @obj_2 = @t.new(-2,1,3)
11
+ @obj_3 = @t.new(7,1,3)
12
+
13
+ @obj_4 = @t.new(-7,-8,-2,1,3)
14
+ end
15
+
16
+ def test_max
17
+ assert_equal(3, @obj_1.max)
18
+ assert_equal(3, @obj_2.max)
19
+ assert_equal(7, @obj_3.max)
20
+ end
21
+
22
+ def test_min
23
+ assert_equal(-2, @obj_1.min)
24
+ assert_equal(-2, @obj_2.min)
25
+ assert_equal(1, @obj_3.min)
26
+ end
27
+
28
+ def test_to_array_index
29
+ assert_equal([0,2,4], @obj_1.to_array_index)
30
+ assert_equal([0,2,4], @obj_2.to_array_index)
31
+ assert_equal([0,2,6], @obj_3.to_array_index)
32
+
33
+ assert_equal([0, 1, 6, 8, 10], @obj_4.to_array_index)
34
+ end
35
+
36
+ def test_initialize_with_pattern
37
+ @obj_5 = @t.new('n^ng^arraxt^n')
38
+ @obj_6 = @t.new('g^arraxt^n')
39
+ @obj_7 = @t.new('nnn^nn^nga^rraxt^nn')
40
+ @obj_8 = @t.new('^g^arraxt^n')
41
+
42
+ assert_equal([-2,1,7], @obj_5)
43
+ assert_equal([0,2,8], @obj_5.to_array_index)
44
+
45
+ assert_equal([1,7], @obj_6)
46
+ assert_equal([0,6], @obj_6.to_array_index)
47
+
48
+ assert_equal([-4, -2, 2, 7], @obj_7)
49
+ assert_equal([0, 2, 5, 10], @obj_7.to_array_index)
50
+
51
+ assert_equal([-1,1,7], @obj_8)
52
+ assert_equal([0,1,7], @obj_8.to_array_index)
53
+ end
54
+
55
+ def test_argument_error
56
+ assert_raise(ArgumentError) { @t.new([0,1,2]) }
57
+ assert_raise(ArgumentError) { @t.new(0,1,2,0) }
58
+
59
+ assert_raise(ArgumentError) { @t.new([nil,1,2]) }
60
+ assert_raise(ArgumentError) { @t.new(nil,1,2,nil) }
61
+
62
+ assert_raise(ArgumentError) { @t.new([1,1,2]) }
63
+ assert_raise(ArgumentError) { @t.new(1,1,2,2) }
64
+ end
65
+
66
+ end
@@ -0,0 +1,228 @@
1
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'helper.rb')).cleanpath.to_s
2
+
3
+ require 'bio/util/restriction_enzyme/analysis'
4
+ require 'bio/sequence'
5
+
6
+ class TestBioRestrictionEnzymeAnalysis < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @enz = Bio::RestrictionEnzyme
10
+ @t = Bio::RestrictionEnzyme::Analysis
11
+
12
+ @obj_1 = @t.cut('cagagag', 'ag^ag')
13
+ @obj_2 = @t.cut('agagag', 'ag^ag')
14
+ @obj_3 = @t.cut('cagagagt', 'ag^ag')
15
+
16
+ e1 = @enz.new('atgcatgc', [3,3])
17
+ @obj_4 = @t.cut('atgcatgcatgc', e1)
18
+
19
+ @obj_4bd = @t.cut('atgcatgcatgccc', e1, 'cc^c') # mix of always cut and sometimes cut
20
+
21
+ e2 = @enz.new('atgcatgc', [3,5])
22
+ @obj_5 = @t.cut('atgcatgcatgc', e2)
23
+
24
+ e3 = @enz.new('anna', [1,1], [3,3])
25
+ e4 = @enz.new('gg', [1,1])
26
+ @obj_6 = @t.cut('agga', e3, e4)
27
+
28
+ @obj_7 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII')
29
+ @obj_7b = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaaccc', 'EcoRII', 'HincII', 'cc^c')
30
+ @obj_7bd = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaaccc', 'EcoRII', 'HincII', 'cc^c')
31
+
32
+ @obj_8 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII')
33
+
34
+ @obj_9 = @t.cut('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'EcoRII')
35
+ @obj_9 = @t.cut('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'EcoRII', 'HincII')
36
+
37
+ @obj_1d = @t.cut_without_permutations('cagagag', 'ag^ag')
38
+ @obj_2d = @t.cut_without_permutations('agagag', 'ag^ag')
39
+ @obj_3d = @t.cut_without_permutations('cagagagt', 'ag^ag')
40
+
41
+ e1 = @enz.new('atgcatgc', [3,3])
42
+ @obj_4d = @t.cut_without_permutations('atgcatgcatgc', e1)
43
+
44
+ e2 = @enz.new('atgcatgc', [3,5])
45
+ @obj_5d = @t.cut_without_permutations('atgcatgcatgc', e2)
46
+
47
+ e3 = @enz.new('anna', [1,1], [3,3])
48
+ e4 = @enz.new('gg', [1,1])
49
+ @obj_6d = @t.cut_without_permutations('agga', e3, e4)
50
+
51
+ @obj_7d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII')
52
+ @obj_8d = @t.cut_without_permutations('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', 'HincII')
53
+
54
+ @obj_98 = @t.cut('', 'EcoRII', 'HincII')
55
+ @obj_99 = @t.cut_without_permutations('', 'EcoRII', 'HincII')
56
+
57
+ @obj_vr1 = @t.cut('gaccaggaaaaagaccaggaaagcctggaaaagttaac', 'EcoRII', {:view_ranges => true})
58
+ @obj_vr2 = @t.cut('cagagag', {:view_ranges => true}, 'ag^ag')
59
+ end
60
+
61
+ def test_cut
62
+ assert_equal(["ag", "cag"], @obj_1.primary)
63
+ assert_equal(["gtc", "tc"], @obj_1.complement)
64
+ assert_equal(2, @obj_1.size)
65
+ assert_equal(Bio::RestrictionEnzyme::Fragments, @obj_1.class)
66
+ assert_equal(Bio::RestrictionEnzyme::Fragment, @obj_1[0].class)
67
+
68
+ assert_equal(["ag"], @obj_2.primary)
69
+ assert_equal(["ag", "agt", "cag"], @obj_3.primary)
70
+ assert_equal(["atg", "atgcatg", "catg", "catgc"], @obj_4.primary)
71
+
72
+ =begin
73
+ A T G^C A T G C
74
+
75
+ A T G C A T G C A T G C
76
+
77
+ A T G^C A T G^C A T G C
78
+
79
+ A T G C A T G^C A T G C
80
+ =end
81
+
82
+ assert_equal(["atg", "atgcatg", "catgc", "catgcatgc"], @obj_5.primary)
83
+ assert_equal(["a", "ag", "g", "ga"], @obj_6.primary)
84
+ assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_7.primary)
85
+ assert_equal(["aac", "ccaggaaaaaga", "ccaggaaag", "cctggaaaagtt", "ga"], @obj_8.primary)
86
+
87
+ =begin
88
+ e1 = @enz.new('atgcatgc', [3,3])
89
+ @obj_4bd = @t.cut('atgcatgcatgccc', e1, 'cc^c') # mix of sometimes cut and always cut
90
+
91
+ [#<struct Bio::RestrictionEnzyme::Analysis::UniqueFragment
92
+ primary="atgcatg",
93
+ complement="tacgtac">,
94
+ #<struct Bio::RestrictionEnzyme::Analysis::UniqueFragment
95
+ primary="catgcc",
96
+ complement="gtacg ">,
97
+ #<struct Bio::RestrictionEnzyme::Analysis::UniqueFragment
98
+ primary=" c",
99
+ complement="gg">,
100
+ #<struct Bio::RestrictionEnzyme::Analysis::UniqueFragment
101
+ primary="atg",
102
+ complement="tac">,
103
+ #<struct Bio::RestrictionEnzyme::Analysis::UniqueFragment
104
+ primary="catg",
105
+ complement="gtac">]
106
+ =end
107
+ assert_equal(["atg", "atgcatg", "c", "catg", "catgcc"], @obj_4bd.primary)
108
+ assert_equal(["gg", "gtac", "gtacg", "tac", "tacgtac"], @obj_4bd.complement)
109
+ end
110
+
111
+ def test_cut_without_permutations
112
+ assert_equal(["ag", "cag"], @obj_1d.primary)
113
+ assert_equal(["ag"], @obj_2d.primary)
114
+ assert_equal(["ag", "agt", "cag"], @obj_3d.primary)
115
+ assert_equal(["atg", "catg", "catgc"], @obj_4d.primary)
116
+ assert_equal(["atg", "catg", "catgc"], @obj_5d.primary)
117
+ assert_equal(["a", "g"], @obj_6d.primary)
118
+ assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_7d.primary)
119
+ assert_equal(["aac", "ccaggaaaaaga", "ccaggaaag", "cctggaaaagtt", "ga"], @obj_8d.primary)
120
+ end
121
+
122
+ def test_cut_from_bio_sequence_na
123
+ assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzyme('ag^ag').primary )
124
+ assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzymes('ag^ag').primary )
125
+ assert_equal(["ag", "cag"], Bio::Sequence::NA.new('cagagag').cut_with_enzymes('ag^ag', 'EcoRII').primary )
126
+
127
+ # Note how EcoRII needs extra padding on the beginning and ending of the
128
+ # sequence 'ccagg' to make the match since the cut must occur between
129
+ # two nucleotides and can not occur on the very end of the sequence.
130
+ #
131
+ # EcoRII:
132
+ # :blunt: "0"
133
+ # :c2: "5"
134
+ # :c4: "0"
135
+ # :c1: "-1"
136
+ # :pattern: CCWGG
137
+ # :len: "5"
138
+ # :name: EcoRII
139
+ # :c3: "0"
140
+ # :ncuts: "2"
141
+ #
142
+ # -1 1 2 3 4 5
143
+ # 5' - n^c c w g g n - 3'
144
+ # 3' - n g g w c c^n - 5'
145
+ #
146
+ # (w == [at])
147
+
148
+ assert_equal(["ag", "agccagg", "cag"], Bio::Sequence::NA.new('cagagagccagg').cut_with_enzymes('ag^ag', 'EcoRII').primary )
149
+ assert_equal(["ag", "agccagg", "cag"], Bio::Sequence::NA.new('cagagagccagg').cut_with_enzymes('ag^ag').primary )
150
+ assert_equal(:no_cuts_found, Bio::Sequence::NA.new('cagagagccagg').cut_with_enzymes('EcoRII') )
151
+
152
+ assert_equal(["ag", "ag", "cag", "ccaggt"], Bio::Sequence::NA.new('cagagagccaggt').cut_with_enzymes('ag^ag', 'EcoRII').primary )
153
+ assert_equal(["ag", "agccaggt", "cag"], Bio::Sequence::NA.new('cagagagccaggt').cut_with_enzymes('ag^ag').primary )
154
+ assert_equal(["cagagag", "ccaggt"], Bio::Sequence::NA.new('cagagagccaggt').cut_with_enzymes('EcoRII').primary )
155
+ assert_equal(["a", "gtctctcggtcc"], Bio::Sequence::NA.new('cagagagccaggt').cut_with_enzymes('EcoRII').complement )
156
+ end
157
+
158
+ def test_view_ranges
159
+ assert_equal(["ccaggaaaaaga", "ccaggaaag", "cctggaaaagttaac", "ga"], @obj_vr1.primary)
160
+ assert_equal(["ctggtcc", "tttcggacc", "ttttcaattg", "tttttctggtcc"], @obj_vr1.complement)
161
+
162
+ a0 = @obj_vr1[0]
163
+ assert_equal('ga ', a0.primary)
164
+ assert_equal('ctggtcc', a0.complement)
165
+ assert_equal(0, a0.p_left)
166
+ assert_equal(1, a0.p_right)
167
+ assert_equal(0, a0.c_left)
168
+ assert_equal(6, a0.c_right)
169
+
170
+ a1 = @obj_vr1[1]
171
+ assert_equal('ccaggaaaaaga ', a1.primary)
172
+ assert_equal(' tttttctggtcc', a1.complement)
173
+ assert_equal(2, a1.p_left)
174
+ assert_equal(13, a1.p_right)
175
+ assert_equal(7, a1.c_left)
176
+ assert_equal(18, a1.c_right)
177
+
178
+ a2 = @obj_vr1[2]
179
+ assert_equal('ccaggaaag ', a2.primary)
180
+ assert_equal(' tttcggacc', a2.complement)
181
+ assert_equal(14, a2.p_left)
182
+ assert_equal(22, a2.p_right)
183
+ assert_equal(19, a2.c_left)
184
+ assert_equal(27, a2.c_right)
185
+
186
+ a3 = @obj_vr1[3]
187
+ assert_equal('cctggaaaagttaac', a3.primary)
188
+ assert_equal(' ttttcaattg', a3.complement)
189
+ assert_equal(23, a3.p_left)
190
+ assert_equal(37, a3.p_right)
191
+ assert_equal(28, a3.c_left)
192
+ assert_equal(37, a3.c_right)
193
+
194
+ a4 = @obj_vr1[4]
195
+ assert_equal(nil, a4)
196
+
197
+ assert_equal(["ag", "ag", "cag"], @obj_vr2.primary)
198
+ assert_equal(["gtc", "tc", "tc"], @obj_vr2.complement)
199
+
200
+ a0 = @obj_vr2[0]
201
+ assert_equal('cag', a0.primary)
202
+ assert_equal('gtc', a0.complement)
203
+ assert_equal(0, a0.p_left)
204
+ assert_equal(2, a0.p_right)
205
+ assert_equal(0, a0.c_left)
206
+ assert_equal(2, a0.c_right)
207
+
208
+ a1 = @obj_vr2[1]
209
+ assert_equal('ag', a1.primary)
210
+ assert_equal('tc', a1.complement)
211
+ assert_equal(3, a1.p_left)
212
+ assert_equal(4, a1.p_right)
213
+ assert_equal(3, a1.c_left)
214
+ assert_equal(4, a1.c_right)
215
+
216
+ a2 = @obj_vr2[2]
217
+ assert_equal('ag', a2.primary)
218
+ assert_equal('tc', a2.complement)
219
+ assert_equal(5, a2.p_left)
220
+ assert_equal(6, a2.p_right)
221
+ assert_equal(5, a2.c_left)
222
+ assert_equal(6, a2.c_right)
223
+
224
+ a3 = @obj_vr2[3]
225
+ assert_equal(nil, a3)
226
+ end
227
+
228
+ end