ruby-ensembl-api 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
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,47 @@
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
@@ -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', 53)
30
+ end
31
+
32
+ def teardown
33
+ DBConnection.remove_connection
34
+ end
35
+
36
+ def test_rev
37
+ source_gene = Gene.find(102634)
38
+ target_gene = source_gene.transform('chromosome')
39
+
40
+ assert_equal('18', source_gene.seq_region.name)
41
+ assert_equal(17659657, source_gene.seq_region_start)
42
+ assert_equal(17659744, source_gene.seq_region_end)
43
+ assert_equal(-1, source_gene.seq_region_strand)
44
+ assert_equal('18', target_gene.seq_region.name)
45
+ assert_equal(17659657, target_gene.seq_region_start)
46
+ assert_equal(17659744, 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(103817)
52
+ target_gene = source_gene.transform('chromosome')
53
+ assert_equal('11', source_gene.seq_region.name)
54
+ assert_equal(66886461, source_gene.seq_region_start)
55
+ assert_equal(66886755, source_gene.seq_region_end)
56
+ assert_equal(1, source_gene.seq_region_strand)
57
+ assert_equal('11', target_gene.seq_region.name)
58
+ assert_equal(66886461, target_gene.seq_region_start)
59
+ assert_equal(66886755, target_gene.seq_region_end)
60
+ assert_equal(1, target_gene.seq_region_strand)
61
+ end
62
+
63
+ end
@@ -0,0 +1,145 @@
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
@@ -0,0 +1,71 @@
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
@@ -0,0 +1,66 @@
1
+ #
2
+ # = test/unit/release_56/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', 56)
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(39663082,g.start)
34
+ assert_equal(39747723 ,g.stop)
35
+ assert_equal(1,g.strand)
36
+ assert_equal(84642,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(5,t.size)
45
+ assert_equal("ENST00000434466",t[0].stable_id)
46
+ t = t[0]
47
+ assert_equal(768,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("ENSE00001829077",e[0].stable_id)
55
+ seq1 = "AGGCCCATGATCACCCTCCTCTCAGCCCACGGACAGGAAGTCGCTCCCCAGCTGCCCCGCCCCGCTCCCCAGCGCCCCGGAAGTGATCTGTGGCGGCTGCTGCAGAGCCGCCAGGAGGAGGGTGGATCTCCCCAGAGCAAAGCGTCGGAGTCCTCCTCCTCCTTCTCCTCCTCCTCCTCCTCCTCCTCCAGCCGCCCAGGCTCCCCCGCCACCCGTCAGACTCCTCCTTCGACCGCTCCCGGCGCGGGGCCTTCCAGGCGACAAGGACCGAGTACCCTCCGGCCGGAGCCACGCAGCCGCGGCTTCCGGAGCCCTCGGGGCGGCGGACTGGCTCGCGGTGCAG"
56
+ assert_equal(seq1,e[0].seq.upcase)
57
+ assert_equal(39663082,e[0].start)
58
+ assert_equal(39663424,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(39726230,e[1].start)
63
+ assert_equal(39726380,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', 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