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,63 @@
1
+ #
2
+ # = test/unit/release_56/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 File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
9
+
10
+ include Ensembl::Variation
11
+
12
+ class TestVariation < Test::Unit::TestCase
13
+
14
+ def setup
15
+ DBConnection.connect('homo_sapiens',56)
16
+ end
17
+
18
+ def teardown
19
+ DBConnection.remove_connection
20
+ end
21
+
22
+ def test_fetch_region
23
+ vf = Variation.find_by_name('rs2076175').variation_features[0]
24
+ slice = vf.fetch_region
25
+ assert_equal(29708370,slice.start)
26
+ assert_equal(29718370,slice.stop)
27
+ assert_equal('6',slice.seq_region.name)
28
+ slice = vf.fetch_region(30,30)
29
+ assert_equal(29713340,slice.start)
30
+ assert_equal(29713400,slice.stop)
31
+ assert_equal('CTCCCAGGACTGCTTCTGCCCACTGTCCCCGGGGCCCTGCCCTGCCTTTCTGCCTGTCACA',slice.seq.upcase)
32
+ end
33
+
34
+ def test_flanking_seq
35
+ vf = Variation.find_by_name('rs2076175').variation_features[0]
36
+ up,down = vf.flanking_seq
37
+ assert_equal(29713371,up.start)
38
+ assert_equal(29713770,up.stop)
39
+ assert_equal(29712970,down.start)
40
+ assert_equal(29713369,down.stop)
41
+ assert_equal('GGGCCCTGCCCTGCCTTTCTGCCTGTCACAGAGCAGGAAGAGCTGACCATCCAGATGTCCCTCAGCGAGAAACCCTGACTGCACAGATCCATCCTGGGACAGCACCGTGAGGTTGTAACAAAGACTGTGGGGCTCTGGGGAAGAGGAAATCACAGATGAAACTTCTTCCTGGAAGTAACTTCACATCAATGTTTAACACACAGGTCTGCTGTCCCGACCTTCCTGAGGAGGCAGGAAATGCACACGGGCAAAGGGACAAGAATGAGGATTTCAGACGCAAGGAAAACTGGGAAGGTGGGAGGATAGAGGAGGGGACTGAGGAACAGAAGAAGGGGGAATGGGGATGGCAAACTTGTAGGCCAGGTGCCAGGGCAGGGCAGCCACAGGCCCCCTCAGGATA',
42
+ up.seq.upcase)
43
+ assert_equal('TCCTGATCTCACAAACCCTAATCTCCTGGAGGGAATGCAAGGCTGCCTGCCCCTACCCAGCAGTGACTTCTCCATTCCAGTCCAAGTGAGGAACTCGGACCAGGAAGGACCCCTCCCTGGCCCTCTTCCATCCCTCCCTGTGTGGGCTGAGCCCCGCTGAGCACCATTCCTCACCCCTACTCACAGCCAAATCCAGTGGGAAGAGACAGGTCCTGCTCTCTGCCCCCAACTCTCCTGGAAAAGGCCTCTCCCATTACTCTTGCCCACTGCCCACTCTCACCTCCTTTCTGGCCCTTGATATGAGCCAGGGTCCTCCTGAGCTCCTGCCCATTCTCTGTCAAGTCTTCAGTCTCTGTGTCCCAGGTCTCAGCTCCCAGGACTGCTTCTGCCCACTGTCCCC',
44
+ down.seq.upcase)
45
+
46
+ end
47
+
48
+ def test_slice_variation
49
+ slice = Ensembl::Core::Slice.fetch_by_region('chromosome',1,100834,101331)
50
+ variations = slice.get_variation_features
51
+ assert_equal(6,variations.size)
52
+
53
+ assert_equal('rs3912703',variations[0].variation_name)
54
+ assert_equal('ENSSNP5435782',variations[1].variation_name)
55
+ assert_equal('ENSSNP3491774',variations[2].variation_name)
56
+ assert_equal('ENSSNP283782',variations[3].variation_name)
57
+ assert_equal('ENSSNP4578340',variations[4].variation_name)
58
+
59
+ end
60
+
61
+
62
+
63
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # = test/unit/release_53/core/test_gene.rb - Unit test for Ensembl::Core
3
+ #
4
+ # Copyright:: Copyright (C) 2009 Francesco Strozzi <francesco.strozzi@gmail.com>
5
+ #
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+
10
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
11
+
12
+ include Ensembl::Core
13
+
14
+ class TestGene < Test::Unit::TestCase
15
+
16
+ def setup
17
+ DBConnection.connect('homo_sapiens', 60)
18
+ end
19
+
20
+ def teardown
21
+ DBConnection.remove_connection
22
+ end
23
+
24
+ def test_gene
25
+ g = Gene.find_by_stable_id("ENSG00000006451")
26
+ assert_equal("ENSG00000006451",g.stable_id)
27
+ assert_equal("7",g.seq_region.name)
28
+ assert_equal(39663082,g.start)
29
+ assert_equal(39747723,g.stop)
30
+ assert_equal(1,g.strand)
31
+ assert_equal(84642,g.seq.length)
32
+ assert_equal("v-ral simian leukemia viral oncogene homolog A (ras related) [Source:HGNC Symbol;Acc:9839]",g.description)
33
+ assert_equal("RALA",g.name)
34
+ end
35
+
36
+ def test_transcript
37
+ g = Gene.find_by_stable_id("ENSG00000006451")
38
+ t = g.transcripts
39
+ assert_equal(5,t.size)
40
+ assert_equal("ENST00000005257",t[0].stable_id)
41
+ t = t[0]
42
+ assert_equal(2880,t.seq.length)
43
+ end
44
+
45
+ def test_exons
46
+ t = Transcript.find_by_stable_id("ENST00000005257")
47
+ e = t.exons
48
+ assert_equal(5,e.size)
49
+ assert_equal("ENSE00001829077",e[0].stable_id)
50
+ seq1 = "AGGCCCATGATCACCCTCCTCTCAGCCCACGGACAGGAAGTCGCTCCCCAGCTGCCCCGCCCCGCTCCCCAGCGCCCCGGAAGTGATCTGTGGCGGCTGCTGCAGAGCCGCCAGGAGGAGGGTGGATCTCCCCAGAGCAAAGCGTCGGAGTCCTCCTCCTCCTTCTCCTCCTCCTCCTCCTCCTCCTCCAGCCGCCCAGGCTCCCCCGCCACCCGTCAGACTCCTCCTTCGACCGCTCCCGGCGCGGGGCCTTCCAGGCGACAAGGACCGAGTACCCTCCGGCCGGAGCCACGCAGCCGCGGCTTCCGGAGCCCTCGGGGCGGCGGACTGGCTCGCGGTGCAG"
51
+ assert_equal(seq1,e[0].seq.upcase)
52
+ assert_equal(39663082,e[0].start)
53
+ assert_equal(39663424,e[0].stop)
54
+ assert_equal("ENSE00000832451",e[1].stable_id)
55
+ seq2 = "ATTCTTCTTAATCCTTTGGTGAAAACTGAGACACAAAATGGCTGCAAATAAGCCCAAGGGTCAGAATTCTTTGGCTTTACACAAAGTCATCATGGTGGGCAGTGGTGGCGTGGGCAAGTCAGCTCTGACTCTACAGTTCATGTACGATGAG"
56
+ assert_equal(seq2,e[1].seq.upcase)
57
+ assert_equal(39726230,e[1].start)
58
+ assert_equal(39726380,e[1].stop)
59
+ end
60
+
61
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # = test/unit/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
+ require File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
11
+
12
+ include Ensembl::Core
13
+
14
+ class AssemblyExceptions < Test::Unit::TestCase
15
+
16
+ def setup
17
+ DBConnection.connect('homo_sapiens', 60)
18
+ end
19
+
20
+ def teardown
21
+ DBConnection.remove_connection
22
+ end
23
+
24
+ def test_chr_x
25
+ source_slice = Slice.fetch_by_region('chromosome','X', 2709497, 2709520)
26
+ assert_equal('ctgaagaattgtgtttcttcccta', source_slice.seq)
27
+ end
28
+
29
+ def test_slice_overlapping_PAR_and_allosome
30
+ source_slice = Slice.fetch_by_region('chromosome','Y',2709500,2709540)
31
+ assert_equal('AGAAACTGAAAATGCTAAGAAATTCAGTTCCAGGATATGAA', source_slice.seq.upcase)
32
+ end
33
+
34
+ end
@@ -0,0 +1,42 @@
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 File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
11
+
12
+ include Ensembl::Core
13
+
14
+ class TestSlice < Test::Unit::TestCase
15
+
16
+ def setup
17
+ DBConnection.connect('homo_sapiens', 60)
18
+ end
19
+
20
+ def teardown
21
+ DBConnection.remove_connection
22
+ end
23
+
24
+ def test_forward
25
+ seq1 = "GGCCAAGCTGGTCTCAAACTCCTGACCTCGTGATCCGCCCACCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGGGCCACTGGGTCCGGCCGCATGTCTGGCTAATTTTGTAGAGACAGGGCCTCCCTATACTGCCCAGGCTGGTTTCAAGCTCCTGGCTTCAAGGGGTCCTCCTGCCTTGGCCTCCCGAAGTGCTGG"
26
+ s = Slice.fetch_by_region("chromosome","13",31786617,31786816,1)
27
+ assert_equal(seq1,s.seq.upcase)
28
+ assert_equal("13",s.seq_region.name)
29
+ assert_equal(31786617,s.start)
30
+ assert_equal(31786816,s.stop)
31
+ end
32
+
33
+ def test_reverse
34
+ seq2 = "CCAGCACTTCGGGAGGCCAAGGCAGGAGGACCCCTTGAAGCCAGGAGCTTGAAACCAGCCTGGGCAGTATAGGGAGGCCCTGTCTCTACAAAATTAGCCAGACATGCGGCCGGACCCAGTGGCCCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGTGGGCGGATCACGAGGTCAGGAGTTTGAGACCAGCTTGGCC"
35
+ s_rev = Slice.fetch_by_region("chromosome","13",31786617,31786816,-1)
36
+ assert_equal(seq2,s_rev.seq.upcase)
37
+ assert_equal("13",s_rev.seq_region.name)
38
+ assert_equal(31786617,s_rev.start)
39
+ assert_equal(31786816,s_rev.stop)
40
+ end
41
+
42
+ end
@@ -0,0 +1,120 @@
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', 60)
14
+
15
+ class CodingPositions < Test::Unit::TestCase
16
+ def setup
17
+ # Transcript tr_fw is ENST00000215574
18
+ @tr_fw = Transcript.find_by_stable_id("ENST00000215574")
19
+ # Transcript tr_rev is ENST00000358041
20
+ @tr_rev = Transcript.find_by_stable_id("ENST00000358041")
21
+ end
22
+
23
+ def test_transcript_coords
24
+ assert_equal(531733, @tr_fw.seq_region_start)
25
+ assert_equal(542084, @tr_fw.seq_region_end)
26
+ assert_equal(644371, @tr_rev.seq_region_start)
27
+ assert_equal(647309, @tr_rev.seq_region_end)
28
+ end
29
+
30
+ def test_coding_regions_genomic_coords_of_fw
31
+ assert_equal(531932, @tr_fw.coding_region_genomic_start)
32
+ assert_equal(541552, @tr_fw.coding_region_genomic_end)
33
+ end
34
+
35
+ def test_coding_regions_genomic_coords_of_rev
36
+ assert_equal(646652, @tr_rev.coding_region_genomic_start)
37
+ assert_equal(647047, @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
+ # Strand
57
+ # Ensembl_Exon_ID
58
+ # Exon_Chr_Start
59
+ # Exon_Chr_End
60
+ # Exon_Rank_in_Transcript
61
+ #ENST00000215574 19 1 ENSE00000655676 531733 532108 1
62
+ #ENST00000215574 19 1 ENSE00000655677 535837 535923 2
63
+ #ENST00000215574 19 1 ENSE00000655678 536243 536340 3
64
+ #ENST00000215574 19 1 ENSE00000655679 537013 537147 4
65
+ #ENST00000215574 19 1 ENSE00000655680 541339 542084 5
66
+ #
67
+ #ENST00000315489 19 -1 ENSE00001215510 474621 474983 1
68
+ #ENST00000315489 19 -1 ENSE00001215495 472394 472501 2
69
+ #ENST00000315489 19 -1 ENSE00001215487 467649 467762 3
70
+ #ENST00000315489 19 -1 ENSE00001215506 463344 464364 4
71
+ def setup
72
+ # Transcript tr_fw is ENST00000215574
73
+ @tr_fw = Transcript.find_by_stable_id("ENST00000215574")
74
+ # Transcript tr_rev is ENST00000315489
75
+ @tr_rev = Transcript.find_by_stable_id("ENST00000315489")
76
+ end
77
+
78
+ def test_identify_exon
79
+ assert_equal("ENSE00000655679", @tr_fw.exon_for_cdna_position(601).stable_id)
80
+ assert_equal("ENSE00000655679", @tr_fw.exon_for_genomic_position(537052).stable_id)
81
+ assert_equal("ENSE00001215487", @tr_rev.exon_for_cdna_position(541).stable_id)
82
+ assert_equal("ENSE00001215487", @tr_rev.exon_for_genomic_position(467693).stable_id)
83
+ end
84
+
85
+ def test_cdna2genomic
86
+ assert_equal(537052, @tr_fw.cdna2genomic(601))
87
+ assert_equal(467693, @tr_rev.cdna2genomic(541))
88
+ end
89
+
90
+ def test_cds2genomic
91
+ assert_equal(537052, @tr_fw.cds2genomic(401))
92
+ assert_equal(467693, @tr_rev.cds2genomic(304))
93
+ end
94
+
95
+ def test_genomic2cdna
96
+ assert_equal(601, @tr_fw.genomic2cdna(537052))
97
+ assert_equal(541, @tr_rev.genomic2cdna(467693))
98
+ end
99
+
100
+ def test_genomic2cds
101
+ assert_equal(401, @tr_fw.genomic2cds(537052))
102
+ assert_equal(304, @tr_rev.genomic2cds(467693))
103
+ end
104
+ end
105
+
106
+ class TestIntron < Test::Unit::TestCase
107
+ def setup
108
+ @transcript = Transcript.find_by_stable_id("ENST00000215574")
109
+ @introns = @transcript.introns
110
+ end
111
+
112
+ def test_get_introns
113
+ assert_equal(4, @introns.length)
114
+ end
115
+
116
+ def test_intron_slices
117
+ assert_equal('chromosome:GRCh37:19:532109:535836:1', @introns[0].slice.to_s)
118
+ end
119
+ end
120
+
@@ -0,0 +1,57 @@
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 File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
12
+
13
+ include Ensembl::Core
14
+
15
+
16
+ # For all tests, the source (i.e. the seq_region that the feature is annotated
17
+ # on initially) remains forward.
18
+ #
19
+ # Same coordinate system: test names refer to direction of gene vs chromosome
20
+ class TransformOntoSameCoordinateSystem < Test::Unit::TestCase
21
+
22
+ def setup
23
+ DBConnection.connect('homo_sapiens', 60)
24
+ end
25
+
26
+ def teardown
27
+ DBConnection.remove_connection
28
+ end
29
+
30
+ def test_fw
31
+ source_gene = Gene.find_by_stable_id("ENSG00000242450")
32
+ target_gene = source_gene.transform('chromosome')
33
+
34
+ assert_equal('22', source_gene.seq_region.name)
35
+ assert_equal(24349643, source_gene.seq_region_start)
36
+ assert_equal(24349710, source_gene.seq_region_end)
37
+ assert_equal(1, source_gene.seq_region_strand)
38
+ assert_equal('22', target_gene.seq_region.name)
39
+ assert_equal(24349643, target_gene.seq_region_start)
40
+ assert_equal(24349710, target_gene.seq_region_end)
41
+ assert_equal(1, target_gene.seq_region_strand)
42
+ end
43
+
44
+ def test_rev
45
+ source_gene = Gene.find_by_stable_id("ENSG00000240339")
46
+ target_gene = source_gene.transform('chromosome')
47
+ assert_equal('22', source_gene.seq_region.name)
48
+ assert_equal(24349560, source_gene.seq_region_start)
49
+ assert_equal(24349631, source_gene.seq_region_end)
50
+ assert_equal(-1, source_gene.seq_region_strand)
51
+ assert_equal('22', target_gene.seq_region.name)
52
+ assert_equal(24349560, target_gene.seq_region_start)
53
+ assert_equal(24349631, target_gene.seq_region_end)
54
+ assert_equal(-1, target_gene.seq_region_strand)
55
+ end
56
+
57
+ end
@@ -0,0 +1,216 @@
1
+ #
2
+ # = test/unit/release_56/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 File.expand_path File.join(File.dirname(__FILE__),"../../helper.rb")
11
+
12
+ include Ensembl::Variation
13
+
14
+ class ActiveRecordVariation < Test::Unit::TestCase
15
+
16
+ def setup
17
+ DBConnection.connect('homo_sapiens',60)
18
+ end
19
+
20
+ def teardown
21
+ DBConnection.remove_connection
22
+ end
23
+
24
+ def test_allele
25
+ allele = Allele.find(1)
26
+ assert_equal('T', allele.allele)
27
+ assert_equal(0.04, allele.frequency)
28
+ end
29
+
30
+ def test_sample
31
+ n = Sample.count(:all)
32
+ assert_equal(30351,n)
33
+ individual = Sample.find(12468).individual
34
+ assert_equal('Male',individual.gender)
35
+ i = Sample.find(13131).individual_genotype_multiple_bp
36
+ assert_equal(5,i.size)
37
+ assert_equal(1688213,i[0].variation_id)
38
+ syn = Sample.find(21).sample_synonym
39
+ assert_equal('6',syn.name)
40
+ end
41
+
42
+ def test_individual
43
+ n = Individual.count(:all)
44
+ assert_equal(12307,n)
45
+ end
46
+
47
+ def test_individual_genotype_multiple_bp
48
+ n = IndividualGenotypeMultipleBp.count(:all)
49
+ assert_equal(1009778,n)
50
+ end
51
+
52
+ def test_compressed_genotype_single_bp
53
+ n = CompressedGenotypeSingleBp.count(:all)
54
+ assert_equal(67856517,n)
55
+ end
56
+
57
+ def test_read_coverage
58
+ n = ReadCoverage.count(:all)
59
+ assert_equal(4183832,n)
60
+ end
61
+
62
+ def test_population
63
+ n = Population.count(:all)
64
+ assert_equal(11673,n)
65
+ p = Population.find(236)
66
+ ind = p.individuals
67
+ assert_equal(653,ind.size)
68
+ end
69
+
70
+ def test_variation
71
+ n = Variation.count(:all)
72
+ assert_equal(24623913,n)
73
+
74
+ syn = Variation.find(712422).variation_synonyms
75
+ assert_equal(1,syn.size)
76
+ assert_equal('rs56673311',syn[0].name)
77
+
78
+ flanking = Variation.find(10000).flanking_sequence
79
+ assert_equal(132077099,flanking.up_seq_region_start)
80
+ assert_equal(132077128,flanking.up_seq_region_end)
81
+ assert_equal(132077130,flanking.down_seq_region_start)
82
+ assert_equal(132077159,flanking.down_seq_region_end)
83
+ assert_equal(27517,flanking.seq_region_id)
84
+ assert_equal(1,flanking.seq_region_strand)
85
+
86
+ ag = Variation.find(10000).allele_groups
87
+ assert_nil ag[0]
88
+
89
+ pg = Variation.find(1234).population_genotypes
90
+ assert_equal(28,pg.size)
91
+ assert_equal('A',pg[0].allele_1)
92
+ assert_equal('A',pg[0].allele_2)
93
+ assert_equal(1,pg[0].frequency)
94
+
95
+ a = Variation.find(115).alleles
96
+ assert_equal(14,a.size)
97
+ assert_equal('C',a[0].allele)
98
+ assert_equal(0.733,a[0].frequency)
99
+
100
+ vf = Variation.find(5345540).variation_features[0]
101
+ assert_equal('C/T',vf.allele_string)
102
+ assert_equal('rs8192830',vf.variation_name)
103
+ assert_equal(27506,vf.seq_region_id)
104
+ assert_equal(139618573,vf.seq_region_start)
105
+ assert_equal(139618573,vf.seq_region_end)
106
+ assert_equal(1,vf.seq_region_strand)
107
+
108
+ vg = Variation.find(1352735).variation_groups
109
+ assert_nil vg[0]
110
+
111
+ i = Variation.find(243).individual_genotype_multiple_bps
112
+ assert_equal(68,i.size)
113
+ end
114
+
115
+ def test_variation_feature
116
+ vf_sample = VariationFeature.find_by_variation_name('rs167125').samples
117
+ assert_equal(1,vf_sample.size)
118
+ assert_equal('CSHL-HAPMAP:HapMap-JPT',vf_sample[0].name)
119
+ end
120
+
121
+ def test_variation_transcript
122
+ t = Variation.find_by_name('rs7671997').variation_features[0].transcript_variations
123
+ assert_equal(7,t.size)
124
+ assert_equal('WITHIN_NON_CODING_GENE',t[0].consequence_type)
125
+ assert_equal('5PRIME_UTR',t[2].consequence_type)
126
+ assert_equal(4079207,t[0].variation_feature_id)
127
+ transcript = t[0].transcript
128
+ assert_equal('processed_transcript',transcript.biotype)
129
+ assert_equal(2158121,transcript.seq_region_start)
130
+ assert_equal(2243848,transcript.seq_region_end)
131
+ assert_equal('ENST00000515357',transcript.stable_id)
132
+ e = transcript.exons
133
+ assert_equal('AGTGCGAGGCGCGCGGGGCACGGAGGGCGGTGGCGGCGGGCTCCTGCGAGAAGCAAGCGGAACTTCCTGAG',e[0].seq.upcase)
134
+
135
+ end
136
+
137
+ def test_source
138
+ syn = Source.find(1).sample_synonyms
139
+ assert_equal(23061,syn.size)
140
+
141
+ ag = Source.find(1).allele_groups
142
+ assert_nil ag[0]
143
+ end
144
+
145
+ def test_variation_annotation
146
+ va = VariationAnnotation.find(95)
147
+ assert_equal(1756227,va.variation_id)
148
+ assert_equal('EGAS00000000060',va.local_stable_id)
149
+ assert_equal('rs2306027',va.variation_names)
150
+ assert_equal(0.218132812399633,va.risk_allele_freq_in_controls.to_f)
151
+ end
152
+
153
+ def test_phenotype
154
+ pheno = Phenotype.find(1527)
155
+ va = pheno.variation_annotations
156
+ assert_equal(14,va.size)
157
+ assert_equal('GATA6,CTAGE1,RBBP8,CABLES1',va[5].associated_gene)
158
+ end
159
+
160
+ def test_structural_variation
161
+ sv = StructuralVariation.find(171276)
162
+ assert_equal('nsv429550',sv.variation_name)
163
+ assert_equal(224676,sv.seq_region_start)
164
+ assert_equal(44780026,sv.seq_region_end)
165
+ assert_equal('11',sv.seq_region.name)
166
+ end
167
+
168
+ def test_population_genotype
169
+ v = Variation.find(1082)
170
+ pg = v.population_genotypes
171
+ assert_equal(41,pg.size)
172
+ assert_equal(0.6,pg[0].frequency)
173
+ pop = Population.find(132)
174
+ pg = pop.population_genotypes
175
+ assert_equal(1070,pg.size)
176
+ end
177
+
178
+ def test_subsnp_handle
179
+ s = SubsnpHandle.find(946)
180
+ assert_equal('WIAF',s.handle)
181
+ pg = s.population_genotypes
182
+ assert_equal(2,pg.size)
183
+ assert_equal(0.4,pg[0].frequency)
184
+ alleles = s.alleles
185
+ assert_equal(2,alleles.size)
186
+ assert_equal('A',alleles[0].allele)
187
+ s = SubsnpHandle.find(107935890)
188
+ vs = s.variation_synonyms
189
+ assert_equal(1,vs.size)
190
+ assert_equal('ENSSNP10154320',vs[0].name)
191
+ end
192
+
193
+ def test_variation_synonym
194
+ v = Variation.find(12659557)
195
+ vs = v.variation_synonyms
196
+ assert_equal(1,vs.size)
197
+ assert_equal('rs66792216',vs[0].name)
198
+ end
199
+
200
+ def test_failed_description
201
+ v = Variation.find(15005920)
202
+ fd = v.failed_descriptions
203
+ assert_equal(1,fd.size)
204
+ assert_equal('Variation maps to more than 3 different locations',fd[0].description)
205
+ end
206
+
207
+ def test_variation_set
208
+ v = Variation.find(8)
209
+ vs = v.variation_sets
210
+ assert_equal(5,vs.size)
211
+ assert_equal("1000 genomes - Trios - CEU",vs[0].name)
212
+ assert_equal("Variations called by the 1000 genomes project on high coverage sequence data from a CEU population trio",vs[0].description)
213
+ end
214
+
215
+
216
+ end