bio-ensembl-rest 0.1.0

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.
@@ -0,0 +1,159 @@
1
+ require_relative 'helper'
2
+
3
+ class TestComparativeGenomics < Test::Unit::TestCase
4
+
5
+ context 'genetree_id' do
6
+
7
+ setup do
8
+ EnsemblRest.connect_db
9
+ end
10
+
11
+ should 'support a basic call and return the correct data' do
12
+ tree = ComparativeGenomics.genetree_id 'ENSGT00390000003602'
13
+ assert tree.index('Euteleostomi') && tree.index('Sarcopterygii')
14
+ end
15
+
16
+ should 'work with nh response type' do
17
+ tree1 = ComparativeGenomics.genetree_id 'ENSGT00390000003602',
18
+ response: 'nh',
19
+ nh_format: 'species_short_name'
20
+ tree2 = ComparativeGenomics.genetree_id 'ENSGT00390000003602',
21
+ response: 'nh',
22
+ nh_format: 'species'
23
+ assert tree1.size < tree2.size
24
+ assert tree1.index 'Xmac'
25
+ assert tree2.index 'xiphophorus_maculatus'
26
+ end
27
+
28
+ should 'return a Bio::PhyloXML object' do
29
+ tree = ComparativeGenomics.genetree_id 'ENSGT00390000003602',
30
+ response: 'ruby'
31
+ assert_instance_of Bio::PhyloXML::Parser, tree
32
+ end
33
+
34
+ sleep(1)
35
+
36
+ end
37
+
38
+
39
+ context 'genetree_member_id' do
40
+
41
+ setup do
42
+ EnsemblRest.connect_db
43
+ end
44
+
45
+ should 'support a basic call and return the correct data' do
46
+ tree = ComparativeGenomics.genetree_member_id 'ENSG00000157764'
47
+ assert tree.index('Petromyzon marinus')
48
+ end
49
+
50
+ should 'return a Bio::PhyloXML object' do
51
+ tree = ComparativeGenomics.genetree_member_id'ENSG00000157764',
52
+ response: 'ruby'
53
+ assert_instance_of Bio::PhyloXML::Parser, tree
54
+ end
55
+
56
+ sleep(1)
57
+
58
+ end
59
+
60
+
61
+ context 'genetree_member_symbol' do
62
+
63
+ setup do
64
+ EnsemblRest.connect_db
65
+ end
66
+
67
+ should 'support a basic call and return the correct data' do
68
+ tree = ComparativeGenomics.genetree_member_symbol 'homo_sapiens', 'BRCA2'
69
+ assert tree.index('BRCA2')
70
+ end
71
+
72
+ sleep(1)
73
+
74
+ end
75
+
76
+
77
+ context 'homology_id' do
78
+
79
+ setup do
80
+ EnsemblRest.connect_db
81
+ require 'rexml/document'
82
+ end
83
+
84
+ should 'support a basic call and return the correct data' do
85
+ hom = ComparativeGenomics.homology_id 'ENSG00000157764'
86
+ assert hom.index 'Bilateria'
87
+ assert hom.index 'ENSG00000157764'
88
+ assert hom.index 'ENSG00000173327'
89
+ end
90
+
91
+ should 'return a json object' do
92
+ hom = ComparativeGenomics.homology_id 'ENSG00000157764',
93
+ response: 'json'
94
+ assert_nothing_raised { JSON.parse hom }
95
+ end
96
+
97
+ should 'return a xml object' do
98
+ hom = ComparativeGenomics.homology_id 'ENSG00000157764',
99
+ response: 'xml'
100
+ assert_nothing_raised { REXML::Document.new hom }
101
+ end
102
+
103
+ should 'support the sequence parameter' do
104
+ hom = ComparativeGenomics.homology_id 'ENSG00000157764', sequence: 'none'
105
+ hom2 = ComparativeGenomics.homology_id 'ENSG00000157764', sequence: 'protein'
106
+ assert hom.size < hom2.size
107
+ end
108
+
109
+ sleep(1)
110
+
111
+ should 'return a list of Homology objects' do
112
+ homs = ComparativeGenomics.homology_id 'ENSG00000157764',
113
+ response: 'ruby'
114
+ homs.each { |hom| assert_instance_of Homology, hom }
115
+ homs.each do |hom|
116
+ hom.bio_methods.each {|met| assert hom.respond_to? met}
117
+ end
118
+ end
119
+
120
+ should 'support the aligned parameter' do
121
+ al = ComparativeGenomics.homology_id 'ENSG00000157764'
122
+ nal = ComparativeGenomics.homology_id 'ENSG00000157764', aligned: false
123
+ assert al.size > nal.size
124
+ end
125
+
126
+ sleep(1)
127
+
128
+ end
129
+
130
+
131
+ context 'homology_symbol' do
132
+
133
+ setup do
134
+ EnsemblRest.connect_db
135
+ require 'rexml/document'
136
+ end
137
+
138
+ should 'support a basic call and return the correct data' do
139
+ hom = ComparativeGenomics.homology_symbol 'human', 'BRCA2'
140
+ assert hom.index 'Homininae'
141
+ assert hom.index 'ENSG00000139618'
142
+ end
143
+
144
+
145
+ should 'return a list of Homology objects' do
146
+ homs = ComparativeGenomics.homology_symbol 'human', 'BRCA2',
147
+ response: 'ruby'
148
+ homs.each { |hom| assert_instance_of Homology, hom }
149
+ homs.each do |hom|
150
+ hom.bio_methods.each {|met| assert hom.respond_to? met}
151
+ end
152
+ end
153
+
154
+ sleep(1)
155
+
156
+ end
157
+
158
+
159
+ end
@@ -0,0 +1,81 @@
1
+ require_relative 'helper'
2
+
3
+ class TestCrossReference < Test::Unit::TestCase
4
+
5
+ context 'xrefs_id' do
6
+
7
+ setup do
8
+ EnsemblRest.connect_db
9
+ end
10
+
11
+ should 'support a basic call and return the correct data' do
12
+ ref = CrossReference.xrefs_id 'ENSG00000157764'
13
+ assert ref.index 'BRAF1'
14
+ end
15
+
16
+ should 'return a json object' do
17
+ ref = CrossReference.xrefs_id 'ENSG00000157764'
18
+ assert_nothing_raised { JSON.parse ref }
19
+ end
20
+
21
+ should 'return a ruby array' do
22
+ refs = CrossReference.xrefs_id 'ENSG00000157764', response: 'ruby'
23
+ assert_instance_of Array, refs
24
+ end
25
+
26
+ sleep(1)
27
+
28
+ end
29
+
30
+
31
+ context 'xrefs_name' do
32
+
33
+ setup do
34
+ EnsemblRest.connect_db
35
+ end
36
+
37
+ should 'support a basic call and return the correct data' do
38
+ ref = CrossReference.xrefs_name 'Homo sapiens', 'BRCA2'
39
+ assert ref.index 'BRCA2'
40
+ assert ref.index 'BRCC2'
41
+ assert ref.index 'BROVCA2'
42
+ end
43
+
44
+ should 'return a JSON object' do
45
+ refs = CrossReference.xrefs_name 'human', 'BRCA2', response: 'json'
46
+ assert_nothing_raised { JSON.parse refs }
47
+ end
48
+
49
+ should 'return a ruby array' do
50
+ refs = CrossReference.xrefs_name 'human', 'BRCA2', response: 'ruby'
51
+ assert_instance_of Array, refs
52
+ end
53
+
54
+ sleep(1)
55
+
56
+ end
57
+
58
+
59
+ context 'xrefs_symbol' do
60
+
61
+ setup do
62
+ EnsemblRest.connect_db
63
+ require 'rexml/document'
64
+ end
65
+
66
+ should 'support a basic call and return the correct data' do
67
+ ref = CrossReference.xrefs_symbol 'homo_sapiens', 'BRCA2'
68
+ assert ref.index 'ENSG00000139618'
69
+ assert ref.index 'ENST00000544455'
70
+ end
71
+
72
+ should 'return xml object' do
73
+ refs = CrossReference.xrefs_symbol 'homo_sapiens', 'BRCA2', response: 'xml'
74
+ assert_nothing_raised { REXML::Document.new refs }
75
+ end
76
+
77
+ sleep(1)
78
+
79
+ end
80
+
81
+ end
@@ -0,0 +1,76 @@
1
+ require_relative 'helper'
2
+
3
+ class TestFeatures < Test::Unit::TestCase
4
+
5
+ context 'feature_id' do
6
+
7
+ setup do
8
+ EnsemblRest.connect_db
9
+ end
10
+
11
+ should 'support a basic call and return the correct data' do
12
+ fts = Features.feature_id 'ENSG00000157764', %w(gene)
13
+ assert fts.index 'ENSG00000157764' # gene ID
14
+ assert fts.index '140424943' # gene starts here
15
+ assert fts.index '140624564' # gene end here
16
+ end
17
+
18
+
19
+ should 'support multiple features' do
20
+ assert_nothing_raised do
21
+ Features.feature_id 'ENSG00000157764', %w(gene transcript exon),
22
+ response: 'json'
23
+ end
24
+ end
25
+
26
+ should 'raise error if no feature is given' do
27
+ assert_raises RuntimeError do
28
+ Features.feature_id 'ENSG00000157764', response: 'json'
29
+ end
30
+ end
31
+
32
+ should 'return a ruby object' do
33
+ fts = Features.feature_id 'ENSG00000157764', %w(gene), response: 'ruby'
34
+ assert_instance_of Array, fts
35
+ end
36
+
37
+ sleep(1)
38
+
39
+ end
40
+
41
+
42
+ context 'feature_region' do
43
+
44
+ setup do
45
+ EnsemblRest.connect_db
46
+ end
47
+
48
+ should 'support a basic call and return the correct data' do
49
+ fts = Features.feature_region 'human', '7:140424943-140624564', %w(gene)
50
+ assert_nothing_raised { JSON.parse fts }
51
+ assert fts.index 'ENSG00000157764' # gene ID
52
+ assert fts.index 'BRAF' # gene name
53
+ assert fts.index '140424943' # gene starts here
54
+ assert fts.index '140624564' # gene end here
55
+ end
56
+
57
+ should 'support multiple features' do
58
+ assert_nothing_raised do
59
+ Features.feature_region 'human', '7:140424943-140624564',
60
+ %w(variation constrained regulatory),
61
+ response: 'json'
62
+ end
63
+ end
64
+
65
+ should 'raise error if no feature is given' do
66
+ assert_raises RuntimeError do
67
+ Features.feature_region 'human', '7:140424943-140624564', response: 'xml'
68
+ end
69
+ end
70
+
71
+ sleep(1)
72
+
73
+ end
74
+
75
+
76
+ end
@@ -0,0 +1,131 @@
1
+ require_relative 'helper'
2
+
3
+ class TestInformation < Test::Unit::TestCase
4
+
5
+ context 'assembly_info' do
6
+
7
+ setup do
8
+ EnsemblRest.connect_db
9
+ end
10
+
11
+ should 'support a basic call and return the correct data' do
12
+ info = Information.assembly_info 'homo_sapiens'
13
+ assert info =~ /GRCh\d{2}/ # check for GRC assembly code
14
+ assert info.index 'X' # check for X chromosome
15
+ assert info.index 'Y' # check for Y chromosome
16
+ end
17
+
18
+ sleep(1)
19
+
20
+ end
21
+
22
+
23
+ context 'assembly_info_region' do
24
+
25
+ setup do
26
+ EnsemblRest.connect_db
27
+ end
28
+
29
+ should 'support a basic call and return the correct data' do
30
+ info = Information.assembly_info_region 'homo_sapiens', 'X'
31
+ assert info.index '155270560' # the length of the X chromosome
32
+ assert info.index 'chromosome' # coordinate_system should be this
33
+ end
34
+
35
+ end
36
+
37
+
38
+ context 'info_comparas' do
39
+
40
+ setup do
41
+ EnsemblRest.connect_db
42
+ end
43
+
44
+ should 'support a basic call and return the correct data' do
45
+ info = Information.info_comparas
46
+ assert info.index 'comparas'
47
+ assert info.index 'name' # we expect at least name and release
48
+ assert info.index 'release' # number of the databases
49
+ end
50
+
51
+ end
52
+
53
+
54
+ context 'info_data' do
55
+
56
+ setup do
57
+ EnsemblRest.connect_db
58
+ end
59
+
60
+ should 'support a basic call and return the correct data' do
61
+ info = Information.info_data
62
+ assert info.index 'releases' # we expect a release number
63
+ end
64
+
65
+ sleep(1)
66
+
67
+ end
68
+
69
+
70
+ context 'info_ping' do
71
+
72
+ setup do
73
+ EnsemblRest.connect_db
74
+ end
75
+
76
+ should 'support a basic call and return the correct data' do
77
+ info = Information.info_ping
78
+ assert info.index 'ping'
79
+ assert info.index '1' # so we know the server is alive
80
+ end
81
+
82
+ end
83
+
84
+
85
+ context 'info_rest' do
86
+
87
+ setup do
88
+ EnsemblRest.connect_db
89
+ end
90
+
91
+ should 'support a basic call and return the correct data' do
92
+ info = Information.info_rest
93
+ assert info.index 'release' # we expect a release number
94
+ end
95
+
96
+ end
97
+
98
+
99
+ context 'info_software' do
100
+
101
+ setup do
102
+ EnsemblRest.connect_db
103
+ end
104
+
105
+ should 'support a basic call and return the correct data' do
106
+ info = Information.info_software
107
+ assert info.index 'release' # we expect a release number
108
+ end
109
+
110
+ sleep(1)
111
+
112
+ end
113
+
114
+
115
+ context 'info_species' do
116
+
117
+ setup do
118
+ EnsemblRest.connect_db
119
+ end
120
+
121
+ should 'support a basic call and return the correct data' do
122
+ info = Information.info_species division: 'ensembl'
123
+ assert info.index 'saccharomyces_cerevisiae' # yeast! everyone has that
124
+ assert info.index 'vicugna pacos' # ALPACA! everyone loves them
125
+ end
126
+
127
+ end
128
+
129
+
130
+
131
+ end