bio-ensembl 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.document +5 -0
  2. data/Gemfile +20 -0
  3. data/Gemfile.lock +40 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +71 -0
  7. data/VERSION +1 -0
  8. data/bin/ensembl +40 -0
  9. data/bin/variation_effect_predictor +106 -0
  10. data/bio-ensembl.gemspec +190 -0
  11. data/lib/bio-ensembl.rb +65 -0
  12. data/lib/bio-ensembl/core/activerecord.rb +1812 -0
  13. data/lib/bio-ensembl/core/collection.rb +64 -0
  14. data/lib/bio-ensembl/core/project.rb +262 -0
  15. data/lib/bio-ensembl/core/slice.rb +657 -0
  16. data/lib/bio-ensembl/core/transcript.rb +409 -0
  17. data/lib/bio-ensembl/core/transform.rb +95 -0
  18. data/lib/bio-ensembl/db_connection.rb +205 -0
  19. data/lib/bio-ensembl/variation/activerecord.rb +536 -0
  20. data/lib/bio-ensembl/variation/variation_feature.rb +376 -0
  21. data/lib/bio-ensembl/variation/variation_feature62.rb +444 -0
  22. data/samples/ensembl_genomes_example.rb +60 -0
  23. data/samples/examples_perl_tutorial.rb +125 -0
  24. data/samples/small_example_ruby_api.rb +34 -0
  25. data/samples/variation_effect_predictor_data.txt +4 -0
  26. data/samples/variation_example.rb +67 -0
  27. data/test/data/seq_c6qbl.fa +10 -0
  28. data/test/data/seq_cso19_coding.fa +16 -0
  29. data/test/data/seq_cso19_transcript.fa +28 -0
  30. data/test/data/seq_drd3_gene.fa +838 -0
  31. data/test/data/seq_drd3_transcript.fa +22 -0
  32. data/test/data/seq_drd4_transcript.fa +24 -0
  33. data/test/data/seq_forward_composite.fa +1669 -0
  34. data/test/data/seq_par_boundary.fa +169 -0
  35. data/test/data/seq_rnd3_transcript.fa +47 -0
  36. data/test/data/seq_ub2r1_coding.fa +13 -0
  37. data/test/data/seq_ub2r1_gene.fa +174 -0
  38. data/test/data/seq_ub2r1_transcript.fa +26 -0
  39. data/test/data/seq_y.fa +2 -0
  40. data/test/default/test_connection.rb +60 -0
  41. data/test/default/test_releases.rb +130 -0
  42. data/test/ensembl_genomes/test_collection.rb +122 -0
  43. data/test/ensembl_genomes/test_gene.rb +46 -0
  44. data/test/ensembl_genomes/test_slice.rb +65 -0
  45. data/test/ensembl_genomes/test_variation.rb +38 -0
  46. data/test/helper.rb +18 -0
  47. data/test/release_50/core/test_project.rb +210 -0
  48. data/test/release_50/core/test_project_human.rb +52 -0
  49. data/test/release_50/core/test_relationships.rb +72 -0
  50. data/test/release_50/core/test_sequence.rb +170 -0
  51. data/test/release_50/core/test_slice.rb +116 -0
  52. data/test/release_50/core/test_transcript.rb +125 -0
  53. data/test/release_50/core/test_transform.rb +217 -0
  54. data/test/release_50/variation/test_activerecord.rb +138 -0
  55. data/test/release_50/variation/test_variation.rb +79 -0
  56. data/test/release_53/core/test_gene.rb +61 -0
  57. data/test/release_53/core/test_project.rb +91 -0
  58. data/test/release_53/core/test_project_human.rb +61 -0
  59. data/test/release_53/core/test_slice.rb +42 -0
  60. data/test/release_53/core/test_transform.rb +57 -0
  61. data/test/release_53/variation/test_activerecord.rb +137 -0
  62. data/test/release_53/variation/test_variation.rb +66 -0
  63. data/test/release_56/core/test_gene.rb +61 -0
  64. data/test/release_56/core/test_project.rb +91 -0
  65. data/test/release_56/core/test_slice.rb +49 -0
  66. data/test/release_56/core/test_transform.rb +57 -0
  67. data/test/release_56/variation/test_activerecord.rb +141 -0
  68. data/test/release_56/variation/test_consequence.rb +131 -0
  69. data/test/release_56/variation/test_variation.rb +63 -0
  70. data/test/release_60/core/test_gene.rb +61 -0
  71. data/test/release_60/core/test_project_human.rb +34 -0
  72. data/test/release_60/core/test_slice.rb +42 -0
  73. data/test/release_60/core/test_transcript.rb +120 -0
  74. data/test/release_60/core/test_transform.rb +57 -0
  75. data/test/release_60/variation/test_activerecord.rb +216 -0
  76. data/test/release_60/variation/test_consequence.rb +153 -0
  77. data/test/release_60/variation/test_variation.rb +64 -0
  78. data/test/release_62/core/test_gene.rb +42 -0
  79. data/test/release_62/variation/test_activerecord.rb +86 -0
  80. data/test/release_62/variation/test_consequence.rb +191 -0
  81. metadata +287 -0
@@ -0,0 +1,52 @@
1
+ #
2
+ # = test/unit/test_project.rb - Unit test for Ensembl::Core
3
+ #
4
+ # Copyright:: Copyright (C) 2007
5
+ # Jan Aerts <http://jandot.myopenid.com>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
10
+ include Ensembl::Core
11
+
12
+ DBConnection.connect('homo_sapiens', 50)
13
+
14
+ class AssemblyExceptions < Test::Unit::TestCase
15
+ def test_chr_x
16
+ source_slice = Slice.fetch_by_region('chromosome','X', 2709497, 2709520)
17
+ assert_equal('tagttatagattaaaagaagttaa', source_slice.seq)
18
+ end
19
+
20
+ def test_slice_overlapping_PAR_and_allosome
21
+ source_slice = Slice.fetch_by_region('chromosome','Y',2709500,2709540)
22
+ target_slices = source_slice.project('contig')
23
+ assert_equal('contig::AC006209.25.1.141759:23323:23343:-1', target_slices[0].display_name)
24
+ assert_equal('contig::AC006040.3.1.186504:57272:57291:1', target_slices[1].display_name)
25
+ end
26
+
27
+ def test_seq_slice_overlapping_PAR
28
+ seq = ''
29
+ File.open('test/data/seq_y.fa').reject{|l| l=~/^>/}.each do |line|
30
+ line.chomp!
31
+ seq += line
32
+ end
33
+ seq.downcase!
34
+
35
+ source_slice = Slice.fetch_by_region('chromosome', 'Y', 2709497, 2709542)
36
+ assert_equal(seq.downcase, source_slice.seq)
37
+ end
38
+
39
+ # The MHC haplotypes for human are not implemented yet, so we raise an error
40
+ # in the code.
41
+ def test_seq_slice_overlapping_HAP
42
+ seq = ''
43
+ File.open('test/data/seq_c6qbl.fa').reject{|l| l=~/^>/}.each do |line|
44
+ line.chomp!
45
+ seq += line
46
+ end
47
+ seq.downcase!
48
+
49
+ source_slice = Slice.fetch_by_region('chromosome', 'c6_QBL', 33451191, 33451690)
50
+ assert_raise(NotImplementedError) {source_slice.seq}
51
+ end
52
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ # = test/unit/test_transfers.rb - Unit test for Ensembl::Core
3
+ #
4
+ # Copyright:: Copyright (C) 2007
5
+ # Jan Aerts <http://jandot.myopenid.com>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
10
+
11
+
12
+ include Ensembl::Core
13
+
14
+ DBConnection.connect('homo_sapiens', 50)
15
+
16
+ # Let's see if we can 'find' things
17
+ class SimpleRecordsTest < Test::Unit::TestCase
18
+ def setup
19
+ @sry_gene = Gene.find(34927)
20
+ @sry_transcript = Transcript.find(60290)
21
+ end
22
+
23
+ def test_coord_system
24
+ coord_system = CoordSystem.find(17)
25
+ assert_equal('chromosome', coord_system.name)
26
+ end
27
+
28
+ def test_coord_system_toplevel
29
+ coord_system = CoordSystem.find(17).find_toplevel
30
+ assert_equal('chromosome', coord_system.name)
31
+ end
32
+
33
+ def test_coord_system_seqlevel
34
+ coord_system = CoordSystem.find(17).find_seqlevel
35
+ assert_equal('contig', coord_system.name)
36
+ end
37
+
38
+ def test_display_label
39
+ assert_equal('SRY', @sry_gene.display_label)
40
+ assert_equal('SRY', @sry_gene.display_name)
41
+ assert_equal('SRY', @sry_gene.label)
42
+ assert_equal('SRY', @sry_gene.name)
43
+
44
+ assert_equal('SRY-001', @sry_transcript.display_label)
45
+ assert_equal('SRY-001', @sry_transcript.display_name)
46
+ assert_equal('SRY-001', @sry_transcript.label)
47
+ assert_equal('SRY-001', @sry_transcript.name)
48
+ end
49
+ end
50
+
51
+ class RelationshipsTest < Test::Unit::TestCase
52
+ def test_go_terms
53
+ gene = Gene.find(34928)
54
+ assert_equal(["GO:0005576", "GO:0042742"], gene.go_terms.sort)
55
+ end
56
+
57
+ def test_hgnc
58
+ gene = Gene.find_by_stable_id('ENSG00000169740')
59
+ assert_equal('ZNF32', gene.hgnc)
60
+ end
61
+ end
62
+
63
+ class ReflectionTest < Test::Unit::TestCase
64
+ def test_has_what
65
+ assert_equal(Gene.has_what.sort.join(';'), 'attrib_types;gene_attribs;gene_stable_id;object_xrefs;transcripts;xrefs')
66
+ end
67
+
68
+ def test_belongs_to_what
69
+ assert_equal(Gene.belongs_to_what.sort.join(';'), 'analysis;seq_region')
70
+ end
71
+ end
72
+
@@ -0,0 +1,170 @@
1
+ #
2
+ # = test/unit/test_seq.rb - Unit test for Ensembl::Core
3
+ #
4
+ # Copyright:: Copyright (C) 2007
5
+ # Jan Aerts <http://jandot.myopenid.com>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
10
+
11
+
12
+ include Ensembl::Core
13
+
14
+ DBConnection.connect('homo_sapiens', 50)
15
+
16
+ #class SequenceForSlice < Test::Unit::TestCase
17
+ # def test_forward_strand_seqlevel
18
+ # slice = Slice.new(SeqRegion.find(170931),5,15)
19
+ # seq = 'gcagtggtgtg'
20
+ # assert_equal(seq, slice.seq)
21
+ # end
22
+ #
23
+ # def test_reverse_strand_seqlevel
24
+ # slice = Slice.new(SeqRegion.find(170931),5,15, -1)
25
+ # seq = 'cacaccactgc'
26
+ # assert_equal(seq, slice.seq)
27
+ # end
28
+ #
29
+ # def test_forward_strand_not_seqlevel_single_target
30
+ # slice = Slice.new(SeqRegion.find(226044),69437100,69437110)
31
+ # seq = 'gtctatttaca'
32
+ # assert_equal(seq, slice.seq)
33
+ # end
34
+ #
35
+ # def test_reverse_strand_not_seqlevel_single_target
36
+ # slice = Slice.new(SeqRegion.find(226044),69437100,69437110,-1)
37
+ # seq = 'tgtaaatagac'
38
+ # assert_equal(seq, slice.seq)
39
+ # end
40
+ #
41
+ # def test_forward_strand_not_seqlevel_composite_target
42
+ # seq = ''
43
+ # File.open('../../data/seq_forward_composite.fa').reject{|l| l=~/^>/}.each do |line|
44
+ # line.chomp!
45
+ # seq += line
46
+ # end
47
+ # seq.downcase!
48
+ # slice = Slice.new(SeqRegion.find(226044),69387650,69487649)
49
+ # assert_equal(seq, slice.seq)
50
+ # end
51
+ #
52
+ # def test_reverse_strand_not_seqlevel_composite_target
53
+ # slice = Slice.new(SeqRegion.find(226044),69437061,69437160,-1)
54
+ # assert_equal('nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatgtaaatagacaactaacaagatagctgagattgtttccttatccagaca', slice.seq)
55
+ # end
56
+ #
57
+ #end
58
+ #
59
+ #class SequenceForUnsplicedFeature < Test::Unit::TestCase
60
+ # def test_forward_strand_seqlevel
61
+ # marker_feature = MarkerFeature.find(1323757)
62
+ # marker_seq = 'ggcttacttggaaaggtctcttccaacccaatattattcaaatactttcaattttcttctaatgtttttagtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtggttttgttttatttcttttaattctctgatacatttagaatttcttttattattttattttattttattatttatttatttatttttgagacagagttttgctc'
63
+ # assert_equal(marker_seq, marker_feature.seq)
64
+ # end
65
+ #
66
+ # def test_reverse_strand_seqlevel
67
+ # gene = Gene.find_by_name('ANKRD56')
68
+ #
69
+ # ankrd56_seq = 'atggcccgagagctgagccaggaggcactactggactttctgtgccaggctgggggccgcgtgaccaacgctgccttgctgagccacttcaagagctttctccgagaccccgacgcgtcccccagccagcaccagcaccgccgcgagctcttcaagggcttcgtcaactcggtcgccgcagtgcgccaggaccccgacggcaccaagtacgtggtgctcaagaggagatacagggaccttttgggggaggaggggctgcagcgaccccgcgagccgcccgcggccgcccccagtgcagggggagctgcgccctgctccccgcgaggcgcgcgccggggggagccgccccagcagcagcccaggcggcggcggcgcgagaaggagccggaggaggagccagcaggtgcagcagccagagccgccgacgcagcttgcaatggactcccgggcagcgactcccgtagggcgcccgggaagggcggcggatcgaagggcagtcccggacagaggccgccggtgcccgcagctgcagcggcaggggcccaggcgagagcgagctgcgcggcggcgaagacgcagggccgctgctgctgggaatgcctccagaacaacctggctgtactgccgggagagctcggcgcactcccgcactcggccaccgcggaggagaagccggcacgggctctgcctgcccaggatgaccgcggggcttccagggagcgggaagaaggcgcgctagctgagccggcgcctgtgcctgcagtggctcactcgcctcccgccaccgtcgaggctgcgacaagcagggcttccccgcctgctctcctgcccggccccgctccccgcggagaccggccggagctgctgacccccagctccctgcattattcgaccctgcagcagcagcagcagcgcactcgagagtgggtggccaggcacccgcaggtgcccgaggcccgtgatcagggccctatccgcgcctggtcggtgctgccagacaacttcctccagctgcccttggaacccggctccacggagcctaattcagagccgccagacccctgtctttcctcgcactctctctttcctgttgttccggatgagtcctgggaatcctgggcggggaacccttcattgactgtctttcgcagcattcgttgtcagctgtccctccaagatctggatgactttgtggaccaggagagtgatggcagtgaggagagcagcagtgggcccaaagactccccgggggcttctgaagaggggctgcaggttgtcttgggaaccccagatagggggaagctcaggaatccagctgggggcctttctgtatctcggaaggagggcagccccagccggagccctcagggtctcagaaacagaggggatggtcacatctctcagcaggtccctgcaggggctaatggccttgcaggccaccccctgaagcctttgccttggccagttcctaagttaaggaggtccctcaggaggagctctctggcagggagagccaaattgtcctcctctgatgaggagtacctcgatgagggcttgctgaaaagaagtcggcgcccacctcgatccaggaagccctccaaggcaggaacggcacccagcccaagggttgatgcaggtttatcactaaaacttgcagaggttaaggctgttgtggccgagcggggttggcgacacagcctgtgggtccccagtggggaggggtctgcagccttggccccccacagaacttctgagcacaaatcatccctggttccactagatgccagggagcatgagtggattgtgaagcttgccagtggctcctggattcaggtgtggactttgttctgggaggaccctcaactggccttgcacaaagactttttgactgggtacactgcgttgcactggatagccaaacatggtgacctcagggcccttcaggacttggtgtctggagcaaagaaggcagggattgtccttgatgtaaacgtgaggtccagttgtggatataccccgctgcaccttgcagccattcacggccaccagggggtcatcaaattgctagtgcaaaggttggcttctcgggtaaatgtcagggacagcagtgggaagaagccatggcagtatctaaccagtaatacctctggggaaatatggcagctgttgggagctcctcggggcaagcccattttccctgtctatcccttagttggaagttcttcccctaccagaaaggccaagagcaaggaaatatctagaagtgtcacccgaaaaacttccttcgctgcactactcaaaagtcagcacaacaagtggaaactggccaaccagtatgagaaattccacagtccaagggaaagagaagagtatagtgactga'
70
+ # assert_equal(ankrd56_seq, gene.seq)
71
+ # end
72
+ #
73
+ # def test_reverse_strand_not_seqlevel
74
+ # gene = Gene.find_by_name('DRD3')
75
+ # drd3_gene_seq = ''
76
+ # File.open('../../data/seq_drd3_gene.fa').reject{|l| l=~/^>/}.each do |line|
77
+ # line.chomp!
78
+ # drd3_gene_seq += line
79
+ # end
80
+ # drd3_gene_seq.downcase!
81
+ # assert_equal(drd3_gene_seq, gene.seq)
82
+ #
83
+ # end
84
+ #
85
+ # def test_exon
86
+ # exon = Exon.find(719588)
87
+ # assert_equal('atggcatctctgagccagctgagtggccacctgaactacacctgtggggcagagaactccacaggtgccagccaggcccgcccacatgcctactatgccctctcctactgcgcgctcatcctggccatcgtcttcggcaatggcctggtgtgcatggctgtgctgaaggagcgggccctgcagactaccaccaactacttagtagtgagcctggctgtggcagacttgctggtggccaccttggtgatgccctgggtggtatacctggag', exon.seq)
88
+ # end
89
+ #
90
+ #end
91
+
92
+ class SequenceForSlicedFeature < Test::Unit::TestCase
93
+ def test_transcript_foward
94
+ transcript = Transcript.find(73491) # UB2R1 = CDC34
95
+ ub2r1_transcript_seq = ''
96
+ File.open('test/data/seq_ub2r1_transcript.fa').reject{|l| l=~/^>/}.each do |line|
97
+ line.chomp!
98
+ ub2r1_transcript_seq += line
99
+ end
100
+ ub2r1_transcript_seq.downcase!
101
+ assert_equal(ub2r1_transcript_seq, transcript.seq)
102
+
103
+ end
104
+
105
+ def test_transcript_reverse
106
+ transcript = Transcript.find(107548)
107
+ rnd3_transcript_seq = ''
108
+ File.open('test/data/seq_rnd3_transcript.fa').reject{|l| l=~/^>/}.each do |line|
109
+ line.chomp!
110
+ rnd3_transcript_seq += line
111
+ end
112
+ rnd3_transcript_seq.downcase!
113
+ assert_equal(rnd3_transcript_seq, transcript.seq)
114
+ end
115
+
116
+ end
117
+
118
+ class SequenceForCDS < Test::Unit::TestCase
119
+ def setup
120
+ # Transcript tr_fw is ENST00000215574
121
+ @tr_fw = Transcript.find(73491)
122
+ # Transcript tr_rev is ENST00000315489
123
+ @tr_rev = Transcript.find(73411)
124
+ end
125
+
126
+ def test_cds_fw
127
+ ub2r1_coding_seq = ''
128
+ File.open('test/data/seq_ub2r1_coding.fa').reject{|l| l=~/^>/}.each do |line|
129
+ line.chomp!
130
+ ub2r1_coding_seq += line
131
+ end
132
+ ub2r1_coding_seq.downcase!
133
+ assert_equal(ub2r1_coding_seq, @tr_fw.cds_seq)
134
+ end
135
+
136
+ def test_cds_rev
137
+ cso19_coding_seq = ''
138
+ File.open('test/data/seq_cso19_coding.fa').reject{|l| l=~/^>/}.each do |line|
139
+ line.chomp!
140
+ cso19_coding_seq += line
141
+ end
142
+ cso19_coding_seq.downcase!
143
+ assert_equal(cso19_coding_seq, @tr_rev.cds_seq)
144
+ end
145
+
146
+ def test_five_prime_utr_fw
147
+ assert_equal('GGCAAGCGCCGGTGGGGCGGCGGCGCCAGAGCTGCTGGAGCGCTCGGGGTCCCCGGGCGGCGGCGGCGGCGCAGAGGAGGAGGCAGGCGGCGGCCCCGGTGGCTCCCCCCCGGACGGTGCGCGGCCCGGCCCGTCTCGCGAACTCGCGGTGGTCGCGCGGCCCCGCGCTGCTCCGACCCCGGGCCCCTCCGCCGCCGCC'.downcase, @tr_fw.five_prime_utr_seq)
148
+ end
149
+
150
+ def test_five_primer_utr_rev
151
+ assert_equal('ACTCGATCCCGGCCCCACTTCCAGGCCAGTGTCCGGCCGACCAGCCTGCCTTGGGCCAGGGCCCCACGACTCCCTGCTGCGGGACAAGAGGCCGTCTGTGCGGCTGTGGTCGTGGGAGGGTGTGGTGAGGCCGTGAAGGTGGGGACGGTGCCTGGGCCTGTGGCCGCCAGAGCTGCTGCGGCTCAGAAGGTAGCACCAGGCCCCGTGGGTGCTGTGGGGGCCATCGCCTGCCCACC'.downcase, @tr_rev.five_prime_utr_seq)
152
+ end
153
+
154
+ def test_three_prime_utr_fw
155
+ assert_equal('CACCACCAGAATAAACTTGCCGAGTTTACCTCACTAGGGCCGGACCCGTGGCTCCTTAGACGACAGACTACCTCACGGAGGTTTTGTGCTGGTCCCCGTCTCCTCTGGTTGTTTCGTTTTGGCTTTTTCTCCCTCCCCATGTCTGTTCTGGGTTTTCACGTGCTTCAGAGAAGAGGGGCTGCCCCACCGCCACTCACGTCACTCGGGGCTCGGTGGACGGGCCCAGGGTGGGAGCGGCCGGCCCACCTGTCCCCTCGGGAGGGGAGCTGAGCCCGACTTCTACCGGGGTCCCCCAGCTTCCGGACTGGCCGCACCCCGGAGGAGCCACGGGGGCGCTGCTGGGAACGTGGGCGGGGGGCCGTTTCCTGACACTACCAGCCTGGGAGGCCCAGGTGTAGCGGTCCGAGGGGCCCGGTCCTGCCTGTCAGCTCCAGGTCCTGGAGCCACGTCCAGCACAGAGTGGACGGATTCACCGTGGCCGACTCTTTTCCCTGCTTTGGTTTGTTTGAAATCTAAATAAAACTACTTTATG'.downcase, @tr_fw.three_prime_utr_seq)
156
+ end
157
+
158
+ def test_three_prime_utr_rev
159
+ assert_equal('GCCAGGCCTGTTTCCCACACAGTGAACGGGGGGCTGGCGGGCCTCTCCTGGGGCCTGGCTTTGGCTGGAGGGGCTAGAAGGCGAGAGGGGCTGGGAAAGGAGTCTTCCCTCCCCTTTCCTGAACTGTCCAGGTCCTTCTAGGACACCTGATCCTTCCAGTCCCTGGGGGCTGTGACCCATGGCCCTGTGCAGGGTGCAGGGTGAGTCTCCTTCCAGTGCCCCAGTTTCTTCCAGGTCACGCCAGGCCAGGCCAGGCCAGGTGGGGAAAGGGACACCTTCCGGCCCTCCCCAGTAGCTGGCTGGAGATGGAGCTTCCTGTGTCCCAGAACTCGGCGTCCAGCTCCACTAGGGCCTGGATCCCCATCACAGCTTGGGTTAGCCCCGGTCCCAGCCCAAACTCAGGCTGGAGGCAGCCCCGAGGCCTGTGCCTTTCCCACTCCACCTTCTACAGTTGCTTAGCCAATAAACCTTTCCTGGGCTGGAG'.downcase, @tr_rev.three_prime_utr_seq)
160
+ end
161
+
162
+ def test_protein_fw
163
+ assert_equal('MARPLVPSSQKALLLELKGLQEEPVEGFRVTLVDEGDLYNWEVAIFGPPNTYYEGGYFKARLKFPIDYPYSPPAFRFLTKMWHPNIYETGDVCISILHPPVDDPQSGELPSERWNPTQNVRTILLSVISLLNEPNTFSPANVDASVMYRKWKESKGKDREYTDIIRKQVLGTKVDAERDGVKVPTTLAEYCVKTKAPAPDEGSDLFYDDYYEDGEVEEEADSCFGDDEDDSGTEES*', @tr_fw.protein_seq)
164
+ end
165
+
166
+ def test_protein_rev
167
+ assert_equal('MGTLSCDSTPRLATAPLGRRVTEGQIPETGLRKSCGTATLENGSGPGLYVLPSTVGFINHDCTRVASPAYSLVRRPSEAPPQDTSPGPIYFLDPKVTRFGRSCTPAYSMQGRAKSRGPEVTPGPGAYSPEKVPPVRHRTPPAFTLGCRLPLKPLDTSAPAPNAYTMPPLWGSQIFTKPSSPSYTVVGRTPPARPPQDPAEIPGPGQYDSPDANTYRQRLPAFTMLGRPRAPRPLEETPGPGAHCPEQVTVNKARAPAFSMGIRHSKRASTMAATTPSRPAGHRLPGRCC*', @tr_rev.protein_seq)
168
+ end
169
+ end
170
+
@@ -0,0 +1,116 @@
1
+ #
2
+ # = test/unit/test_project.rb - Unit test for Ensembl::Core
3
+ #
4
+ # Copyright:: Copyright (C) 2007
5
+ # Jan Aerts <http://jandot.myopenid.com>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
10
+
11
+ include Ensembl::Core
12
+ DBConnection.connect('bos_taurus', 50)
13
+
14
+ class GetFeatures < Test::Unit::TestCase
15
+ # Chr4.003.122 has no simple features in itself, but the corresponding region
16
+ # covered by the chromosome has 37. In addition, contigs within the scaffold
17
+ # have 85. Total should therefore be 122.
18
+ def test_simple_features
19
+ contig = SeqRegion.find_by_name('AAFC03055312')
20
+ assert_equal(19, contig.simple_features.length)
21
+ assert_equal(19, contig.slice.simple_features.length)
22
+ slice = Slice.fetch_by_region('contig','AAFC03055312')
23
+ assert_equal(19, slice.simple_features.length)
24
+ end
25
+ end
26
+
27
+ class SliceMethodMissing < Test::Unit::TestCase
28
+ def setup
29
+ @slice = Slice.fetch_by_region('chromosome','4',10000,10000000)
30
+ end
31
+
32
+ # There is not NotExistingTable class
33
+ def test_non_existing_tables
34
+ assert_raise(NoMethodError) { @slice.not_existing_tables }
35
+ end
36
+
37
+ # A slice can get its exons
38
+ def test_exons
39
+ assert_equal(291, @slice.exons.length)
40
+ assert_equal(Exon, @slice.exons[0].class)
41
+ end
42
+
43
+ # A slice can _not_ get its markers; it has marker_features instead.
44
+ def test_markers
45
+ assert_raise(NoMethodError) { @slice.markers }
46
+ end
47
+
48
+ def test_transcripts
49
+ assert_equal(36, @slice.transcripts.length)
50
+ end
51
+ end
52
+
53
+ class GetOverlappingObjects < Test::Unit::TestCase
54
+ def setup
55
+ @small_slice = Slice.fetch_by_region('chromosome','Un.004.10515',850,900)
56
+ @genes_inclusive = @small_slice.genes(true)
57
+ @genes_exclusive = @small_slice.genes
58
+
59
+ @large_slice = Slice.fetch_by_region('contig','AAFC03055312',1,18210)
60
+ @repeats_inclusive = @large_slice.repeat_features(true).select{|r| r.analysis_id == 6}
61
+ end
62
+
63
+ def test_get_gene
64
+ assert_equal(1, @genes_inclusive.length)
65
+ assert_equal('ENSBTAG00000039669', @genes_inclusive[0].stable_id)
66
+ assert_equal(0, @genes_exclusive.length)
67
+ end
68
+
69
+ def test_get_repeat_features
70
+ assert_equal(2, @repeats_inclusive.length)
71
+ end
72
+ end
73
+
74
+ class ExcisingSlice < Test::Unit::TestCase
75
+ def setup
76
+ @original_slice = Slice.fetch_by_region('chromosome','1',1,1000)
77
+ end
78
+
79
+ def test_excise_one_range
80
+ output = @original_slice.excise([20..50])
81
+ assert_equal(2, output.length)
82
+ assert_equal('chromosome:Btau_4.0:1:1:19:1', output[0].to_s)
83
+ assert_equal('chromosome:Btau_4.0:1:51:1000:1', output[1].to_s)
84
+ end
85
+
86
+ def test_excise_two_nonoverlapping_ranges
87
+ output = @original_slice.excise([20..50,100..200])
88
+ assert_equal(3, output.length)
89
+ assert_equal('chromosome:Btau_4.0:1:1:19:1', output[0].to_s)
90
+ assert_equal('chromosome:Btau_4.0:1:51:99:1', output[1].to_s)
91
+ assert_equal('chromosome:Btau_4.0:1:201:1000:1', output[2].to_s)
92
+ end
93
+
94
+ def test_excise_two_overlapping_ranges
95
+ output = @original_slice.excise([20..150,100..200])
96
+ assert_equal(2, output.length)
97
+ assert_equal('chromosome:Btau_4.0:1:1:19:1', output[0].to_s)
98
+ assert_equal('chromosome:Btau_4.0:1:201:1000:1', output[1].to_s)
99
+ end
100
+
101
+ def test_excise_two_adjacent_ranges
102
+ output = @original_slice.excise([20..99,100..200])
103
+ assert_equal(2, output.length)
104
+ assert_equal('chromosome:Btau_4.0:1:1:19:1', output[0].to_s)
105
+ assert_equal('chromosome:Btau_4.0:1:201:1000:1', output[1].to_s)
106
+ end
107
+
108
+ def test_excise_internal_ranges
109
+ output = @original_slice.excise([20..300,100..200])
110
+ assert_equal(2, output.length)
111
+ assert_equal('chromosome:Btau_4.0:1:1:19:1', output[0].to_s)
112
+ assert_equal('chromosome:Btau_4.0:1:201:1000:1', output[1].to_s)
113
+ end
114
+
115
+
116
+ end
@@ -0,0 +1,125 @@
1
+ #
2
+ # = test/unit/test_transcript.rb - Unit test for Ensembl::Core
3
+ #
4
+ # Copyright:: Copyright (C) 2007
5
+ # Jan Aerts <http://jandot.myopenid.com>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
10
+
11
+ include Ensembl::Core
12
+
13
+ DBConnection.connect('homo_sapiens', 50)
14
+
15
+ class CodingPositions < Test::Unit::TestCase
16
+ def setup
17
+ # Transcript tr_fw is ENST00000215574
18
+ @tr_fw = Transcript.find(73491)
19
+ # Transcript tr_rev is ENST00000358041
20
+ @tr_rev = Transcript.find(73774)
21
+ end
22
+
23
+ def test_transcript_coords
24
+ assert_equal(482733, @tr_fw.seq_region_start)
25
+ assert_equal(493084, @tr_fw.seq_region_end)
26
+ assert_equal(595371, @tr_rev.seq_region_start)
27
+ assert_equal(598309, @tr_rev.seq_region_end)
28
+ end
29
+
30
+ def test_coding_regions_genomic_coords_of_fw
31
+ assert_equal(482932, @tr_fw.coding_region_genomic_start)
32
+ assert_equal(492552, @tr_fw.coding_region_genomic_end)
33
+ end
34
+
35
+ def test_coding_regions_genomic_coords_of_rev
36
+ assert_equal(597652, @tr_rev.coding_region_genomic_start)
37
+ assert_equal(598047, @tr_rev.coding_region_genomic_end)
38
+ end
39
+
40
+ def test_coding_regions_cdna_coords_of_fw
41
+ assert_equal(200, @tr_fw.coding_region_cdna_start)
42
+ assert_equal(910, @tr_fw.coding_region_cdna_end)
43
+ end
44
+
45
+ def test_coding_regions_cdna_coords_of_rev
46
+ assert_equal(263, @tr_rev.coding_region_cdna_start)
47
+ assert_equal(658, @tr_rev.coding_region_cdna_end)
48
+ end
49
+
50
+ end
51
+
52
+ class GenomicVsCDna < Test::Unit::TestCase
53
+ #From BioMart. Columns:
54
+ # Ensembl_Transcript_ID
55
+ # Chromosome
56
+ # Gene_Start
57
+ # Gene_End
58
+ # Transcript_Start
59
+ # Transcript_End
60
+ # Strand
61
+ # Gene
62
+ # Exon_Chr_Start
63
+ # Exon_Chr_End
64
+ # Exon_Rank_in_Transcript
65
+ # phase
66
+ #ENST00000215574 19 482733 493084 482733 493084 1 CDC34 482733 483108 1 -1
67
+ #ENST00000215574 19 482733 493084 482733 493084 1 CDC34 486837 486923 2 0
68
+ #ENST00000215574 19 482733 493084 482733 493084 1 CDC34 487243 487340 3 0
69
+ #ENST00000215574 19 482733 493084 482733 493084 1 CDC34 488013 488147 4 2
70
+ #ENST00000215574 19 482733 493084 482733 493084 1 CDC34 492339 493084 5 2
71
+ #
72
+ #ENST00000315489 19 414360 425983 414360 425983 -1 C19orf19 425621 425983 1 -1
73
+ #ENST00000315489 19 414360 425983 414360 425983 -1 C19orf19 423394 423501 2 1
74
+ #ENST00000315489 19 414360 425983 414360 425983 -1 C19orf19 418649 418762 3 1
75
+ #ENST00000315489 19 414360 425983 414360 425983 -1 C19orf19 414360 415364 4 1
76
+ def setup
77
+ # Transcript tr_fw is ENST00000215574
78
+ @tr_fw = Transcript.find(73491)
79
+ # Transcript tr_rev is ENST00000315489
80
+ @tr_rev = Transcript.find(73411)
81
+ end
82
+
83
+ def test_identify_exon
84
+ assert_equal(Exon.find(374767), @tr_fw.exon_for_cdna_position(601))
85
+ assert_equal(Exon.find(374767), @tr_fw.exon_for_genomic_position(488053))
86
+ assert_equal(Exon.find(374458), @tr_rev.exon_for_cdna_position(541))
87
+ assert_equal(Exon.find(374458), @tr_rev.exon_for_genomic_position(418719))
88
+ end
89
+
90
+ def test_cdna2genomic
91
+ assert_equal(488052, @tr_fw.cdna2genomic(601))
92
+ assert_equal(418693, @tr_rev.cdna2genomic(541))
93
+ end
94
+
95
+ def test_cds2genomic
96
+ assert_equal(488052, @tr_fw.cds2genomic(401))
97
+ assert_equal(418693, @tr_rev.cds2genomic(304))
98
+ end
99
+
100
+ def test_genomic2cdna
101
+ assert_equal(601, @tr_fw.genomic2cdna(488052))
102
+ assert_equal(541, @tr_rev.genomic2cdna(418693))
103
+ end
104
+
105
+ def test_genomic2cds
106
+ assert_equal(401, @tr_fw.genomic2cds(488052))
107
+ assert_equal(304, @tr_rev.genomic2cds(418693))
108
+ end
109
+ end
110
+
111
+ class TestIntron < Test::Unit::TestCase
112
+ def setup
113
+ @transcript = Transcript.find(58973)
114
+ @introns = @transcript.introns
115
+ end
116
+
117
+ def test_get_introns
118
+ assert_equal(2, @introns.length)
119
+ end
120
+
121
+ def test_intron_slices
122
+ assert_equal('chromosome:NCBI36:8:159418:172128:-1', @introns[0].slice.to_s)
123
+ end
124
+ end
125
+