ruby-ensembl-api 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/TUTORIAL.rdoc +623 -0
  2. data/bin/ensembl +40 -0
  3. data/lib/ensembl.rb +64 -0
  4. data/lib/ensembl/core/activerecord.rb +1914 -0
  5. data/lib/ensembl/core/collection.rb +60 -0
  6. data/lib/ensembl/core/project.rb +264 -0
  7. data/lib/ensembl/core/slice.rb +693 -0
  8. data/lib/ensembl/core/transcript.rb +425 -0
  9. data/lib/ensembl/core/transform.rb +97 -0
  10. data/lib/ensembl/db_connection.rb +216 -0
  11. data/lib/ensembl/variation/activerecord.rb +253 -0
  12. data/lib/ensembl/variation/variation.rb +163 -0
  13. data/test/unit/data/seq_c6qbl.fa +10 -0
  14. data/test/unit/data/seq_cso19_coding.fa +16 -0
  15. data/test/unit/data/seq_cso19_transcript.fa +28 -0
  16. data/test/unit/data/seq_drd3_gene.fa +838 -0
  17. data/test/unit/data/seq_drd3_transcript.fa +22 -0
  18. data/test/unit/data/seq_drd4_transcript.fa +24 -0
  19. data/test/unit/data/seq_forward_composite.fa +1669 -0
  20. data/test/unit/data/seq_par_boundary.fa +169 -0
  21. data/test/unit/data/seq_rnd3_transcript.fa +47 -0
  22. data/test/unit/data/seq_ub2r1_coding.fa +13 -0
  23. data/test/unit/data/seq_ub2r1_gene.fa +174 -0
  24. data/test/unit/data/seq_ub2r1_transcript.fa +26 -0
  25. data/test/unit/data/seq_y.fa +2 -0
  26. data/test/unit/ensembl_genomes/test_collection.rb +51 -0
  27. data/test/unit/ensembl_genomes/test_gene.rb +52 -0
  28. data/test/unit/ensembl_genomes/test_slice.rb +71 -0
  29. data/test/unit/ensembl_genomes/test_variation.rb +17 -0
  30. data/test/unit/release_50/core/test_project.rb +215 -0
  31. data/test/unit/release_50/core/test_project_human.rb +58 -0
  32. data/test/unit/release_50/core/test_relationships.rb +66 -0
  33. data/test/unit/release_50/core/test_sequence.rb +175 -0
  34. data/test/unit/release_50/core/test_slice.rb +121 -0
  35. data/test/unit/release_50/core/test_transcript.rb +108 -0
  36. data/test/unit/release_50/core/test_transform.rb +223 -0
  37. data/test/unit/release_50/variation/test_activerecord.rb +143 -0
  38. data/test/unit/release_50/variation/test_variation.rb +84 -0
  39. data/test/unit/release_53/core/test_gene.rb +66 -0
  40. data/test/unit/release_53/core/test_project.rb +96 -0
  41. data/test/unit/release_53/core/test_project_human.rb +65 -0
  42. data/test/unit/release_53/core/test_slice.rb +47 -0
  43. data/test/unit/release_53/core/test_transform.rb +63 -0
  44. data/test/unit/release_53/variation/test_activerecord.rb +145 -0
  45. data/test/unit/release_53/variation/test_variation.rb +71 -0
  46. data/test/unit/release_56/core/test_gene.rb +66 -0
  47. data/test/unit/release_56/core/test_project.rb +96 -0
  48. data/test/unit/release_56/core/test_slice.rb +54 -0
  49. data/test/unit/release_56/core/test_transform.rb +63 -0
  50. data/test/unit/release_56/variation/test_activerecord.rb +142 -0
  51. data/test/unit/release_56/variation/test_variation.rb +68 -0
  52. data/test/unit/test_connection.rb +66 -0
  53. data/test/unit/test_releases.rb +136 -0
  54. metadata +128 -0
@@ -0,0 +1,143 @@
1
+ #
2
+ # = test/unit/release_50/variation/test_activerecord.rb - Unit test for Ensembl::Variation
3
+ #
4
+ # Copyright:: Copyright (C) 2008 Francesco Strozzi <francesco.strozzi@gmail.com>
5
+ #
6
+ # License:: Ruby's
7
+ #
8
+ # $Id:
9
+ require 'pathname'
10
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
11
+ $:.unshift(libpath) unless $:.include?(libpath)
12
+
13
+ require 'test/unit'
14
+ require 'lib/ensembl'
15
+
16
+ include Ensembl::Variation
17
+ DBConnection.connect('homo_sapiens',50)
18
+
19
+ class ActiveRecordVariation < Test::Unit::TestCase
20
+
21
+ def test_allele
22
+ allele = Allele.find(1)
23
+ assert_equal('T', allele.allele)
24
+ assert_equal(0.04, allele.frequency)
25
+ end
26
+
27
+ def test_allele_group
28
+ n = AlleleGroup.count(:all)
29
+ assert_equal(0, n)
30
+ end
31
+
32
+ def test_sample
33
+ n = Sample.count(:all)
34
+ assert_equal(12385,n)
35
+ individual = Sample.find(5499).individual
36
+ assert_equal('Male',individual.gender)
37
+ i = Sample.find(6201).individual_genotype_multiple_bp
38
+ assert_equal(1256,i.size)
39
+ assert_equal(548383,i[0].variation_id)
40
+ syn = Sample.find(17).sample_synonym
41
+ assert_equal('5',syn.name)
42
+ end
43
+
44
+ def test_individual
45
+ n = Individual.count(:all)
46
+ assert_equal(7769,n)
47
+ end
48
+
49
+ def test_individual_genotype_multiple_bp
50
+ n = IndividualGenotypeMultipleBp.count(:all)
51
+ assert_equal(835033,n)
52
+ end
53
+
54
+ def test_compressed_genotype_single_bp
55
+ n = CompressedGenotypeSingleBp.count(:all)
56
+ assert_equal(12473477,n)
57
+ end
58
+
59
+ def test_read_coverage
60
+ n = ReadCoverage.count(:all)
61
+ assert_equal(9328349,n)
62
+ end
63
+
64
+ def test_population
65
+ n = Population.count(:all)
66
+ assert_equal(4616,n)
67
+ end
68
+
69
+ def test_variation
70
+ n = Variation.count(:all)
71
+ assert_equal(13383219,n)
72
+
73
+ syn = Variation.find(27).variation_synonyms
74
+ assert_equal('SNP001745772',syn[0].name)
75
+
76
+ flanking = Variation.find(130).flanking_sequence
77
+ assert_equal(24910767,flanking.up_seq_region_start)
78
+ assert_equal(24911281,flanking.up_seq_region_end)
79
+ assert_equal(24911283,flanking.down_seq_region_start)
80
+ assert_equal(24911367,flanking.down_seq_region_end)
81
+ assert_equal(226030,flanking.seq_region_id)
82
+ assert_equal(1,flanking.seq_region_strand)
83
+
84
+ ag = Variation.find(130).allele_groups
85
+ assert_nil ag[0]
86
+
87
+ pg = Variation.find(1125).population_genotypes
88
+ assert_equal(26,pg.size)
89
+ assert_equal('A',pg[0].allele_1)
90
+ assert_equal('A',pg[0].allele_2)
91
+ assert_equal(0.2,pg[0].frequency)
92
+
93
+ a = Variation.find(115).alleles
94
+ assert_equal(8,a.size)
95
+ assert_equal('C',a[0].allele)
96
+ assert_equal(0.733,a[0].frequency)
97
+
98
+ vf = Variation.find(5345540).variation_features[0]
99
+ assert_equal('G/A',vf.allele_string)
100
+ assert_equal('rs8175337',vf.variation_name)
101
+ assert_equal(226028,vf.seq_region_id)
102
+ assert_equal(10052344,vf.seq_region_start)
103
+ assert_equal(10052344,vf.seq_region_end)
104
+ assert_equal(1,vf.seq_region_strand)
105
+
106
+ vg = Variation.find(1352735).variation_groups
107
+ assert_nil vg[0]
108
+
109
+ i = Variation.find(1352735).individual_genotype_multiple_bps
110
+ assert_equal(31,i.size)
111
+ end
112
+
113
+ def test_variation_feature
114
+ vf_sample = VariationFeature.find(4571).samples
115
+ assert_equal(5,vf_sample.size)
116
+ assert_equal('PERLEGEN:AFD_EUR_PANEL',vf_sample[0].name)
117
+ end
118
+
119
+ def test_variation_transcript
120
+ t = Variation.find_by_name('rs35303525').variation_features[0].transcript_variations
121
+ assert_equal(5,t.size)
122
+ assert_equal(69644,t[0].transcript_id)
123
+ transcript = t[0].transcript
124
+ assert_equal('protein_coding',transcript.biotype)
125
+ assert_equal(2050017,transcript.seq_region_start)
126
+ assert_equal(2148813,transcript.seq_region_end)
127
+ assert_equal('ENST00000382857',transcript.stable_id)
128
+ e = transcript.exons
129
+ assert_equal('ATGGCTGTGGGGAGCCAG',e[0].seq.upcase)
130
+ end
131
+
132
+ def test_source
133
+ syn = Source.find(1).sample_synonyms
134
+ assert_equal('2',syn[0].name)
135
+
136
+ ag = Source.find(1).allele_groups
137
+ assert_nil ag[0]
138
+
139
+ v = Source.find(6).variations
140
+ assert_equal(19,v.size)
141
+ assert_equal('SNP_A-8319323',v[0].name)
142
+ end
143
+ end
@@ -0,0 +1,84 @@
1
+ #
2
+ # = test/unit/release_50/variation/test_variation.tb - Unit test for Ensembl::Variation
3
+ #
4
+ # Copyright:: Copyright (C) 2008 Francesco Strozzi <francesco.strozzi@gmail.com>
5
+ #
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
+ DBConnection.connect('homo_sapiens',50)
18
+
19
+ class TestVariation < Test::Unit::TestCase
20
+
21
+ def test_fetch_region
22
+ vf = Variation.find_by_name('rs2076175').variation_features[0]
23
+ slice = vf.fetch_region
24
+ assert_equal(29816349,slice.start)
25
+ assert_equal(29826349,slice.stop)
26
+ assert_equal('6',slice.seq_region.name)
27
+ slice = vf.fetch_region(30,30)
28
+ assert_equal(29821319,slice.start)
29
+ assert_equal(29821379,slice.stop)
30
+ assert_equal('CTCCCAGGACTGCTTCTGCCCACTGTCCCCGGGGCCCTGCCCTGCCTTTCTGCCTGTCACA',slice.seq.upcase)
31
+ end
32
+
33
+ def test_flanking_seq
34
+ vf = Variation.find_by_name('rs2076175').variation_features[0]
35
+ up,down = vf.flanking_seq
36
+ assert_equal(29820949,up.start)
37
+ assert_equal(29821348,up.stop)
38
+ assert_equal(29821350,down.start)
39
+ assert_equal(29821749,down.stop)
40
+ assert_equal('TCCTGATCTCACAAACCCTAATCTCCTGGAGGGAATGCAAGGCTGCCTGCCCCTACCCAGCAGTGACTTCTCCATTCCAGTCCAAGTGAGGAACTCGGACCAGGAAGGACCCCTCCCTGGCCCTCTTCCATCCCTCCCTGTGTGGGCTGAGCCCCGCTGAGCACCATTCCTCACCCCTACTCACAGCCAAATCCAGTGGGAAGAGACAGGTCCTGCTCTCTGCCCCCAACTCTCCTGGAAAAGGCCTCTCCCATTACTCTTGCCCACTGCCCACTCTCACCTCCTTTCTGGCCCTTGATATGAGCCAGGGTCCTCCTGAGCTCCTGCCCATTCTCTGTCAAGTCTTCAGTCTCTGTGTCCCAGGTCTCAGCTCCCAGGACTGCTTCTGCCCACTGTCCCC',
41
+ up.seq.upcase)
42
+ assert_equal('GGGCCCTGCCCTGCCTTTCTGCCTGTCACAGAGCAGGAAGAGCTGACCATCCAGATGTCCCTCAGCGAGAAACCCTGACTGCACAGATCCATCCTGGGACAGCACCGTGAGGTTGTAACAAAGACTGTGGGGCTCTGGGGAAGAGGAAATCACAGATGAAACTTCTTCCTGGAAGTAACTTCACATCAATGTTTAACACACAGGTCTGCTGTCCCGACCTTCCTGAGGAGGCAGGAAATGCACACGGGCAAAGGGACAAGAATGAGGATTTCAGACGCAAGGAAAACTGGGAAGGTGGGAGGATAGAGGAGGGGACTGAGGAACAGAAGAAGGGGGAATGGGGATGGCAAACTTGTAGGCCAGGTGCCAGGGCAGGGCAGCCACAGGCCCCCTCAGGATA',
43
+ down.seq.upcase)
44
+
45
+ end
46
+
47
+ def test_slice_variation
48
+ slice = Ensembl::Core::Slice.fetch_by_region('chromosome',1,50000,51000)
49
+ variations = slice.get_variation_features
50
+ assert_equal(9,variations.size)
51
+ assert_equal('ENSSNP4691381',variations[0].variation_name)
52
+ assert_equal('ENSSNP9996411',variations[1].variation_name)
53
+ assert_equal('rs2691281',variations[2].variation_name)
54
+ assert_equal('ENSSNP4068519',variations[3].variation_name)
55
+ assert_equal('ENSSNP230814',variations[4].variation_name)
56
+ assert_equal('ENSSNP4010737',variations[5].variation_name)
57
+ assert_equal('rs2531295',variations[6].variation_name)
58
+ assert_equal('ENSSNP5092147',variations[7].variation_name)
59
+ assert_equal('ENSSNP5346602',variations[8].variation_name)
60
+
61
+ genotyped = slice.get_genotyped_variation_features
62
+ assert_equal(7,genotyped.size)
63
+ assert_equal('ENSSNP4691381',genotyped[0].variation_name)
64
+ assert_equal('genotyped',genotyped[0].flags)
65
+ assert_equal('ENSSNP9996411',genotyped[1].variation_name)
66
+ assert_equal('genotyped',genotyped[1].flags)
67
+ assert_equal('ENSSNP4068519',genotyped[2].variation_name)
68
+ assert_equal('genotyped',genotyped[2].flags)
69
+ assert_equal('ENSSNP230814',genotyped[3].variation_name)
70
+ assert_equal('genotyped',genotyped[3].flags)
71
+ assert_equal('ENSSNP4010737',genotyped[4].variation_name)
72
+ assert_equal('genotyped',genotyped[4].flags)
73
+ assert_equal('ENSSNP5092147',genotyped[5].variation_name)
74
+ assert_equal('genotyped',genotyped[5].flags)
75
+ assert_equal('ENSSNP5346602',genotyped[6].variation_name)
76
+ assert_equal('genotyped',genotyped[6].flags)
77
+
78
+ v = variations[0].variation
79
+ assert_equal(16366812,v.variation_id)
80
+ end
81
+
82
+
83
+
84
+ end
@@ -0,0 +1,66 @@
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 '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 TestGene < 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_gene
30
+ g = Gene.find_by_stable_id("ENSG00000006451")
31
+ assert_equal("ENSG00000006451",g.stable_id)
32
+ assert_equal("7",g.seq_region.name)
33
+ assert_equal(39629687,g.start)
34
+ assert_equal(39714240,g.stop)
35
+ assert_equal(1,g.strand)
36
+ assert_equal(84554,g.seq.length)
37
+ assert_equal("Ras-related protein Ral-A Precursor [Source:UniProtKB/Swiss-Prot;Acc:P11233]",g.description)
38
+ assert_equal("RALA",g.name)
39
+ end
40
+
41
+ def test_transcript
42
+ g = Gene.find_by_stable_id("ENSG00000006451")
43
+ t = g.transcripts
44
+ assert_equal(1,t.size)
45
+ assert_equal("ENST00000005257",t[0].stable_id)
46
+ t = t[0]
47
+ assert_equal(2792,t.seq.length)
48
+ end
49
+
50
+ def test_exons
51
+ t = Transcript.find_by_stable_id("ENST00000005257")
52
+ e = t.exons
53
+ assert_equal(5,e.size)
54
+ assert_equal("ENSE00001324495",e[0].stable_id)
55
+ seq1 = "AAGTGATCTGTGGCGGCTGCTGCAGAGCCGCCAGGAGGAGGGTGGATCTCCCCAGAGCAAAGCGTCGGAGTCCTCCTCCTCCTTCTCCTCCTCCTCCTCCTCCTCCTCCAGCCGCCCAGGCTCCCCCGCCACCCGTCAGACTCCTCCTTCGACCGCTCCCGGCGCGGGGCCTTCCAGGCGACAAGGACCGAGTACCCTCCGGCCGGAGCCACGCAGCCGCGGCTTCCGGAGCCCTCGGGGCGGCGGACTGGCTCGCGGTGCAG"
56
+ assert_equal(seq1,e[0].seq.upcase)
57
+ assert_equal(39629687,e[0].start)
58
+ assert_equal(39629949,e[0].stop)
59
+ assert_equal("ENSE00000832451",e[1].stable_id)
60
+ seq2 = "ATTCTTCTTAATCCTTTGGTGAAAACTGAGACACAAAATGGCTGCAAATAAGCCCAAGGGTCAGAATTCTTTGGCTTTACACAAAGTCATCATGGTGGGCAGTGGTGGCGTGGGCAAGTCAGCTCTGACTCTACAGTTCATGTACGATGAG"
61
+ assert_equal(seq2,e[1].seq.upcase)
62
+ assert_equal(39692755,e[1].start)
63
+ assert_equal(39692905,e[1].stop)
64
+ end
65
+
66
+ end
@@ -0,0 +1,96 @@
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', 53)
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
@@ -0,0 +1,65 @@
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 'pathname'
11
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
12
+ $:.unshift(libpath) unless $:.include?(libpath)
13
+ require 'test/unit'
14
+ require 'lib/ensembl'
15
+
16
+ include Ensembl::Core
17
+
18
+ class AssemblyExceptions < Test::Unit::TestCase
19
+
20
+ def setup
21
+ DBConnection.connect('homo_sapiens', 53)
22
+ end
23
+
24
+ def teardown
25
+ DBConnection.remove_connection
26
+ end
27
+
28
+ def test_chr_x
29
+ source_slice = Slice.fetch_by_region('chromosome','X', 2709497, 2709520)
30
+ assert_equal('tagttatagattaaaagaagttaa', source_slice.seq)
31
+ end
32
+
33
+ def test_slice_overlapping_PAR_and_allosome
34
+ source_slice = Slice.fetch_by_region('chromosome','Y',2709500,2709540)
35
+ target_slices = source_slice.project('contig')
36
+ assert_equal('contig::AC006209.25.1.141759:23323:23343:-1', target_slices[0].display_name)
37
+ assert_equal('contig::AC006040.3.1.186504:57272:57291:1', target_slices[1].display_name)
38
+ end
39
+
40
+ def test_seq_slice_overlapping_PAR
41
+ seq = ''
42
+ File.open("test/unit/data/seq_y.fa").reject{|l| l=~/^>/}.each do |line|
43
+ line.chomp!
44
+ seq += line
45
+ end
46
+ seq.downcase!
47
+
48
+ source_slice = Slice.fetch_by_region('chromosome', 'Y', 2709497, 2709542)
49
+ assert_equal(seq.downcase, source_slice.seq)
50
+ end
51
+
52
+ # The MHC haplotypes for human are not implemented yet, so we raise an error
53
+ # in the code.
54
+ def test_seq_slice_overlapping_HAP
55
+ seq = ''
56
+ File.open('test/unit/data/seq_c6qbl.fa').reject{|l| l=~/^>/}.each do |line|
57
+ line.chomp!
58
+ seq += line
59
+ end
60
+ seq.downcase!
61
+
62
+ source_slice = Slice.fetch_by_region('chromosome', 'c6_QBL', 33451191, 33451690)
63
+ assert_raise(NotImplementedError) {source_slice.seq}
64
+ end
65
+ end