bio-ensembl-rest 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +20 -0
- data/README.md +51 -0
- data/Rakefile +45 -0
- data/lib/bio-ensembl-rest.rb +19 -0
- data/lib/bio-ensembl-rest/comparative-genomics.rb +117 -0
- data/lib/bio-ensembl-rest/cross-reference.rb +55 -0
- data/lib/bio-ensembl-rest/ensembl-rest-main.rb +108 -0
- data/lib/bio-ensembl-rest/features.rb +46 -0
- data/lib/bio-ensembl-rest/information.rb +133 -0
- data/lib/bio-ensembl-rest/lookup.rb +20 -0
- data/lib/bio-ensembl-rest/mapping.rb +55 -0
- data/lib/bio-ensembl-rest/ontologies.rb +68 -0
- data/lib/bio-ensembl-rest/sequence.rb +37 -0
- data/lib/bio-ensembl-rest/taxonomy.rb +30 -0
- data/lib/bio-ensembl-rest/variation.rb +37 -0
- data/test/helper.rb +20 -0
- data/test/test-comparative-genomics.rb +159 -0
- data/test/test-cross-reference.rb +81 -0
- data/test/test-features.rb +76 -0
- data/test/test-information.rb +131 -0
- data/test/test-lookup.rb +45 -0
- data/test/test-mapping.rb +105 -0
- data/test/test-ontologies.rb +116 -0
- data/test/test-sequence.rb +110 -0
- data/test/test-taxonomy.rb +58 -0
- data/test/test-variation.rb +62 -0
- metadata +157 -0
data/test/test-lookup.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestLookup < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'lookup_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
|
+
look = Lookup.lookup_id 'ENSG00000157764'
|
13
|
+
assert look.index 'Gene' # we asked for a gene
|
14
|
+
assert look.index 'core' # db_type should be this
|
15
|
+
assert look.index 'homo_sapiens' # we used a human stable ID
|
16
|
+
assert look.index 'ENSG00000157764' # exactly this one
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'support the full parameter' do
|
20
|
+
look_plain = Lookup.lookup_id 'ENSG00000157764'
|
21
|
+
look_full = Lookup.lookup_id 'ENSG00000157764', format: 'full'
|
22
|
+
assert look_full.size > look_plain.size
|
23
|
+
end
|
24
|
+
|
25
|
+
sleep(1)
|
26
|
+
|
27
|
+
should 'return the right object' do
|
28
|
+
look = JSON.parse Lookup.lookup_id 'ENSG00000157764', format: 'full'
|
29
|
+
assert look['object_type'].casecmp 'gene'
|
30
|
+
assert look['species'].casecmp 'homo_sapiens'
|
31
|
+
assert look['start'] = 140424943
|
32
|
+
assert look['end'] = 140624564
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'support db_type parameter' do
|
36
|
+
look = JSON.parse Lookup.lookup_id 'ENSG00000157764', db_type: 'core'
|
37
|
+
assert look['db_type'] = 'core'
|
38
|
+
end
|
39
|
+
|
40
|
+
sleep(1)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestMapping < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'test map' 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
|
+
map = Mapping.map 'NCBI36', 'GRCh37', 'human', 'X:1000000..1000100:1'
|
13
|
+
assert map.index 'NCBI36' # we asked a map from this
|
14
|
+
assert map.index 'GRCh37' # to this
|
15
|
+
assert map.index 'X' # of a sequence on the X chromosome
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'return work with response: ruby' do
|
19
|
+
map = Mapping.map 'NCBI36', 'GRCh37', 'human', 'X:1000000..1000100:1',
|
20
|
+
response: 'ruby'
|
21
|
+
from = map['mappings'][0]['original'] # from here
|
22
|
+
to = map['mappings'][0]['mapped'] # to here
|
23
|
+
|
24
|
+
assert from['assembly'] = 'NCBI36' # from has to be NCBI36
|
25
|
+
assert from['start'] = 1000000 # its region start here
|
26
|
+
assert from['end'] = 1000100 # and ends here
|
27
|
+
assert to['assembly'] = 'GRCh37' # to has to be GRCh37
|
28
|
+
assert to['start'] = 1080000 # its region starts here
|
29
|
+
assert to['end'] = 1080100 # and ends here
|
30
|
+
end
|
31
|
+
|
32
|
+
sleep(1)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
context 'test map_from_cdna' do
|
38
|
+
|
39
|
+
setup do
|
40
|
+
EnsemblRest.connect_db
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'support a basic call and return the correct data' do
|
44
|
+
map = Mapping.map_from_cdna 'ENST00000288602', '100..300'
|
45
|
+
assert map.index 'chromosome' # we asked a map on chromosome
|
46
|
+
assert map.index '7' # chromosome 7, in fact
|
47
|
+
assert map.index '-1' # strand -1
|
48
|
+
end
|
49
|
+
|
50
|
+
should 'return the right mapping' do
|
51
|
+
map = Mapping.map_from_cdna 'ENST00000288602', '100..300',
|
52
|
+
response: 'ruby'
|
53
|
+
from = map['mappings'][0]
|
54
|
+
to = map['mappings'][1]
|
55
|
+
from['seq_region_name'] = '7'
|
56
|
+
from['start'] = 140624366
|
57
|
+
to['end'] = 140624465
|
58
|
+
from['seq_region_name'] = '7'
|
59
|
+
from['start'] = 140549912
|
60
|
+
to['end'] = 140550012
|
61
|
+
end
|
62
|
+
|
63
|
+
sleep(1)
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'test map_from_cds' do
|
68
|
+
|
69
|
+
setup do
|
70
|
+
EnsemblRest.connect_db
|
71
|
+
end
|
72
|
+
|
73
|
+
should 'support a basic call and return the correct data' do
|
74
|
+
map = Mapping.map_from_cds 'ENST00000288602', '1..1000'
|
75
|
+
assert map.index '7' # we asked for stuff on chromosome 7
|
76
|
+
assert map.index '-1' # strand -1
|
77
|
+
assert map.index '140624366' # one of the mapping starts here
|
78
|
+
assert map.index '140624503' # and ends here
|
79
|
+
end
|
80
|
+
|
81
|
+
sleep(1)
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
context 'test map_from_translation' do
|
87
|
+
|
88
|
+
setup do
|
89
|
+
EnsemblRest.connect_db
|
90
|
+
end
|
91
|
+
|
92
|
+
should 'support a basic call and return the correct data' do
|
93
|
+
map = Mapping.map_from_translation 'ENSP00000288602', '100..300'
|
94
|
+
assert map.index '7' # we asked for stuff on chromosome 7
|
95
|
+
assert map.index '-1' # strand -1
|
96
|
+
assert map.index '140534409' # one of the mapping starts here
|
97
|
+
assert map.index '140534615' # and ends here
|
98
|
+
end
|
99
|
+
|
100
|
+
sleep(1)
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestOntologies < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'test ontology_ancestor' 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
|
+
ont = Ontologies.ontology_ancestor 'GO:0005667'
|
13
|
+
assert ont.index 'GO:0000120' # GO:000566 should have this ancestor
|
14
|
+
assert ont.index 'GO:0000126' # and this
|
15
|
+
assert ont.index 'GO:0000127' # and this
|
16
|
+
assert ont.index 'GO:0097221' # and this one, too
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'work both with GO and EFO IDs' do
|
20
|
+
assert_nothing_raised do
|
21
|
+
Ontologies.ontology_ancestor 'GO:0005667'
|
22
|
+
Ontologies.ontology_ancestor 'EFO:0000493'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
sleep(1)
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
context 'test ontology_ancestor_chart' 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
|
+
ont = Ontologies.ontology_ancestor_chart 'GO:0005667'
|
39
|
+
assert ont.index 'GO:0005575' # GO:0005667 should have this ancestor
|
40
|
+
assert ont.index 'GO:0005622' # and this
|
41
|
+
assert ont.index 'GO:0005623' # and this
|
42
|
+
assert ont.index 'GO:0005654' # and this one, too
|
43
|
+
end
|
44
|
+
|
45
|
+
sleep(1)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
context 'test ontology_descendants' do
|
51
|
+
|
52
|
+
setup do
|
53
|
+
EnsemblRest.connect_db
|
54
|
+
end
|
55
|
+
|
56
|
+
should 'support a basic call and return the correct data' do
|
57
|
+
ont = Ontologies.ontology_descendents 'GO:0005667'
|
58
|
+
assert ont.index 'GO:0043234' # GO:0005667 should have this descendent
|
59
|
+
assert ont.index 'GO:0044451' # and this
|
60
|
+
assert ont.index 'GO:0005654' # and this
|
61
|
+
assert ont.index 'GO:0043231' # and this one, too
|
62
|
+
end
|
63
|
+
|
64
|
+
should 'support the subset parameter' do
|
65
|
+
ont1 = Ontologies.ontology_descendents 'GO:0005667', subset: 'goslim_generic'
|
66
|
+
ont2 = Ontologies.ontology_descendents 'GO:0005667'
|
67
|
+
assert ont1.size < ont2.size
|
68
|
+
end
|
69
|
+
|
70
|
+
sleep(1)
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
context 'test ontology_id' do
|
76
|
+
|
77
|
+
setup do
|
78
|
+
EnsemblRest.connect_db
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'support a basic call and return the correct data' do
|
82
|
+
ont = Ontologies.ontology_id 'GO:0005667'
|
83
|
+
assert ont.index 'transcription factor complex' # what GO:0005667 is
|
84
|
+
assert ont.index 'GO:0000120' # a son of him
|
85
|
+
assert ont.index 'GO:0044451' # his parent
|
86
|
+
end
|
87
|
+
|
88
|
+
should 'return a ruby object' do
|
89
|
+
ont = Ontologies.ontology_id 'GO:0005667', response: 'ruby'
|
90
|
+
assert_instance_of Hash, ont
|
91
|
+
end
|
92
|
+
|
93
|
+
sleep(1)
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
context 'test ontology_name' do
|
99
|
+
|
100
|
+
setup do
|
101
|
+
EnsemblRest.connect_db
|
102
|
+
end
|
103
|
+
|
104
|
+
should 'support a basic call and return the correct data' do
|
105
|
+
ont = Ontologies.ontology_name 'transcription factor complex'
|
106
|
+
assert ont.index 'GO:0005667' # ID of transcription factor complex
|
107
|
+
assert ont.index 'GO:0000120' # a son of him
|
108
|
+
assert ont.index 'GO:0044451' # his parent
|
109
|
+
end
|
110
|
+
|
111
|
+
sleep(1)
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestSequence < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'sequence_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
|
+
seq = Sequence.sequence_id 'ENSG00000236597'
|
13
|
+
seq2 = Sequence.sequence_id 'ENSG00000228131'
|
14
|
+
assert_equal seq, 'CTAACTGGGGA'
|
15
|
+
assert_equal seq2.size, 18
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'expand the sequence 10 pairs upstream' do
|
19
|
+
seq1 = Sequence.sequence_id 'ENSE00001154485',
|
20
|
+
response: 'text',
|
21
|
+
type: 'genomic'
|
22
|
+
seq2 = Sequence.sequence_id 'ENSE00001154485',
|
23
|
+
response: 'text',
|
24
|
+
type: 'genomic',
|
25
|
+
expand_5prime: 10
|
26
|
+
assert_equal 10 + seq1.size, seq2.size
|
27
|
+
assert_equal seq1, seq2[10..-1]
|
28
|
+
end
|
29
|
+
|
30
|
+
sleep(1)
|
31
|
+
|
32
|
+
should 'return a Bio::Sequence object' do
|
33
|
+
seq = Sequence.sequence_id 'ENSVPAG00000001567',
|
34
|
+
response: 'ruby'
|
35
|
+
assert_instance_of Bio::Sequence, seq
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'raise an error: ID not found' do
|
39
|
+
assert_raises RuntimeError do
|
40
|
+
Sequence.sequence_id 'CCDS5863.1',
|
41
|
+
response: 'fasta',
|
42
|
+
object_type: 'transcript',
|
43
|
+
db_type: 'otherfeatures',
|
44
|
+
type: 'cds',
|
45
|
+
species: 'human'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
should 'return multiple sequences' do
|
50
|
+
response = Sequence.sequence_id 'ENSG00000157764',
|
51
|
+
response: 'fasta',
|
52
|
+
multiple_sequences: true,
|
53
|
+
type: 'protein'
|
54
|
+
assert response.scan(/>\w{15,18}\n/).size > 1
|
55
|
+
end
|
56
|
+
|
57
|
+
sleep(1)
|
58
|
+
|
59
|
+
should 'return masked sequences' do
|
60
|
+
seq1 = Sequence.sequence_id 'ENST00000288602',
|
61
|
+
mask: 'hard'
|
62
|
+
seq2 = Sequence.sequence_id 'ENST00000288602',
|
63
|
+
mask: 'soft'
|
64
|
+
assert_equal 'N'*10, seq1[0..9]
|
65
|
+
assert_equal seq2[0..9].downcase, seq2[0..9]
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
context 'sequence_region' do
|
72
|
+
|
73
|
+
setup do
|
74
|
+
EnsemblRest.connect_db
|
75
|
+
end
|
76
|
+
|
77
|
+
should 'support a basic call and return the correct data' do
|
78
|
+
seq = Sequence.sequence_region 'human', 'X:1000000..1000100:1'
|
79
|
+
assert_equal 'GAAACAGCTACTTGG', seq[0..14]
|
80
|
+
assert_equal seq.size, 101
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'expand the sequence upstream and downstream' do
|
84
|
+
seq = Sequence.sequence_region 'human',
|
85
|
+
'X:1000000..1000100:1',
|
86
|
+
expand_3prime: 50,
|
87
|
+
expand_5prime: 50
|
88
|
+
assert_equal 201, seq.size
|
89
|
+
end
|
90
|
+
|
91
|
+
sleep(1)
|
92
|
+
|
93
|
+
should 'support json response' do
|
94
|
+
seq = Sequence.sequence_region 'human',
|
95
|
+
'X:1000000..1000100:1',
|
96
|
+
response: 'json'
|
97
|
+
assert_nothing_raised { JSON.parse seq }
|
98
|
+
end
|
99
|
+
|
100
|
+
should 'return a Bio::Sequence object' do
|
101
|
+
seq = Sequence.sequence_region 'human',
|
102
|
+
'X:1000000..1000100:1',
|
103
|
+
response: 'ruby'
|
104
|
+
assert_instance_of Bio::Sequence, seq
|
105
|
+
assert_equal 101, seq.to_s.size
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestTaxonomy < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'test taxonomy_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
|
+
tax = Taxonomy.taxonomy_id '9606'
|
13
|
+
assert tax.index 'Homo sapiens' # the species with ID 9606
|
14
|
+
assert tax.index 'Neandertal' # one if his sons
|
15
|
+
assert tax.index '63221' # neandertal has this ID
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'work both with name and NBCI taxon id' do
|
19
|
+
assert_nothing_raised do
|
20
|
+
Taxonomy.taxonomy_id 'Homo sapiens'
|
21
|
+
Taxonomy.taxonomy_id '9606'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
sleep(1)
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
context 'test taxonomy_classification' do
|
31
|
+
|
32
|
+
setup do
|
33
|
+
EnsemblRest.connect_db
|
34
|
+
end
|
35
|
+
|
36
|
+
should 'support a basic call and return the correct data' do
|
37
|
+
tax = Taxonomy.taxonomy_classification 'Homo'
|
38
|
+
assert tax.index '9605' # the ID of Homo
|
39
|
+
assert tax.index 'Homo sapiens' # one of his children
|
40
|
+
assert tax.index '9606' # has this ID
|
41
|
+
assert tax.index 'man' # and this common name
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'work both with name and NBCI taxon id' do
|
45
|
+
assert_nothing_raised do
|
46
|
+
Taxonomy.taxonomy_classification 'Homo sapiens'
|
47
|
+
Taxonomy.taxonomy_classification '9606'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
sleep(1)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
class TestVariation < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'test vep_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
|
+
var = Variation.vep_id 'COSM476', 'human'
|
13
|
+
assert var.index '7' # variation we asked for is on chromosome 7
|
14
|
+
assert var.index '140453136' # and starts here
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'return the correct data' do
|
18
|
+
data = JSON.parse Variation.vep_id 'COSM476', 'human'
|
19
|
+
var = data['data'].first
|
20
|
+
assert var['name'] == 'COSM476'
|
21
|
+
assert var['is_somatic'] == 1
|
22
|
+
assert var['location']['start'] = 140453136
|
23
|
+
assert var['location']['end'] = 140453136
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'support rs ID' do
|
27
|
+
var = Variation.vep_id 'rs116035550', 'human'
|
28
|
+
assert var.index '11' # variation we asked for is on chromosome 11
|
29
|
+
assert var.index '212464' # and starts here
|
30
|
+
end
|
31
|
+
|
32
|
+
sleep(1)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
context 'test vep_region' do
|
38
|
+
|
39
|
+
setup do
|
40
|
+
EnsemblRest.connect_db
|
41
|
+
require 'rexml/document'
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'support a basic call and return the correct data' do
|
45
|
+
var = Variation.vep_region 'C', '9:22125503-22125502:1', 'human'
|
46
|
+
assert var.index '9' # variation we asked for is on chromosome 7
|
47
|
+
assert var.index '2125503' # starts here
|
48
|
+
assert var.index '22125502' # and ends here
|
49
|
+
end
|
50
|
+
|
51
|
+
should 'return an xml object' do
|
52
|
+
var = Variation.vep_region 'C', '9:22125503-22125502:1', 'human',
|
53
|
+
response: 'xml'
|
54
|
+
assert_nothing_raised { REXML::Document.new var }
|
55
|
+
end
|
56
|
+
|
57
|
+
sleep(1)
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|