jandot-ruby-ensembl-api 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/TUTORIAL +623 -0
- data/bin/ensembl +39 -0
- data/lib/ensembl/core/activerecord.rb +1847 -0
- data/lib/ensembl/core/project.rb +248 -0
- data/lib/ensembl/core/slice.rb +627 -0
- data/lib/ensembl/core/transcript.rb +425 -0
- data/lib/ensembl/core/transform.rb +97 -0
- data/lib/ensembl/db_connection.rb +148 -0
- data/lib/ensembl/variation/activerecord.rb +308 -0
- data/lib/ensembl.rb +23 -0
- data/samples/examples_perl_tutorial.rb +120 -0
- data/samples/small_example_ruby_api.rb +34 -0
- data/test/unit/release_45/core/run_tests.rb +12 -0
- data/test/unit/release_45/core/test_project.rb +235 -0
- data/test/unit/release_45/core/test_project_human.rb +58 -0
- data/test/unit/release_45/core/test_relationships.rb +61 -0
- data/test/unit/release_45/core/test_sequence.rb +175 -0
- data/test/unit/release_45/core/test_slice.rb +56 -0
- data/test/unit/release_45/core/test_transcript.rb +94 -0
- data/test/unit/release_45/core/test_transform.rb +223 -0
- data/test/unit/release_45/variation/test_activerecord.rb +32 -0
- data/test/unit/release_50/core/run_tests.rb +12 -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 +136 -0
- data/test/unit/test_connection.rb +58 -0
- data/test/unit/test_releases.rb +40 -0
- metadata +243 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_seq.rb - Unit test for Ensembl::Core
|
3
|
+
#
|
4
|
+
# Copyright:: Copyright (C) 2008
|
5
|
+
# Jan Aerts <http://jandot.myopenid.com>
|
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 'yaml'
|
15
|
+
require 'ensembl'
|
16
|
+
|
17
|
+
include Ensembl::Variation
|
18
|
+
|
19
|
+
DBConnection.connect('homo_sapiens')
|
20
|
+
|
21
|
+
class Simple < Test::Unit::TestCase
|
22
|
+
def test_allele
|
23
|
+
allele = Allele.find(1)
|
24
|
+
assert_equal('T', allele.allele)
|
25
|
+
assert_equal(0.04, allele.frequency)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_allele_group
|
29
|
+
allele_group = AlleleGroup.find(1)
|
30
|
+
assert_equal('ABDR-1', allele_group.name)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
# Either run the tests that use Bos taurus
|
4
|
+
require 'test_project'
|
5
|
+
require 'test_transform'
|
6
|
+
require 'test_slice'
|
7
|
+
|
8
|
+
# Or the ones using Homo sapiens
|
9
|
+
#require 'test_relationships'
|
10
|
+
#require 'test_project_human'
|
11
|
+
#require 'test_sequence'
|
12
|
+
#require 'test_transcript'
|
@@ -0,0 +1,215 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_project.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 '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 'ensembl'
|
15
|
+
|
16
|
+
include Ensembl::Core
|
17
|
+
|
18
|
+
DBConnection.connect('bos_taurus', 50)
|
19
|
+
|
20
|
+
class CoordinateMappingsTestSimple < Test::Unit::TestCase
|
21
|
+
# First see if the relationships work
|
22
|
+
def test_assemblies
|
23
|
+
# Contig AAFC03055291 should only be a component of chromosome 20
|
24
|
+
contig_coord_system = CoordSystem.find_by_name('contig')
|
25
|
+
aafc03055291 = SeqRegion.find_by_name_and_coord_system_id('AAFC03055291', contig_coord_system.id)
|
26
|
+
assert_equal(1, aafc03055291.assembled_seq_regions.length)
|
27
|
+
|
28
|
+
# Chromosome 20 has 2970 components
|
29
|
+
chr_coord_system = CoordSystem.find_by_name('chromosome')
|
30
|
+
chr20 = SeqRegion.find_by_name_and_coord_system_id('20', chr_coord_system.id)
|
31
|
+
assert_equal(2970, chr20.component_seq_regions.length)
|
32
|
+
|
33
|
+
# Chromosome 20 has 2970 contigs
|
34
|
+
assert_equal(2970, chr20.component_seq_regions('contig').length)
|
35
|
+
|
36
|
+
# Positions of the link between Chr20 and AAFC03055291
|
37
|
+
# * Contig AAFC03055291 starts at position 13970982 on chromosome Chr20
|
38
|
+
assert_equal(13970982, aafc03055291.assembly_links_as_component('chromosome')[0].asm_start)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Sequences < Test::Unit::TestCase
|
43
|
+
def setup
|
44
|
+
@seq_region = SeqRegion.find(92594)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_simple
|
48
|
+
assert_equal('AGCTATTTTATGACTT', @seq_region.seq.slice(4,16))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_subseq
|
52
|
+
assert_equal('AGCTATTTTATGACTT', @seq_region.subseq(5,20))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
#class SliceProjectFromComponentToAssembly < Test::Unit::TestCase
|
57
|
+
# # |------------------------------------------> chromosome
|
58
|
+
# # ^ ^
|
59
|
+
# # | |
|
60
|
+
# # |-----------------> scaffold
|
61
|
+
# def test_project_from_whole_component_to_assembly
|
62
|
+
# source_slice = Slice.fetch_by_region('contig','AAFC03055291')
|
63
|
+
# target_slices = source_slice.project('chromosome')
|
64
|
+
#
|
65
|
+
# # Start and stop of chr4_105 on Chr4
|
66
|
+
# assert_equal(13970982, target_slices[0].start)
|
67
|
+
# assert_equal(13982069, target_slices[0].stop)
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# # |------------------------------------------> chromosome
|
71
|
+
# # ^ ^
|
72
|
+
# # | |
|
73
|
+
# # |-----------------> scaffold
|
74
|
+
# def test_project_from_component_to_assembly_with_positions
|
75
|
+
# source_slice = Slice.fetch_by_region('scaffold','Chr4.003.105', 42, 2007)
|
76
|
+
# target_slices = source_slice.project('chromosome')
|
77
|
+
#
|
78
|
+
# # Position 42 on chr4_105 is position 96652152, position 2007 is 96654117
|
79
|
+
# assert_equal(96652152, target_slices[0].start)
|
80
|
+
# assert_equal(96654117, target_slices[0].stop)
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# # |------------------------------------------> scaffold
|
84
|
+
# # ^ ^
|
85
|
+
# # | |
|
86
|
+
# # ----------------> contig
|
87
|
+
# # /
|
88
|
+
# # |--
|
89
|
+
# def test_project_from_component_to_assembly_with_positions_and_cmp_start_not_1
|
90
|
+
# source_slice = Slice.fetch_by_region('contig', 'AAFC03020247', 42, 2007)
|
91
|
+
# target_slices = source_slice.project('scaffold')
|
92
|
+
#
|
93
|
+
# # Position 42 on AAFC03020247 is position 6570 on ChrUn.003.3522, position 2007 is 8565
|
94
|
+
# assert_equal(6570, target_slices[0].start)
|
95
|
+
# assert_equal(8535, target_slices[0].stop)
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# # |------------------------------------------> scaffold
|
99
|
+
# # ^ ^
|
100
|
+
# # | |
|
101
|
+
# # <-----------------| contig
|
102
|
+
# def test_project_from_component_to_assembly_with_strand
|
103
|
+
# source_slice_fw = Slice.fetch_by_region('contig', 'AAFC03020247')
|
104
|
+
# target_slices_fw = source_slice_fw.project('scaffold')
|
105
|
+
#
|
106
|
+
# assert_equal(1, target_slices_fw[0].strand)
|
107
|
+
#
|
108
|
+
# source_slice_rev = Slice.fetch_by_region('contig', 'AAFC03061502')
|
109
|
+
# target_slices_rev = source_slice_rev.project('scaffold')
|
110
|
+
#
|
111
|
+
# assert_equal(-1, target_slices_rev[0].strand)
|
112
|
+
# end
|
113
|
+
#end
|
114
|
+
|
115
|
+
#class SliceProjectFromComponentToAssemblyUsingTopLevel < Test::Unit::TestCase
|
116
|
+
# # |------------------------------------------> chromosome
|
117
|
+
# # ^ ^
|
118
|
+
# # | |
|
119
|
+
# # |-----------------> scaffold
|
120
|
+
# def test_project_from_whole_component_to_assembly
|
121
|
+
# source_slice = Slice.fetch_by_region('scaffold','Chr4.003.105')
|
122
|
+
# target_slices = source_slice.project('toplevel')
|
123
|
+
#
|
124
|
+
# # Start and stop of chr4_105 on Chr4
|
125
|
+
# assert_equal(96652111, target_slices[0].start)
|
126
|
+
# assert_equal(97251689, target_slices[0].stop)
|
127
|
+
# end
|
128
|
+
#
|
129
|
+
# # |------------------------------------------> chromosome
|
130
|
+
# # ^ ^
|
131
|
+
# # | |
|
132
|
+
# # |-----------------> scaffold
|
133
|
+
# def test_project_from_component_to_assembly_with_positions
|
134
|
+
# source_slice = Slice.fetch_by_region('scaffold','Chr4.003.105', 42, 2007)
|
135
|
+
# target_slices = source_slice.project('toplevel')
|
136
|
+
#
|
137
|
+
# # Position 42 on chr4_105 is position 96652152, position 2007 is 96654117
|
138
|
+
# assert_equal(96652152, target_slices[0].start)
|
139
|
+
# assert_equal(96654117, target_slices[0].stop)
|
140
|
+
# end
|
141
|
+
#end
|
142
|
+
|
143
|
+
class SliceProjectFromAssemblyToComponentForwardStrands < Test::Unit::TestCase
|
144
|
+
def setup
|
145
|
+
@source_slice_single_contig = Slice.fetch_by_region('chromosome', '20', 175000, 180000)
|
146
|
+
@target_slices_single_contig = @source_slice_single_contig.project('contig')
|
147
|
+
|
148
|
+
@source_slice_two_contigs = Slice.fetch_by_region('chromosome','20', 175000, 190000)
|
149
|
+
@target_slices_two_contigs = @source_slice_two_contigs.project('contig')
|
150
|
+
|
151
|
+
@source_slice_contigs_with_strand = Slice.fetch_by_region('chromosome', '20', 160000, 190000)
|
152
|
+
@target_slices_contigs_with_strand = @source_slice_contigs_with_strand.project('contig')
|
153
|
+
|
154
|
+
@source_slice_contigs_with_strand_ends_in_gaps = Slice.fetch_by_region('chromosome', '20', 170950, 196000)
|
155
|
+
@target_slices_contigs_with_strand_ends_in_gaps = @source_slice_contigs_with_strand_ends_in_gaps.project('contig')
|
156
|
+
end
|
157
|
+
|
158
|
+
# |-----------------> contig
|
159
|
+
# ^ ^
|
160
|
+
# | |
|
161
|
+
# |------------------------------------------> chromosome
|
162
|
+
def test_project_from_assembly_to_single_component
|
163
|
+
# Position 175000 on chr20 is position 4030 on contig, position 180000 is 9030
|
164
|
+
assert_equal('AAFC03028970', @target_slices_single_contig[0].seq_region.name)
|
165
|
+
assert_equal(4030, @target_slices_single_contig[0].start)
|
166
|
+
assert_equal(9030, @target_slices_single_contig[0].stop)
|
167
|
+
end
|
168
|
+
|
169
|
+
# |-----> |--------> contig
|
170
|
+
# ^ ^
|
171
|
+
# | |
|
172
|
+
# |------------------------------------------> chromosome
|
173
|
+
def test_project_from_assembly_to_two_components
|
174
|
+
# This chromosomal region is covered by contigs AAFC03028970, a gap and AAFC03028962
|
175
|
+
# * Position 175000 on chr 20 is position 4030 on contig AAFC03028970
|
176
|
+
# * Position 190000 on chr 20 is position 35 on contig AAFC03028962
|
177
|
+
assert_equal(3, @target_slices_two_contigs.length)
|
178
|
+
assert_equal('contig:Btau_4.0:AAFC03028970:4030:17365:1', @target_slices_two_contigs[0].display_name)
|
179
|
+
assert_equal(Gap, @target_slices_two_contigs[1].class)
|
180
|
+
assert_equal('contig:Btau_4.0:AAFC03028962:1:35:1', @target_slices_two_contigs[2].display_name)
|
181
|
+
end
|
182
|
+
|
183
|
+
# |-----> <-------| |-------> |-------> contig
|
184
|
+
# ^ ^
|
185
|
+
# | |
|
186
|
+
# |--------------------------------------------------> chromosome
|
187
|
+
def test_project_from_assembly_to_contigs_with_strand
|
188
|
+
# This chromosomal region is covered by 4 contigs and 3 gaps
|
189
|
+
# One of the contigs are on the reverse strand.
|
190
|
+
assert_equal(7, @target_slices_contigs_with_strand.length)
|
191
|
+
assert_equal('contig:Btau_4.0:AAFC03028964:90:9214:1', @target_slices_contigs_with_strand[0].display_name)
|
192
|
+
assert_equal(Gap, @target_slices_contigs_with_strand[1].class)
|
193
|
+
assert_equal('contig:Btau_4.0:AAFC03028959:1:1746:-1', @target_slices_contigs_with_strand[2].display_name)
|
194
|
+
assert_equal(Gap, @target_slices_contigs_with_strand[3].class)
|
195
|
+
assert_equal('contig:Btau_4.0:AAFC03028970:1:17365:1', @target_slices_contigs_with_strand[4].display_name)
|
196
|
+
assert_equal(Gap, @target_slices_contigs_with_strand[5].class)
|
197
|
+
assert_equal('contig:Btau_4.0:AAFC03028962:1:35:1', @target_slices_contigs_with_strand[6].display_name)
|
198
|
+
end
|
199
|
+
|
200
|
+
# <--| |-----> contig
|
201
|
+
# ^ ^
|
202
|
+
# | |
|
203
|
+
# |--------------------------------------------------> chromosome
|
204
|
+
def test_project_from_assembly_to_contigs_with_strand_and_ending_in_gaps
|
205
|
+
# This chromosomal region is covered by 2 contigs and 2 gaps at the end: GaCoGaCoGa
|
206
|
+
assert_equal(5, @target_slices_contigs_with_strand_ends_in_gaps.length)
|
207
|
+
assert_equal(Gap, @target_slices_contigs_with_strand_ends_in_gaps[0].class)
|
208
|
+
assert_equal('contig:Btau_4.0:AAFC03028970:1:17365:1', @target_slices_contigs_with_strand_ends_in_gaps[1].display_name)
|
209
|
+
assert_equal(Gap, @target_slices_contigs_with_strand_ends_in_gaps[2].class)
|
210
|
+
assert_equal('contig:Btau_4.0:AAFC03028962:1:5704:1', @target_slices_contigs_with_strand_ends_in_gaps[3].display_name)
|
211
|
+
assert_equal(Gap, @target_slices_contigs_with_strand_ends_in_gaps[4].class)
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_project.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 '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 'ensembl'
|
15
|
+
|
16
|
+
include Ensembl::Core
|
17
|
+
|
18
|
+
DBConnection.connect('homo_sapiens', 50)
|
19
|
+
|
20
|
+
class AssemblyExceptions < Test::Unit::TestCase
|
21
|
+
def test_chr_x
|
22
|
+
source_slice = Slice.fetch_by_region('chromosome','X', 2709497, 2709520)
|
23
|
+
assert_equal('tagttatagattaaaagaagttaa', source_slice.seq)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_slice_overlapping_PAR_and_allosome
|
27
|
+
source_slice = Slice.fetch_by_region('chromosome','Y',2709500,2709540)
|
28
|
+
target_slices = source_slice.project('contig')
|
29
|
+
assert_equal('contig::AC006209.25.1.141759:23323:23343:-1', target_slices[0].display_name)
|
30
|
+
assert_equal('contig::AC006040.3.1.186504:57272:57291:1', target_slices[1].display_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_seq_slice_overlapping_PAR
|
34
|
+
seq = ''
|
35
|
+
File.open('../../data/seq_y.fa').reject{|l| l=~/^>/}.each do |line|
|
36
|
+
line.chomp!
|
37
|
+
seq += line
|
38
|
+
end
|
39
|
+
seq.downcase!
|
40
|
+
|
41
|
+
source_slice = Slice.fetch_by_region('chromosome', 'Y', 2709497, 2709542)
|
42
|
+
assert_equal(seq.downcase, source_slice.seq)
|
43
|
+
end
|
44
|
+
|
45
|
+
# The MHC haplotypes for human are not implemented yet, so we raise an error
|
46
|
+
# in the code.
|
47
|
+
def test_seq_slice_overlapping_HAP
|
48
|
+
seq = ''
|
49
|
+
File.open('../../data/seq_c6qbl.fa').reject{|l| l=~/^>/}.each do |line|
|
50
|
+
line.chomp!
|
51
|
+
seq += line
|
52
|
+
end
|
53
|
+
seq.downcase!
|
54
|
+
|
55
|
+
source_slice = Slice.fetch_by_region('chromosome', 'c6_QBL', 33451191, 33451690)
|
56
|
+
assert_raise(NotImplementedError) {source_slice.seq}
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_transfers.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 '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
|
+
|
15
|
+
require 'ensembl'
|
16
|
+
|
17
|
+
include Ensembl::Core
|
18
|
+
|
19
|
+
DBConnection.connect('homo_sapiens', 50)
|
20
|
+
|
21
|
+
# Let's see if we can 'find' things
|
22
|
+
class SimpleRecordsTest < Test::Unit::TestCase
|
23
|
+
def setup
|
24
|
+
@sry_gene = Gene.find(34927)
|
25
|
+
@sry_transcript = Transcript.find(60290)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_coord_system
|
29
|
+
coord_system = CoordSystem.find(17)
|
30
|
+
assert_equal('chromosome', coord_system.name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_coord_system_toplevel
|
34
|
+
coord_system = CoordSystem.find_toplevel
|
35
|
+
assert_equal('chromosome', coord_system.name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_coord_system_seqlevel
|
39
|
+
coord_system = CoordSystem.find_seqlevel
|
40
|
+
assert_equal('contig', coord_system.name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_display_label
|
44
|
+
assert_equal('SRY', @sry_gene.display_label)
|
45
|
+
assert_equal('SRY', @sry_gene.display_name)
|
46
|
+
assert_equal('SRY', @sry_gene.label)
|
47
|
+
assert_equal('SRY', @sry_gene.name)
|
48
|
+
|
49
|
+
assert_equal('SRY-001', @sry_transcript.display_label)
|
50
|
+
assert_equal('SRY-001', @sry_transcript.display_name)
|
51
|
+
assert_equal('SRY-001', @sry_transcript.label)
|
52
|
+
assert_equal('SRY-001', @sry_transcript.name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class RelationshipsTest < Test::Unit::TestCase
|
57
|
+
def test_go_terms
|
58
|
+
gene = Gene.find(34928)
|
59
|
+
assert_equal(["GO:0005576", "GO:0042742"], gene.go_terms.sort)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_hgnc
|
63
|
+
gene = Gene.find_by_stable_id('ENSG00000169740')
|
64
|
+
assert_equal('ZNF32', gene.hgnc)
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#
|
2
|
+
# = test/unit/test_seq.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 '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 'yaml'
|
15
|
+
require 'ensembl'
|
16
|
+
|
17
|
+
include Ensembl::Core
|
18
|
+
|
19
|
+
DBConnection.connect('homo_sapiens', 50)
|
20
|
+
|
21
|
+
#class SequenceForSlice < Test::Unit::TestCase
|
22
|
+
# def test_forward_strand_seqlevel
|
23
|
+
# slice = Slice.new(SeqRegion.find(170931),5,15)
|
24
|
+
# seq = 'gcagtggtgtg'
|
25
|
+
# assert_equal(seq, slice.seq)
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# def test_reverse_strand_seqlevel
|
29
|
+
# slice = Slice.new(SeqRegion.find(170931),5,15, -1)
|
30
|
+
# seq = 'cacaccactgc'
|
31
|
+
# assert_equal(seq, slice.seq)
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# def test_forward_strand_not_seqlevel_single_target
|
35
|
+
# slice = Slice.new(SeqRegion.find(226044),69437100,69437110)
|
36
|
+
# seq = 'gtctatttaca'
|
37
|
+
# assert_equal(seq, slice.seq)
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# def test_reverse_strand_not_seqlevel_single_target
|
41
|
+
# slice = Slice.new(SeqRegion.find(226044),69437100,69437110,-1)
|
42
|
+
# seq = 'tgtaaatagac'
|
43
|
+
# assert_equal(seq, slice.seq)
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# def test_forward_strand_not_seqlevel_composite_target
|
47
|
+
# seq = ''
|
48
|
+
# File.open('../../data/seq_forward_composite.fa').reject{|l| l=~/^>/}.each do |line|
|
49
|
+
# line.chomp!
|
50
|
+
# seq += line
|
51
|
+
# end
|
52
|
+
# seq.downcase!
|
53
|
+
# slice = Slice.new(SeqRegion.find(226044),69387650,69487649)
|
54
|
+
# assert_equal(seq, slice.seq)
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# def test_reverse_strand_not_seqlevel_composite_target
|
58
|
+
# slice = Slice.new(SeqRegion.find(226044),69437061,69437160,-1)
|
59
|
+
# assert_equal('nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatgtaaatagacaactaacaagatagctgagattgtttccttatccagaca', slice.seq)
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
#end
|
63
|
+
#
|
64
|
+
#class SequenceForUnsplicedFeature < Test::Unit::TestCase
|
65
|
+
# def test_forward_strand_seqlevel
|
66
|
+
# marker_feature = MarkerFeature.find(1323757)
|
67
|
+
# marker_seq = 'ggcttacttggaaaggtctcttccaacccaatattattcaaatactttcaattttcttctaatgtttttagtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtggttttgttttatttcttttaattctctgatacatttagaatttcttttattattttattttattttattatttatttatttatttttgagacagagttttgctc'
|
68
|
+
# assert_equal(marker_seq, marker_feature.seq)
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# def test_reverse_strand_seqlevel
|
72
|
+
# gene = Gene.find_by_name('ANKRD56')
|
73
|
+
#
|
74
|
+
# ankrd56_seq = 'atggcccgagagctgagccaggaggcactactggactttctgtgccaggctgggggccgcgtgaccaacgctgccttgctgagccacttcaagagctttctccgagaccccgacgcgtcccccagccagcaccagcaccgccgcgagctcttcaagggcttcgtcaactcggtcgccgcagtgcgccaggaccccgacggcaccaagtacgtggtgctcaagaggagatacagggaccttttgggggaggaggggctgcagcgaccccgcgagccgcccgcggccgcccccagtgcagggggagctgcgccctgctccccgcgaggcgcgcgccggggggagccgccccagcagcagcccaggcggcggcggcgcgagaaggagccggaggaggagccagcaggtgcagcagccagagccgccgacgcagcttgcaatggactcccgggcagcgactcccgtagggcgcccgggaagggcggcggatcgaagggcagtcccggacagaggccgccggtgcccgcagctgcagcggcaggggcccaggcgagagcgagctgcgcggcggcgaagacgcagggccgctgctgctgggaatgcctccagaacaacctggctgtactgccgggagagctcggcgcactcccgcactcggccaccgcggaggagaagccggcacgggctctgcctgcccaggatgaccgcggggcttccagggagcgggaagaaggcgcgctagctgagccggcgcctgtgcctgcagtggctcactcgcctcccgccaccgtcgaggctgcgacaagcagggcttccccgcctgctctcctgcccggccccgctccccgcggagaccggccggagctgctgacccccagctccctgcattattcgaccctgcagcagcagcagcagcgcactcgagagtgggtggccaggcacccgcaggtgcccgaggcccgtgatcagggccctatccgcgcctggtcggtgctgccagacaacttcctccagctgcccttggaacccggctccacggagcctaattcagagccgccagacccctgtctttcctcgcactctctctttcctgttgttccggatgagtcctgggaatcctgggcggggaacccttcattgactgtctttcgcagcattcgttgtcagctgtccctccaagatctggatgactttgtggaccaggagagtgatggcagtgaggagagcagcagtgggcccaaagactccccgggggcttctgaagaggggctgcaggttgtcttgggaaccccagatagggggaagctcaggaatccagctgggggcctttctgtatctcggaaggagggcagccccagccggagccctcagggtctcagaaacagaggggatggtcacatctctcagcaggtccctgcaggggctaatggccttgcaggccaccccctgaagcctttgccttggccagttcctaagttaaggaggtccctcaggaggagctctctggcagggagagccaaattgtcctcctctgatgaggagtacctcgatgagggcttgctgaaaagaagtcggcgcccacctcgatccaggaagccctccaaggcaggaacggcacccagcccaagggttgatgcaggtttatcactaaaacttgcagaggttaaggctgttgtggccgagcggggttggcgacacagcctgtgggtccccagtggggaggggtctgcagccttggccccccacagaacttctgagcacaaatcatccctggttccactagatgccagggagcatgagtggattgtgaagcttgccagtggctcctggattcaggtgtggactttgttctgggaggaccctcaactggccttgcacaaagactttttgactgggtacactgcgttgcactggatagccaaacatggtgacctcagggcccttcaggacttggtgtctggagcaaagaaggcagggattgtccttgatgtaaacgtgaggtccagttgtggatataccccgctgcaccttgcagccattcacggccaccagggggtcatcaaattgctagtgcaaaggttggcttctcgggtaaatgtcagggacagcagtgggaagaagccatggcagtatctaaccagtaatacctctggggaaatatggcagctgttgggagctcctcggggcaagcccattttccctgtctatcccttagttggaagttcttcccctaccagaaaggccaagagcaaggaaatatctagaagtgtcacccgaaaaacttccttcgctgcactactcaaaagtcagcacaacaagtggaaactggccaaccagtatgagaaattccacagtccaagggaaagagaagagtatagtgactga'
|
75
|
+
# assert_equal(ankrd56_seq, gene.seq)
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# def test_reverse_strand_not_seqlevel
|
79
|
+
# gene = Gene.find_by_name('DRD3')
|
80
|
+
# drd3_gene_seq = ''
|
81
|
+
# File.open('../../data/seq_drd3_gene.fa').reject{|l| l=~/^>/}.each do |line|
|
82
|
+
# line.chomp!
|
83
|
+
# drd3_gene_seq += line
|
84
|
+
# end
|
85
|
+
# drd3_gene_seq.downcase!
|
86
|
+
# assert_equal(drd3_gene_seq, gene.seq)
|
87
|
+
#
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# def test_exon
|
91
|
+
# exon = Exon.find(719588)
|
92
|
+
# assert_equal('atggcatctctgagccagctgagtggccacctgaactacacctgtggggcagagaactccacaggtgccagccaggcccgcccacatgcctactatgccctctcctactgcgcgctcatcctggccatcgtcttcggcaatggcctggtgtgcatggctgtgctgaaggagcgggccctgcagactaccaccaactacttagtagtgagcctggctgtggcagacttgctggtggccaccttggtgatgccctgggtggtatacctggag', exon.seq)
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
#end
|
96
|
+
|
97
|
+
class SequenceForSlicedFeature < Test::Unit::TestCase
|
98
|
+
def test_transcript_foward
|
99
|
+
transcript = Transcript.find(73491) # UB2R1 = CDC34
|
100
|
+
ub2r1_transcript_seq = ''
|
101
|
+
File.open('../../data/seq_ub2r1_transcript.fa').reject{|l| l=~/^>/}.each do |line|
|
102
|
+
line.chomp!
|
103
|
+
ub2r1_transcript_seq += line
|
104
|
+
end
|
105
|
+
ub2r1_transcript_seq.downcase!
|
106
|
+
assert_equal(ub2r1_transcript_seq, transcript.seq)
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_transcript_reverse
|
111
|
+
transcript = Transcript.find(107548)
|
112
|
+
rnd3_transcript_seq = ''
|
113
|
+
File.open('../../data/seq_rnd3_transcript.fa').reject{|l| l=~/^>/}.each do |line|
|
114
|
+
line.chomp!
|
115
|
+
rnd3_transcript_seq += line
|
116
|
+
end
|
117
|
+
rnd3_transcript_seq.downcase!
|
118
|
+
assert_equal(rnd3_transcript_seq, transcript.seq)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
class SequenceForCDS < Test::Unit::TestCase
|
124
|
+
def setup
|
125
|
+
# Transcript tr_fw is ENST00000215574
|
126
|
+
@tr_fw = Transcript.find(73491)
|
127
|
+
# Transcript tr_rev is ENST00000315489
|
128
|
+
@tr_rev = Transcript.find(73411)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_cds_fw
|
132
|
+
ub2r1_coding_seq = ''
|
133
|
+
File.open('../../data/seq_ub2r1_coding.fa').reject{|l| l=~/^>/}.each do |line|
|
134
|
+
line.chomp!
|
135
|
+
ub2r1_coding_seq += line
|
136
|
+
end
|
137
|
+
ub2r1_coding_seq.downcase!
|
138
|
+
assert_equal(ub2r1_coding_seq, @tr_fw.cds_seq)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_cds_rev
|
142
|
+
cso19_coding_seq = ''
|
143
|
+
File.open('../../data/seq_cso19_coding.fa').reject{|l| l=~/^>/}.each do |line|
|
144
|
+
line.chomp!
|
145
|
+
cso19_coding_seq += line
|
146
|
+
end
|
147
|
+
cso19_coding_seq.downcase!
|
148
|
+
assert_equal(cso19_coding_seq, @tr_rev.cds_seq)
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_five_prime_utr_fw
|
152
|
+
assert_equal('GGCAAGCGCCGGTGGGGCGGCGGCGCCAGAGCTGCTGGAGCGCTCGGGGTCCCCGGGCGGCGGCGGCGGCGCAGAGGAGGAGGCAGGCGGCGGCCCCGGTGGCTCCCCCCCGGACGGTGCGCGGCCCGGCCCGTCTCGCGAACTCGCGGTGGTCGCGCGGCCCCGCGCTGCTCCGACCCCGGGCCCCTCCGCCGCCGCC'.downcase, @tr_fw.five_prime_utr_seq)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_five_primer_utr_rev
|
156
|
+
assert_equal('ACTCGATCCCGGCCCCACTTCCAGGCCAGTGTCCGGCCGACCAGCCTGCCTTGGGCCAGGGCCCCACGACTCCCTGCTGCGGGACAAGAGGCCGTCTGTGCGGCTGTGGTCGTGGGAGGGTGTGGTGAGGCCGTGAAGGTGGGGACGGTGCCTGGGCCTGTGGCCGCCAGAGCTGCTGCGGCTCAGAAGGTAGCACCAGGCCCCGTGGGTGCTGTGGGGGCCATCGCCTGCCCACC'.downcase, @tr_rev.five_prime_utr_seq)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_three_prime_utr_fw
|
160
|
+
assert_equal('CACCACCAGAATAAACTTGCCGAGTTTACCTCACTAGGGCCGGACCCGTGGCTCCTTAGACGACAGACTACCTCACGGAGGTTTTGTGCTGGTCCCCGTCTCCTCTGGTTGTTTCGTTTTGGCTTTTTCTCCCTCCCCATGTCTGTTCTGGGTTTTCACGTGCTTCAGAGAAGAGGGGCTGCCCCACCGCCACTCACGTCACTCGGGGCTCGGTGGACGGGCCCAGGGTGGGAGCGGCCGGCCCACCTGTCCCCTCGGGAGGGGAGCTGAGCCCGACTTCTACCGGGGTCCCCCAGCTTCCGGACTGGCCGCACCCCGGAGGAGCCACGGGGGCGCTGCTGGGAACGTGGGCGGGGGGCCGTTTCCTGACACTACCAGCCTGGGAGGCCCAGGTGTAGCGGTCCGAGGGGCCCGGTCCTGCCTGTCAGCTCCAGGTCCTGGAGCCACGTCCAGCACAGAGTGGACGGATTCACCGTGGCCGACTCTTTTCCCTGCTTTGGTTTGTTTGAAATCTAAATAAAACTACTTTATG'.downcase, @tr_fw.three_prime_utr_seq)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_three_prime_utr_rev
|
164
|
+
assert_equal('GCCAGGCCTGTTTCCCACACAGTGAACGGGGGGCTGGCGGGCCTCTCCTGGGGCCTGGCTTTGGCTGGAGGGGCTAGAAGGCGAGAGGGGCTGGGAAAGGAGTCTTCCCTCCCCTTTCCTGAACTGTCCAGGTCCTTCTAGGACACCTGATCCTTCCAGTCCCTGGGGGCTGTGACCCATGGCCCTGTGCAGGGTGCAGGGTGAGTCTCCTTCCAGTGCCCCAGTTTCTTCCAGGTCACGCCAGGCCAGGCCAGGCCAGGTGGGGAAAGGGACACCTTCCGGCCCTCCCCAGTAGCTGGCTGGAGATGGAGCTTCCTGTGTCCCAGAACTCGGCGTCCAGCTCCACTAGGGCCTGGATCCCCATCACAGCTTGGGTTAGCCCCGGTCCCAGCCCAAACTCAGGCTGGAGGCAGCCCCGAGGCCTGTGCCTTTCCCACTCCACCTTCTACAGTTGCTTAGCCAATAAACCTTTCCTGGGCTGGAG'.downcase, @tr_rev.three_prime_utr_seq)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_protein_fw
|
168
|
+
assert_equal('MARPLVPSSQKALLLELKGLQEEPVEGFRVTLVDEGDLYNWEVAIFGPPNTYYEGGYFKARLKFPIDYPYSPPAFRFLTKMWHPNIYETGDVCISILHPPVDDPQSGELPSERWNPTQNVRTILLSVISLLNEPNTFSPANVDASVMYRKWKESKGKDREYTDIIRKQVLGTKVDAERDGVKVPTTLAEYCVKTKAPAPDEGSDLFYDDYYEDGEVEEEADSCFGDDEDDSGTEES*', @tr_fw.protein_seq)
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_protein_rev
|
172
|
+
assert_equal('MGTLSCDSTPRLATAPLGRRVTEGQIPETGLRKSCGTATLENGSGPGLYVLPSTVGFINHDCTRVASPAYSLVRRPSEAPPQDTSPGPIYFLDPKVTRFGRSCTPAYSMQGRAKSRGPEVTPGPGAYSPEKVPPVRHRTPPAFTLGCRLPLKPLDTSAPAPNAYTMPPLWGSQIFTKPSSPSYTVVGRTPPARPPQDPAEIPGPGQYDSPDANTYRQRLPAFTMLGRPRAPRPLEETPGPGAHCPEQVTVNKARAPAFSMGIRHSKRASTMAATTPSRPAGHRLPGRCC*', @tr_rev.protein_seq)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|