ruby-ensembl-api 0.9.6 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/TUTORIAL.rdoc +1 -1
  2. data/bin/variation_effect_predictor +106 -0
  3. data/lib/ensembl.rb +2 -2
  4. data/lib/ensembl/core/activerecord.rb +119 -225
  5. data/lib/ensembl/core/collection.rb +14 -10
  6. data/lib/ensembl/core/project.rb +6 -8
  7. data/lib/ensembl/core/slice.rb +87 -123
  8. data/lib/ensembl/core/transcript.rb +49 -65
  9. data/lib/ensembl/core/transform.rb +6 -8
  10. data/lib/ensembl/db_connection.rb +56 -72
  11. data/lib/ensembl/variation/activerecord.rb +138 -8
  12. data/lib/ensembl/variation/variation.rb +284 -46
  13. data/samples/ensembl_genomes_example.rb +60 -0
  14. data/samples/examples_perl_tutorial.rb +125 -0
  15. data/samples/small_example_ruby_api.rb +34 -0
  16. data/samples/variation_example.rb +67 -0
  17. data/test/unit/{release_56 → release_60}/core/test_gene.rb +6 -6
  18. data/test/unit/release_60/core/test_project_human.rb +38 -0
  19. data/test/unit/{release_56 → release_60}/core/test_slice.rb +1 -8
  20. data/test/unit/release_60/core/test_transcript.rb +126 -0
  21. data/test/unit/{release_53 → release_60}/core/test_transform.rb +21 -21
  22. data/test/unit/release_60/variation/test_activerecord.rb +213 -0
  23. data/test/unit/release_60/variation/test_consequence.rb +158 -0
  24. data/test/unit/{release_56 → release_60}/variation/test_variation.rb +18 -17
  25. data/test/unit/test_connection.rb +2 -2
  26. data/test/unit/test_releases.rb +8 -8
  27. metadata +27 -43
  28. data/test/unit/data/seq_c6qbl.fa +0 -10
  29. data/test/unit/data/seq_cso19_coding.fa +0 -16
  30. data/test/unit/data/seq_cso19_transcript.fa +0 -28
  31. data/test/unit/data/seq_drd3_gene.fa +0 -838
  32. data/test/unit/data/seq_drd3_transcript.fa +0 -22
  33. data/test/unit/data/seq_drd4_transcript.fa +0 -24
  34. data/test/unit/data/seq_forward_composite.fa +0 -1669
  35. data/test/unit/data/seq_par_boundary.fa +0 -169
  36. data/test/unit/data/seq_rnd3_transcript.fa +0 -47
  37. data/test/unit/data/seq_ub2r1_coding.fa +0 -13
  38. data/test/unit/data/seq_ub2r1_gene.fa +0 -174
  39. data/test/unit/data/seq_ub2r1_transcript.fa +0 -26
  40. data/test/unit/data/seq_y.fa +0 -2
  41. data/test/unit/ensembl_genomes/test_collection.rb +0 -51
  42. data/test/unit/ensembl_genomes/test_gene.rb +0 -52
  43. data/test/unit/ensembl_genomes/test_slice.rb +0 -71
  44. data/test/unit/ensembl_genomes/test_variation.rb +0 -17
  45. data/test/unit/release_50/core/test_project.rb +0 -215
  46. data/test/unit/release_50/core/test_project_human.rb +0 -58
  47. data/test/unit/release_50/core/test_relationships.rb +0 -66
  48. data/test/unit/release_50/core/test_sequence.rb +0 -175
  49. data/test/unit/release_50/core/test_slice.rb +0 -121
  50. data/test/unit/release_50/core/test_transcript.rb +0 -108
  51. data/test/unit/release_50/core/test_transform.rb +0 -223
  52. data/test/unit/release_50/variation/test_activerecord.rb +0 -143
  53. data/test/unit/release_50/variation/test_variation.rb +0 -84
  54. data/test/unit/release_53/core/test_gene.rb +0 -66
  55. data/test/unit/release_53/core/test_project.rb +0 -96
  56. data/test/unit/release_53/core/test_project_human.rb +0 -65
  57. data/test/unit/release_53/core/test_slice.rb +0 -47
  58. data/test/unit/release_53/variation/test_activerecord.rb +0 -145
  59. data/test/unit/release_53/variation/test_variation.rb +0 -71
  60. data/test/unit/release_56/core/test_project.rb +0 -96
  61. data/test/unit/release_56/core/test_transform.rb +0 -63
  62. data/test/unit/release_56/variation/test_activerecord.rb +0 -142
@@ -1,47 +0,0 @@
1
- #
2
- # = test/unit/release_53/core/test_slice.rb - Unit test for Ensembl::Core
3
- #
4
- # Copyright:: Copyright (C) 2009
5
- # Francesco Strozzi <francesco.strozzi@gmail.com>
6
- # License:: Ruby's
7
- #
8
- # $Id:
9
-
10
- require 'pathname'
11
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
12
- $:.unshift(libpath) unless $:.include?(libpath)
13
-
14
- require 'test/unit'
15
- require 'lib/ensembl'
16
-
17
- include Ensembl::Core
18
-
19
- class TestSlice < Test::Unit::TestCase
20
-
21
- def setup
22
- DBConnection.connect('homo_sapiens', 53)
23
- end
24
-
25
- def teardown
26
- DBConnection.remove_connection
27
- end
28
-
29
- def test_forward
30
- seq1 = "AGAACCAACGAATTCGGAGATGAAGTCAGGTCTTCCAGTTCAGCCTGCGAGGAAGACAGGTGATCCGAATCCTAAGAATGCAAAAGATGGGCCGGGTGTGGTGGCTCATGCCTGTAATCCCAGCGCTTTGGGAGGCCGAGGCAGGCAGATCACCTGAGGTCGGGAGGTTGAGACCAGACTGACCAACAACGGAGAAACCC"
31
- s = Slice.fetch_by_region("chromosome","13",31786617,31786816,1)
32
- assert_equal(seq1,s.seq.upcase)
33
- assert_equal("13",s.seq_region.name)
34
- assert_equal(31786617,s.start)
35
- assert_equal(31786816,s.stop)
36
- end
37
-
38
- def test_reverse
39
- seq2 = "GGGTTTCTCCGTTGTTGGTCAGTCTGGTCTCAACCTCCCGACCTCAGGTGATCTGCCTGCCTCGGCCTCCCAAAGCGCTGGGATTACAGGCATGAGCCACCACACCCGGCCCATCTTTTGCATTCTTAGGATTCGGATCACCTGTCTTCCTCGCAGGCTGAACTGGAAGACCTGACTTCATCTCCGAATTCGTTGGTTCT"
40
- s_rev = Slice.fetch_by_region("chromosome","13",31786617,31786816,-1)
41
- assert_equal(seq2,s_rev.seq.upcase)
42
- assert_equal("13",s_rev.seq_region.name)
43
- assert_equal(31786617,s_rev.start)
44
- assert_equal(31786816,s_rev.stop)
45
- end
46
-
47
- end
@@ -1,145 +0,0 @@
1
- #
2
- # = test/unit/release_50/variation/test_activerecord.rb - Unit test for Ensembl::Variation
3
- #
4
- # Copyright:: Copyright (C) 2009
5
- # Francesco Strozzi <francesco.strozzi@gmail.com>
6
- #
7
- # License:: Ruby's
8
- #
9
- # $Id:
10
- require 'pathname'
11
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
12
- $:.unshift(libpath) unless $:.include?(libpath)
13
-
14
- require 'test/unit'
15
- require 'lib/ensembl'
16
-
17
- include Ensembl::Variation
18
-
19
- class ActiveRecordVariation < Test::Unit::TestCase
20
-
21
- def setup
22
- DBConnection.connect('homo_sapiens',53)
23
- end
24
-
25
- def teardown
26
- DBConnection.remove_connection
27
- end
28
-
29
- def test_allele
30
- allele = Allele.find(1)
31
- assert_equal('C', allele.allele)
32
- assert_equal(0.673913, allele.frequency)
33
- end
34
-
35
- def test_sample
36
- n = Sample.count(:all)
37
- assert_equal(15406,n)
38
- individual = Sample.find(9146).individual
39
- assert_equal('Female',individual.gender)
40
- i = Sample.find(10128).individual_genotype_multiple_bp
41
- assert_equal(990,i.size)
42
- assert_equal(1533205,i[0].variation_id)
43
- syn = Sample.find(21).sample_synonym
44
- assert_equal('477',syn.name)
45
- end
46
-
47
- def test_individual
48
- n = Individual.count(:all)
49
- assert_equal(8658,n)
50
- end
51
-
52
- def test_individual_genotype_multiple_bp
53
- n = IndividualGenotypeMultipleBp.count(:all)
54
- assert_equal(208579,n)
55
- end
56
-
57
- def test_compressed_genotype_single_bp
58
- n = CompressedGenotypeSingleBp.count(:all)
59
- assert_equal(12580098,n)
60
- end
61
-
62
- def test_read_coverage
63
- n = ReadCoverage.count(:all)
64
- assert_equal(9300776,n)
65
- end
66
-
67
- def test_population
68
- n = Population.count(:all)
69
- assert_equal(6748,n)
70
- end
71
-
72
- def test_variation
73
- n = Variation.count(:all)
74
- assert_equal(15872232,n)
75
-
76
- syn = Variation.find(84).variation_synonyms
77
- assert_equal(6,syn.size)
78
- assert_equal('TSC1239757',syn[0].name)
79
-
80
- flanking = Variation.find(10000).flanking_sequence
81
- assert_equal(3652320,flanking.up_seq_region_start)
82
- assert_equal(3652519,flanking.up_seq_region_end)
83
- assert_equal(3652521,flanking.down_seq_region_start)
84
- assert_equal(3652720,flanking.down_seq_region_end)
85
- assert_equal(226033,flanking.seq_region_id)
86
- assert_equal(1,flanking.seq_region_strand)
87
-
88
- ag = Variation.find(10000).allele_groups
89
- assert_nil ag[0]
90
-
91
- pg = Variation.find(10000).population_genotypes
92
- assert_equal(12,pg.size)
93
- assert_equal('C',pg[0].allele_1)
94
- assert_equal('C',pg[0].allele_2)
95
- assert_equal(1,pg[0].frequency)
96
-
97
- a = Variation.find(115).alleles
98
- assert_equal(8,a.size)
99
- assert_equal('C',a[0].allele)
100
- assert_equal(0.593,a[0].frequency)
101
-
102
- vf = Variation.find(5345540).variation_features[0]
103
- assert_equal('G/A',vf.allele_string)
104
- assert_equal('rs8189278',vf.variation_name)
105
- assert_equal(226044,vf.seq_region_id)
106
- assert_equal(50727657,vf.seq_region_start)
107
- assert_equal(50727657,vf.seq_region_end)
108
- assert_equal(1,vf.seq_region_strand)
109
-
110
- vg = Variation.find(1352735).variation_groups
111
- assert_nil vg[0]
112
-
113
- i = Variation.find(1533205).individual_genotype_multiple_bps
114
- assert_equal(41,i.size)
115
- end
116
-
117
- def test_variation_feature
118
- vf_sample = VariationFeature.find(8).samples
119
- assert_equal(6,vf_sample.size)
120
- assert_equal('PERLEGEN:AFD_EUR_PANEL',vf_sample[0].name)
121
- end
122
-
123
- def test_variation_transcript
124
- t = Variation.find_by_name('rs35303525').variation_features[0].transcript_variations
125
- assert_equal(2,t.size)
126
- transcript = t[0].transcript
127
- assert_equal('protein_coding',transcript.biotype)
128
- assert_equal(2199894,transcript.seq_region_start)
129
- assert_equal(2213658,transcript.seq_region_end)
130
- assert_equal('ENST00000243706',transcript.stable_id)
131
- e = transcript.exons
132
- assert_equal('CTCCCGTGAGGCAGTGCGAGGCGCGCGGGGCACGGAGGGCGGTGGCGGCGGGCTCCTGCGAGAAGCAAGCGGAACTTCCTGAG',e[0].seq.upcase)
133
- end
134
-
135
- def test_source
136
- syn = Source.find(1).sample_synonyms
137
- assert_equal(15385,syn.size)
138
-
139
- ag = Source.find(1).allele_groups
140
- assert_nil ag[0]
141
-
142
- s = Source.count(9)
143
- assert_equal(4,s.size)
144
- end
145
- end
@@ -1,71 +0,0 @@
1
- #
2
- # = test/unit/release_50/variation/test_variation.tb - Unit test for Ensembl::Variation
3
- #
4
- # Copyright:: Copyright (C) 2009
5
- # Francesco Strozzi <francesco.strozzi@gmail.com>
6
- # License:: Ruby's
7
- #
8
- require 'pathname'
9
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
10
- $:.unshift(libpath) unless $:.include?(libpath)
11
-
12
- require 'test/unit'
13
- require 'lib/ensembl'
14
-
15
- include Ensembl::Variation
16
-
17
- class TestVariation < Test::Unit::TestCase
18
-
19
- def setup
20
- DBConnection.connect('homo_sapiens',53)
21
- end
22
-
23
- def teardown
24
- DBConnection.remove_connection
25
- end
26
-
27
- def test_fetch_region
28
- vf = Variation.find_by_name('rs2076175').variation_features[0]
29
- slice = vf.fetch_region
30
- assert_equal(29816349,slice.start)
31
- assert_equal(29826349,slice.stop)
32
- assert_equal('6',slice.seq_region.name)
33
- slice = vf.fetch_region(30,30)
34
- assert_equal(29821319,slice.start)
35
- assert_equal(29821379,slice.stop)
36
- assert_equal('CTCCCAGGACTGCTTCTGCCCACTGTCCCCGGGGCCCTGCCCTGCCTTTCTGCCTGTCACA',slice.seq.upcase)
37
- end
38
-
39
- def test_flanking_seq
40
- vf = Variation.find_by_name('rs2076175').variation_features[0]
41
- up,down = vf.flanking_seq
42
- assert_equal(29820949,up.start)
43
- assert_equal(29821348,up.stop)
44
- assert_equal(29821350,down.start)
45
- assert_equal(29821749,down.stop)
46
- assert_equal('TCCTGATCTCACAAACCCTAATCTCCTGGAGGGAATGCAAGGCTGCCTGCCCCTACCCAGCAGTGACTTCTCCATTCCAGTCCAAGTGAGGAACTCGGACCAGGAAGGACCCCTCCCTGGCCCTCTTCCATCCCTCCCTGTGTGGGCTGAGCCCCGCTGAGCACCATTCCTCACCCCTACTCACAGCCAAATCCAGTGGGAAGAGACAGGTCCTGCTCTCTGCCCCCAACTCTCCTGGAAAAGGCCTCTCCCATTACTCTTGCCCACTGCCCACTCTCACCTCCTTTCTGGCCCTTGATATGAGCCAGGGTCCTCCTGAGCTCCTGCCCATTCTCTGTCAAGTCTTCAGTCTCTGTGTCCCAGGTCTCAGCTCCCAGGACTGCTTCTGCCCACTGTCCCC',
47
- up.seq.upcase)
48
- assert_equal('GGGCCCTGCCCTGCCTTTCTGCCTGTCACAGAGCAGGAAGAGCTGACCATCCAGATGTCCCTCAGCGAGAAACCCTGACTGCACAGATCCATCCTGGGACAGCACCGTGAGGTTGTAACAAAGACTGTGGGGCTCTGGGGAAGAGGAAATCACAGATGAAACTTCTTCCTGGAAGTAACTTCACATCAATGTTTAACACACAGGTCTGCTGTCCCGACCTTCCTGAGGAGGCAGGAAATGCACACGGGCAAAGGGACAAGAATGAGGATTTCAGACGCAAGGAAAACTGGGAAGGTGGGAGGATAGAGGAGGGGACTGAGGAACAGAAGAAGGGGGAATGGGGATGGCAAACTTGTAGGCCAGGTGCCAGGGCAGGGCAGCCACAGGCCCCCTCAGGATA',
49
- down.seq.upcase)
50
-
51
- end
52
-
53
- def test_slice_variation
54
- slice = Ensembl::Core::Slice.fetch_by_region('chromosome',1,50000,50300)
55
- variations = slice.get_variation_features
56
- assert_equal(8,variations.size)
57
-
58
- assert_equal('rs987669',variations[0].variation_name)
59
- assert_equal('ENSSNP4691381',variations[1].variation_name)
60
- assert_equal('rs2854665',variations[2].variation_name)
61
- assert_equal('rs62637816',variations[3].variation_name)
62
- assert_equal('ENSSNP9996411',variations[4].variation_name)
63
- assert_equal('rs62637817',variations[5].variation_name)
64
- assert_equal('rs2691281',variations[6].variation_name)
65
- assert_equal('ENSSNP4068519',variations[7].variation_name)
66
-
67
- end
68
-
69
-
70
-
71
- end
@@ -1,96 +0,0 @@
1
- #
2
- # = test/unit/release_53/core/test_project.rb - Unit test for Ensembl::Core
3
- #
4
- # Copyright:: Copyright (C) 2009
5
- # Jan Aerts <http://jandot.myopenid.com>
6
- # Francesco Strozzi <francesco.strozzi@gmail.com>
7
- # License:: Ruby's
8
- #
9
- # $Id:
10
-
11
- require 'pathname'
12
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
13
- $:.unshift(libpath) unless $:.include?(libpath)
14
-
15
- require 'test/unit'
16
- require 'lib/ensembl'
17
-
18
- include Ensembl::Core
19
-
20
- class SliceProjectFromAssemblyToComponentForwardStrands < Test::Unit::TestCase
21
- def setup
22
- DBConnection.connect('bos_taurus', 56)
23
- @source_slice_single_contig = Slice.fetch_by_region('chromosome', '20', 175000, 180000)
24
- @target_slices_single_contig = @source_slice_single_contig.project('contig')
25
-
26
- @source_slice_two_contigs = Slice.fetch_by_region('chromosome','20', 175000, 190000)
27
- @target_slices_two_contigs = @source_slice_two_contigs.project('contig')
28
-
29
- @source_slice_contigs_with_strand = Slice.fetch_by_region('chromosome', '20', 160000, 190000)
30
- @target_slices_contigs_with_strand = @source_slice_contigs_with_strand.project('contig')
31
-
32
- @source_slice_contigs_with_strand_ends_in_gaps = Slice.fetch_by_region('chromosome', '20', 170950, 196000)
33
- @target_slices_contigs_with_strand_ends_in_gaps = @source_slice_contigs_with_strand_ends_in_gaps.project('contig')
34
- end
35
-
36
- def teardown
37
- DBConnection.remove_connection
38
- end
39
-
40
- # |-----------------> contig
41
- # ^ ^
42
- # | |
43
- # |------------------------------------------> chromosome
44
- def test_project_from_assembly_to_single_component
45
- # Position 175000 on chr20 is position 4030 on contig, position 180000 is 9030
46
- assert_equal('AAFC03028970', @target_slices_single_contig[0].seq_region.name)
47
- assert_equal(4030, @target_slices_single_contig[0].start)
48
- assert_equal(9030, @target_slices_single_contig[0].stop)
49
- end
50
-
51
- # |-----> |--------> contig
52
- # ^ ^
53
- # | |
54
- # |------------------------------------------> chromosome
55
- def test_project_from_assembly_to_two_components
56
- # This chromosomal region is covered by contigs AAFC03028970, a gap and AAFC03028962
57
- # * Position 175000 on chr 20 is position 4030 on contig AAFC03028970
58
- # * Position 190000 on chr 20 is position 35 on contig AAFC03028962
59
- assert_equal(3, @target_slices_two_contigs.length)
60
- assert_equal('contig:Btau_4.0:AAFC03028970:4030:17365:1', @target_slices_two_contigs[0].display_name)
61
- assert_equal(Gap, @target_slices_two_contigs[1].class)
62
- assert_equal('contig:Btau_4.0:AAFC03028962:1:35:1', @target_slices_two_contigs[2].display_name)
63
- end
64
-
65
- # |-----> <-------| |-------> |-------> contig
66
- # ^ ^
67
- # | |
68
- # |--------------------------------------------------> chromosome
69
- def test_project_from_assembly_to_contigs_with_strand
70
- # This chromosomal region is covered by 4 contigs and 3 gaps
71
- # One of the contigs are on the reverse strand.
72
- assert_equal(7, @target_slices_contigs_with_strand.length)
73
- assert_equal('contig:Btau_4.0:AAFC03028964:90:9214:1', @target_slices_contigs_with_strand[0].display_name)
74
- assert_equal(Gap, @target_slices_contigs_with_strand[1].class)
75
- assert_equal('contig:Btau_4.0:AAFC03028959:1:1746:-1', @target_slices_contigs_with_strand[2].display_name)
76
- assert_equal(Gap, @target_slices_contigs_with_strand[3].class)
77
- assert_equal('contig:Btau_4.0:AAFC03028970:1:17365:1', @target_slices_contigs_with_strand[4].display_name)
78
- assert_equal(Gap, @target_slices_contigs_with_strand[5].class)
79
- assert_equal('contig:Btau_4.0:AAFC03028962:1:35:1', @target_slices_contigs_with_strand[6].display_name)
80
- end
81
-
82
- # <--| |-----> contig
83
- # ^ ^
84
- # | |
85
- # |--------------------------------------------------> chromosome
86
- def test_project_from_assembly_to_contigs_with_strand_and_ending_in_gaps
87
- # This chromosomal region is covered by 2 contigs and 2 gaps at the end: GaCoGaCoGa
88
- assert_equal(5, @target_slices_contigs_with_strand_ends_in_gaps.length)
89
- assert_equal(Gap, @target_slices_contigs_with_strand_ends_in_gaps[0].class)
90
- assert_equal('contig:Btau_4.0:AAFC03028970:1:17365:1', @target_slices_contigs_with_strand_ends_in_gaps[1].display_name)
91
- assert_equal(Gap, @target_slices_contigs_with_strand_ends_in_gaps[2].class)
92
- assert_equal('contig:Btau_4.0:AAFC03028962:1:5704:1', @target_slices_contigs_with_strand_ends_in_gaps[3].display_name)
93
- assert_equal(Gap, @target_slices_contigs_with_strand_ends_in_gaps[4].class)
94
- end
95
-
96
- end
@@ -1,63 +0,0 @@
1
- #
2
- # = test/unit/release_53/core/test_transform.rb - Unit test for Ensembl::Core
3
- #
4
- # Copyright:: Copyright (C) 2009
5
- # Jan Aerts <http://jandot.myopenid.com>
6
- # Francesco Strozzi <francesco.strozzi@gmail.com>
7
- # License:: Ruby's
8
- #
9
- # $Id:
10
-
11
- require 'pathname'
12
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
13
- $:.unshift(libpath) unless $:.include?(libpath)
14
-
15
- require 'test/unit'
16
-
17
- require 'lib/ensembl'
18
-
19
- include Ensembl::Core
20
-
21
-
22
- # For all tests, the source (i.e. the seq_region that the feature is annotated
23
- # on initially) remains forward.
24
- #
25
- # Same coordinate system: test names refer to direction of gene vs chromosome
26
- class TransformOntoSameCoordinateSystem < Test::Unit::TestCase
27
-
28
- def setup
29
- DBConnection.connect('homo_sapiens', 56)
30
- end
31
-
32
- def teardown
33
- DBConnection.remove_connection
34
- end
35
-
36
- def test_rev
37
- source_gene = Gene.find_by_stable_id("ENSG00000165322")
38
- target_gene = source_gene.transform('chromosome')
39
-
40
- assert_equal('10', source_gene.seq_region.name)
41
- assert_equal(32094365, source_gene.seq_region_start)
42
- assert_equal(32217770, source_gene.seq_region_end)
43
- assert_equal(-1, source_gene.seq_region_strand)
44
- assert_equal('10', target_gene.seq_region.name)
45
- assert_equal(32094365, target_gene.seq_region_start)
46
- assert_equal(32217770, target_gene.seq_region_end)
47
- assert_equal(-1, target_gene.seq_region_strand)
48
- end
49
-
50
- def test_fw
51
- source_gene = Gene.find_by_stable_id("ENSG00000133401")
52
- target_gene = source_gene.transform('chromosome')
53
- assert_equal('5', source_gene.seq_region.name)
54
- assert_equal(31639517, source_gene.seq_region_start)
55
- assert_equal(32111037, source_gene.seq_region_end)
56
- assert_equal(1, source_gene.seq_region_strand)
57
- assert_equal('5', target_gene.seq_region.name)
58
- assert_equal(31639517, target_gene.seq_region_start)
59
- assert_equal(32111037, target_gene.seq_region_end)
60
- assert_equal(1, target_gene.seq_region_strand)
61
- end
62
-
63
- end
@@ -1,142 +0,0 @@
1
- #
2
- # = test/unit/release_50/variation/test_activerecord.rb - Unit test for Ensembl::Variation
3
- #
4
- # Copyright:: Copyright (C) 2009
5
- # Francesco Strozzi <francesco.strozzi@gmail.com>
6
- #
7
- # License:: Ruby's
8
- #
9
- # $Id:
10
- require 'pathname'
11
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
12
- $:.unshift(libpath) unless $:.include?(libpath)
13
-
14
- require 'test/unit'
15
- require 'lib/ensembl'
16
-
17
- include Ensembl::Variation
18
-
19
- class ActiveRecordVariation < Test::Unit::TestCase
20
-
21
- def setup
22
- DBConnection.connect('homo_sapiens',56)
23
- end
24
-
25
- def teardown
26
- DBConnection.remove_connection
27
- end
28
-
29
- def test_allele
30
- allele = Allele.find(1)
31
- assert_equal('T', allele.allele)
32
- assert_equal(0.04, allele.frequency)
33
- end
34
-
35
- def test_sample
36
- n = Sample.count(:all)
37
- assert_equal(17822,n)
38
- individual = Sample.find(12468).individual
39
- assert_equal('Male',individual.gender)
40
- i = Sample.find(13131).individual_genotype_multiple_bp
41
- assert_equal(3,i.size)
42
- assert_equal(17510,i[0].variation_id)
43
- syn = Sample.find(21).sample_synonym
44
- assert_equal('477',syn.name)
45
- end
46
-
47
- def test_individual
48
- n = Individual.count(:all)
49
- assert_equal(10132,n)
50
- end
51
-
52
- def test_individual_genotype_multiple_bp
53
- n = IndividualGenotypeMultipleBp.count(:all)
54
- assert_equal(712267,n)
55
- end
56
-
57
- def test_compressed_genotype_single_bp
58
- n = CompressedGenotypeSingleBp.count(:all)
59
- assert_equal(12736658,n)
60
- end
61
-
62
- def test_read_coverage
63
- n = ReadCoverage.count(:all)
64
- assert_equal(6521608,n)
65
- end
66
-
67
- def test_population
68
- n = Population.count(:all)
69
- assert_equal(7690,n)
70
- end
71
-
72
- def test_variation
73
- n = Variation.count(:all)
74
- assert_equal(18909925,n)
75
-
76
- syn = Variation.find(712422).variation_synonyms
77
- assert_equal(6,syn.size)
78
- assert_equal('SNP_A-1507972',syn[0].name)
79
-
80
- flanking = Variation.find(10000).flanking_sequence
81
- assert_equal(3705521,flanking.up_seq_region_start)
82
- assert_equal(3705770,flanking.up_seq_region_end)
83
- assert_equal(3705772,flanking.down_seq_region_start)
84
- assert_equal(3706021,flanking.down_seq_region_end)
85
- assert_equal(27509,flanking.seq_region_id)
86
- assert_equal(1,flanking.seq_region_strand)
87
-
88
- ag = Variation.find(10000).allele_groups
89
- assert_nil ag[0]
90
-
91
- pg = Variation.find(10000).population_genotypes
92
- assert_equal(12,pg.size)
93
- assert_equal('C',pg[0].allele_1)
94
- assert_equal('C',pg[0].allele_2)
95
- assert_equal(1,pg[0].frequency)
96
-
97
- a = Variation.find(115).alleles
98
- assert_equal(8,a.size)
99
- assert_equal('C',a[0].allele)
100
- assert_equal(0.733,a[0].frequency)
101
-
102
- vf = Variation.find(5345540).variation_features[0]
103
- assert_equal('T/A',vf.allele_string)
104
- assert_equal('rs8189747',vf.variation_name)
105
- assert_equal(27526,vf.seq_region_id)
106
- assert_equal(24606076,vf.seq_region_start)
107
- assert_equal(24606076,vf.seq_region_end)
108
- assert_equal(1,vf.seq_region_strand)
109
-
110
- vg = Variation.find(1352735).variation_groups
111
- assert_nil vg[0]
112
-
113
- i = Variation.find(1533176).individual_genotype_multiple_bps
114
- assert_equal(42,i.size)
115
- end
116
-
117
- def test_variation_feature
118
- vf_sample = VariationFeature.find(38461).samples
119
- assert_equal(8,vf_sample.size)
120
- assert_equal('PERLEGEN:AFD_EUR_PANEL',vf_sample[0].name)
121
- end
122
-
123
- def test_variation_transcript
124
- t = Variation.find_by_name('rs7671997').variation_features[0].transcript_variations
125
- assert_equal(2,t.size)
126
- transcript = t[0].transcript
127
- assert_equal('protein_coding',transcript.biotype)
128
- assert_equal(2230096,transcript.seq_region_start)
129
- assert_equal(2243860,transcript.seq_region_end)
130
- assert_equal('ENST00000243706',transcript.stable_id)
131
- e = transcript.exons
132
- assert_equal('CTCCCGTGAGGCAGTGCGAGGCGCGCGGGGCACGGAGGGCGGTGGCGGCGGGCTCCTGCGAGAAGCAAGCGGAACTTCCTGAG',e[0].seq.upcase)
133
- end
134
-
135
- def test_source
136
- syn = Source.find(1).sample_synonyms
137
- assert_equal(17806,syn.size)
138
-
139
- ag = Source.find(1).allele_groups
140
- assert_nil ag[0]
141
- end
142
- end