ruby-ensembl-api 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/TUTORIAL.rdoc +623 -0
- data/bin/ensembl +40 -0
- data/lib/ensembl.rb +64 -0
- data/lib/ensembl/core/activerecord.rb +1914 -0
- data/lib/ensembl/core/collection.rb +60 -0
- data/lib/ensembl/core/project.rb +264 -0
- data/lib/ensembl/core/slice.rb +693 -0
- data/lib/ensembl/core/transcript.rb +425 -0
- data/lib/ensembl/core/transform.rb +97 -0
- data/lib/ensembl/db_connection.rb +216 -0
- data/lib/ensembl/variation/activerecord.rb +253 -0
- data/lib/ensembl/variation/variation.rb +163 -0
- data/test/unit/data/seq_c6qbl.fa +10 -0
- data/test/unit/data/seq_cso19_coding.fa +16 -0
- data/test/unit/data/seq_cso19_transcript.fa +28 -0
- data/test/unit/data/seq_drd3_gene.fa +838 -0
- data/test/unit/data/seq_drd3_transcript.fa +22 -0
- data/test/unit/data/seq_drd4_transcript.fa +24 -0
- data/test/unit/data/seq_forward_composite.fa +1669 -0
- data/test/unit/data/seq_par_boundary.fa +169 -0
- data/test/unit/data/seq_rnd3_transcript.fa +47 -0
- data/test/unit/data/seq_ub2r1_coding.fa +13 -0
- data/test/unit/data/seq_ub2r1_gene.fa +174 -0
- data/test/unit/data/seq_ub2r1_transcript.fa +26 -0
- data/test/unit/data/seq_y.fa +2 -0
- data/test/unit/ensembl_genomes/test_collection.rb +51 -0
- data/test/unit/ensembl_genomes/test_gene.rb +52 -0
- data/test/unit/ensembl_genomes/test_slice.rb +71 -0
- data/test/unit/ensembl_genomes/test_variation.rb +17 -0
- data/test/unit/release_50/core/test_project.rb +215 -0
- data/test/unit/release_50/core/test_project_human.rb +58 -0
- data/test/unit/release_50/core/test_relationships.rb +66 -0
- data/test/unit/release_50/core/test_sequence.rb +175 -0
- data/test/unit/release_50/core/test_slice.rb +121 -0
- data/test/unit/release_50/core/test_transcript.rb +108 -0
- data/test/unit/release_50/core/test_transform.rb +223 -0
- data/test/unit/release_50/variation/test_activerecord.rb +143 -0
- data/test/unit/release_50/variation/test_variation.rb +84 -0
- data/test/unit/release_53/core/test_gene.rb +66 -0
- data/test/unit/release_53/core/test_project.rb +96 -0
- data/test/unit/release_53/core/test_project_human.rb +65 -0
- data/test/unit/release_53/core/test_slice.rb +47 -0
- data/test/unit/release_53/core/test_transform.rb +63 -0
- data/test/unit/release_53/variation/test_activerecord.rb +145 -0
- data/test/unit/release_53/variation/test_variation.rb +71 -0
- data/test/unit/release_56/core/test_gene.rb +66 -0
- data/test/unit/release_56/core/test_project.rb +96 -0
- data/test/unit/release_56/core/test_slice.rb +54 -0
- data/test/unit/release_56/core/test_transform.rb +63 -0
- data/test/unit/release_56/variation/test_activerecord.rb +142 -0
- data/test/unit/release_56/variation/test_variation.rb +68 -0
- data/test/unit/test_connection.rb +66 -0
- data/test/unit/test_releases.rb +136 -0
- metadata +128 -0
@@ -0,0 +1,54 @@
|
|
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', 56)
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown
|
26
|
+
DBConnection.remove_connection
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_forward
|
30
|
+
seq1 = "GGCCAAGCTGGTCTCAAACTCCTGACCTCGTGATCCGCCCACCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGGGCCACTGGGTCCGGCCGCATGTCTGGCTAATTTTGTAGAGACAGGGCCTCCCTATACTGCCCAGGCTGGTTTCAAGCTCCTGGCTTCAAGGGGTCCTCCTGCCTTGGCCTCCCGAAGTGCTGG"
|
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 = "CCAGCACTTCGGGAGGCCAAGGCAGGAGGACCCCTTGAAGCCAGGAGCTTGAAACCAGCCTGGGCAGTATAGGGAGGCCCTGTCTCTACAAAATTAGCCAGACATGCGGCCGGACCCAGTGGCCCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGTGGGCGGATCACGAGGTCAGGAGTTTGAGACCAGCTTGGCC"
|
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
|
+
def test_slice_genes
|
48
|
+
slice = Slice.fetch_by_region("chromosome","13",31773073,31909413,1)
|
49
|
+
genes = slice.genes
|
50
|
+
assert_equal("ENSG00000229427",genes[1].stable_id)
|
51
|
+
assert_equal("ENSG00000187676",genes[0].stable_id)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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
|
@@ -0,0 +1,142 @@
|
|
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
|
@@ -0,0 +1,68 @@
|
|
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',56)
|
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(29708370,slice.start)
|
31
|
+
assert_equal(29718370,slice.stop)
|
32
|
+
assert_equal('6',slice.seq_region.name)
|
33
|
+
slice = vf.fetch_region(30,30)
|
34
|
+
assert_equal(29713340,slice.start)
|
35
|
+
assert_equal(29713400,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(29713371,up.start)
|
43
|
+
assert_equal(29713770,up.stop)
|
44
|
+
assert_equal(29712970,down.start)
|
45
|
+
assert_equal(29713369,down.stop)
|
46
|
+
assert_equal('GGGCCCTGCCCTGCCTTTCTGCCTGTCACAGAGCAGGAAGAGCTGACCATCCAGATGTCCCTCAGCGAGAAACCCTGACTGCACAGATCCATCCTGGGACAGCACCGTGAGGTTGTAACAAAGACTGTGGGGCTCTGGGGAAGAGGAAATCACAGATGAAACTTCTTCCTGGAAGTAACTTCACATCAATGTTTAACACACAGGTCTGCTGTCCCGACCTTCCTGAGGAGGCAGGAAATGCACACGGGCAAAGGGACAAGAATGAGGATTTCAGACGCAAGGAAAACTGGGAAGGTGGGAGGATAGAGGAGGGGACTGAGGAACAGAAGAAGGGGGAATGGGGATGGCAAACTTGTAGGCCAGGTGCCAGGGCAGGGCAGCCACAGGCCCCCTCAGGATA',
|
47
|
+
up.seq.upcase)
|
48
|
+
assert_equal('TCCTGATCTCACAAACCCTAATCTCCTGGAGGGAATGCAAGGCTGCCTGCCCCTACCCAGCAGTGACTTCTCCATTCCAGTCCAAGTGAGGAACTCGGACCAGGAAGGACCCCTCCCTGGCCCTCTTCCATCCCTCCCTGTGTGGGCTGAGCCCCGCTGAGCACCATTCCTCACCCCTACTCACAGCCAAATCCAGTGGGAAGAGACAGGTCCTGCTCTCTGCCCCCAACTCTCCTGGAAAAGGCCTCTCCCATTACTCTTGCCCACTGCCCACTCTCACCTCCTTTCTGGCCCTTGATATGAGCCAGGGTCCTCCTGAGCTCCTGCCCATTCTCTGTCAAGTCTTCAGTCTCTGTGTCCCAGGTCTCAGCTCCCAGGACTGCTTCTGCCCACTGTCCCC',
|
49
|
+
down.seq.upcase)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_slice_variation
|
54
|
+
slice = Ensembl::Core::Slice.fetch_by_region('chromosome',1,100834,101331)
|
55
|
+
variations = slice.get_variation_features
|
56
|
+
assert_equal(6,variations.size)
|
57
|
+
|
58
|
+
assert_equal('rs3912703',variations[0].variation_name)
|
59
|
+
assert_equal('ENSSNP5435782',variations[1].variation_name)
|
60
|
+
assert_equal('ENSSNP3491774',variations[2].variation_name)
|
61
|
+
assert_equal('ENSSNP283782',variations[3].variation_name)
|
62
|
+
assert_equal('ENSSNP4578340',variations[4].variation_name)
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_connection.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__), ['..'] * 2, 'lib')).cleanpath.to_s
|
13
|
+
$:.unshift(libpath) unless $:.include?(libpath)
|
14
|
+
|
15
|
+
require 'test/unit'
|
16
|
+
|
17
|
+
require 'ensembl'
|
18
|
+
|
19
|
+
|
20
|
+
class TestConnection < Test::Unit::TestCase
|
21
|
+
|
22
|
+
def test_remote_core_connection
|
23
|
+
assert_nothing_raised do
|
24
|
+
Ensembl::Core::DBConnection.connect('homo_sapiens',56)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# This is to check if the overwrite of the default parameters is possible,
|
29
|
+
# so you can specify an Ensembl database on a host that is different from the official Ensembl website.
|
30
|
+
|
31
|
+
def test_local_core_connection
|
32
|
+
|
33
|
+
# Change username, password, host and port in order to test the connection with a different Ensembl db server
|
34
|
+
assert_nothing_raised do
|
35
|
+
Ensembl::Core::DBConnection.connect('homo_sapiens',56,:username => "anonymous",:host => "ensembldb.ensembl.org", :port => 5306)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_remote_variation_connection
|
40
|
+
assert_nothing_raised do
|
41
|
+
Ensembl::Variation::DBConnection.connect('homo_sapiens',56)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_local_variation_connection
|
46
|
+
|
47
|
+
# Change username, password, host and port in order to test the connection with a different Ensembl db server
|
48
|
+
assert_nothing_raised do
|
49
|
+
Ensembl::Variation::DBConnection.connect('bos_taurus',56,:username => "anonymous",:host => "ensembldb.ensembl.org", :port => 5306)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_connection_ensembl_genomes
|
54
|
+
assert_nothing_raised do
|
55
|
+
Ensembl::Core::DBConnection.ensemblgenomes_connect('Staphylococcus_aureus_MRSA252',3)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_manual_connection_ensembl_genomes
|
60
|
+
assert_nothing_raised do
|
61
|
+
Ensembl::Core::DBConnection.connect("bacillus_collection",3,:host => "mysql.ebi.ac.uk", :port => 4157)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,136 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_releases.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__), ['..'] * 3, '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
|
+
class TestRelease53 < Test::Unit::TestCase
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
DBConnection.remove_connection
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_gene_stable_id_human
|
28
|
+
DBConnection.connect('homo_sapiens', 53)
|
29
|
+
@slice = Slice.fetch_by_region('chromosome','1',1000,100000)
|
30
|
+
assert_equal(["ENSG00000146556","ENSG00000177693","ENSG00000197490","ENSG00000205292","ENSG00000219789","ENSG00000221311","ENSG00000222003","ENSG00000222027"], @slice.genes.collect{|g| g.stable_id}.sort)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class TestRelease50 < Test::Unit::TestCase
|
35
|
+
|
36
|
+
def teardown
|
37
|
+
DBConnection.remove_connection
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_gene_stable_id
|
41
|
+
DBConnection.connect('homo_sapiens', 50)
|
42
|
+
@slice = Slice.fetch_by_region('chromosome','1',1000,100000)
|
43
|
+
assert_equal(["ENSG00000146556", "ENSG00000177693", "ENSG00000197194", "ENSG00000197490", "ENSG00000205292", "ENSG00000219789", "ENSG00000221311"], @slice.genes.collect{|g| g.stable_id}.sort)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class TestRelease49 < Test::Unit::TestCase
|
48
|
+
|
49
|
+
def teardown
|
50
|
+
DBConnection.remove_connection
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_slice_and_genes_mouse
|
54
|
+
DBConnection.connect('mus_musculus',49)
|
55
|
+
|
56
|
+
slice = Slice.fetch_by_region('chromosome',"19",52571924,52572023)
|
57
|
+
assert_equal("AAGGTTGTATTCTAGTTTGCTCTCTGTTATTGTGACAAAGACAGGACCAAAGAAACTTGAGTAGGAAATGGTTGATAAAATCTTACAAGTTAGAAGGCAG",slice.seq.upcase)
|
58
|
+
|
59
|
+
gene = Gene.find_by_stable_id("ENSMUSG00000017167")
|
60
|
+
assert_equal(101037431, gene.start)
|
61
|
+
assert_equal(101052034, gene.stop)
|
62
|
+
assert_equal(1,gene.transcripts.size)
|
63
|
+
assert_equal("ENSMUST00000103109",gene.transcripts[0].stable_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
class TestRelease47 < Test::Unit::TestCase
|
69
|
+
|
70
|
+
def teardown
|
71
|
+
DBConnection.remove_connection
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_slice_and_genes_mouse
|
75
|
+
DBConnection.connect('mus_musculus',47)
|
76
|
+
|
77
|
+
slice = Slice.fetch_by_region('chromosome',"5",123840876,123912619)
|
78
|
+
genes = slice.genes
|
79
|
+
assert_equal("ENSMUSG00000038342",genes[0].stable_id)
|
80
|
+
slice = Slice.fetch_by_region('chromosome',"5",123840876,123840975)
|
81
|
+
assert_equal("TCTCAGTTCAGGTTCTATGGGGGGGAGGGGAGGGAATGAAAAGGATGTTAACAATCACCATCACCAGGGGGGACCAATTTGAAGATCTGATCGCCGGTGT",slice.seq.upcase)
|
82
|
+
|
83
|
+
gene = Gene.find_by_stable_id("ENSMUSG00000017167")
|
84
|
+
assert_equal(101037431, gene.start)
|
85
|
+
assert_equal(101052034, gene.stop)
|
86
|
+
assert_equal(1,gene.transcripts.size)
|
87
|
+
assert_equal("ENSMUST00000103109",gene.transcripts[0].stable_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
class TestRelease45 < Test::Unit::TestCase
|
93
|
+
|
94
|
+
def teardown
|
95
|
+
DBConnection.remove_connection
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_gene_stable_id_human
|
99
|
+
DBConnection.connect('homo_sapiens', 45)
|
100
|
+
@slice = Slice.fetch_by_region('chromosome','1',1000,100000)
|
101
|
+
assert_equal(["ENSG00000146556", "ENSG00000177693", "ENSG00000197194", "ENSG00000197490", "ENSG00000205292"], @slice.genes.collect{|g| g.stable_id}.sort)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_slice_and_genes_mouse
|
105
|
+
DBConnection.connect('mus_musculus',45)
|
106
|
+
|
107
|
+
slice = Slice.fetch_by_region('chromosome',"11",101037431,101037530)
|
108
|
+
assert_equal("ACTCTATCCAACTGAAACTGGAGATTAGTAACAGGGAAAAACAAACTCAACTGACAGCTGCTCCCAGTACAGTTCTTATGGTACAGGGAGCGTGGGAGTG",slice.seq.upcase)
|
109
|
+
|
110
|
+
gene = Gene.find_by_stable_id("ENSMUSG00000017167")
|
111
|
+
assert_equal(100992131,gene.start)
|
112
|
+
assert_equal(101006814,gene.stop)
|
113
|
+
assert_equal("11",gene.seq_region.name)
|
114
|
+
assert_equal(2,gene.transcripts.size)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
class TestRelease37 < Test::Unit::TestCase
|
120
|
+
|
121
|
+
def teardown
|
122
|
+
DBConnection.remove_connection
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_gene_stable_id_human
|
126
|
+
DBConnection.connect('homo_sapiens', 37)
|
127
|
+
@slice = Slice.fetch_by_region('chromosome','1',1000,100000)
|
128
|
+
assert_equal(["ENSG00000146556", "ENSG00000177693", "ENSG00000197194", "ENSG00000197490"], @slice.genes.collect{|g| g.stable_id}.sort)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|