bio-ensembl-rest 0.1.0 → 0.2.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.
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.0.0
5
4
 
6
5
  matrix:
7
6
  allow_failures:
data/README.md CHANGED
@@ -3,13 +3,13 @@ Ensembl Rest
3
3
 
4
4
  A Ruby library for the RESTful Ensembl API.
5
5
 
6
- [![Build Status](https://api.travis-ci.org/ALTree/ensembl-rest.png)](https://travis-ci.org/ALTree/ensembl-rest)
6
+ [![Gem Version](https://badge.fury.io/rb/bio-ensembl-rest.png)](http://badge.fury.io/rb/bio-ensembl-rest)
7
7
 
8
8
  Obtaining
9
9
  ---------
10
10
 
11
11
  ```sh
12
- gem install ensembl-rest
12
+ gem install bio-ensembl-rest
13
13
  ```
14
14
  for the repository:
15
15
  ```sh
@@ -43,7 +43,7 @@ See the [ensembl-rest wiki page](https://github.com/ALTree/bio-ensembl-rest/wiki
43
43
 
44
44
  ### version-specific issues
45
45
 
46
- * On jruby-1.7, methods in the ComparativeGenomics module fail if called with `response: ruby`,
46
+ * On jruby, methods in the ComparativeGenomics module fail if called with `response: ruby`,
47
47
  due to a C dependency in the 'bio' gem.
48
48
 
49
49
  * On rubinius, methods in the ComparativeGenomics module fail if called with `response: ruby`,
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ require 'rake'
14
14
  require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  gem.name = "bio-ensembl-rest"
17
- gem.version = '0.1.0'
17
+ gem.version = '0.2.0'
18
18
  gem.homepage = "http://github.com/ALTree/bio-ensembl-rest"
19
19
  gem.license = "MIT"
20
20
  gem.summary = "Ruby Ensembl REST api"
@@ -1,6 +1,38 @@
1
1
  module EnsemblRest
2
2
  module ComparativeGenomics
3
3
 
4
+ ##
5
+ # Retrieves genomic alignments as separate blocks based on its location
6
+ def self.alignment_block(species, region, opts = {})
7
+ opts = EnsemblRest.parse_options opts
8
+ path = EnsemblRest.build_path "/alignment/block/region/#{species}/#{region}", opts
9
+
10
+ if opts['content-type'] == 'ruby'
11
+ plain_opts = opts.clone
12
+ plain_opts['content-type'] = 'application/json'
13
+ return JSON.parse ComparativeGenomics.alignment_block species, region, plain_opts
14
+ end
15
+
16
+ return EnsemblRest.fetch_data path, opts, 'compara'
17
+ end
18
+
19
+ ##
20
+ # Retrieves genomic alignments as a single slice based on its location
21
+ def self.alignment_slice(species, region, opts = {})
22
+ opts = EnsemblRest.parse_options opts
23
+ path = EnsemblRest.build_path "/alignment/slice/region/#{species}/#{region}", opts
24
+
25
+ if opts['content-type'] == 'ruby'
26
+ plain_opts = opts.clone
27
+ plain_opts['content-type'] = 'application/json'
28
+ return JSON.parse ComparativeGenomics.alignment_slice species, region, plain_opts
29
+ end
30
+
31
+ return EnsemblRest.fetch_data path, opts, 'compara'
32
+ end
33
+
34
+
35
+
4
36
  ##
5
37
  # Retrieves Gene Tree dumps for a given Gene Tree stable identifier
6
38
  def self.genetree_id(id, opts = {})
@@ -52,7 +52,6 @@ module EnsemblRest
52
52
  opts
53
53
  end
54
54
 
55
-
56
55
  ## HTTP request stuff ##
57
56
 
58
57
  def self.build_path(home, opts) # :nodoc:
@@ -62,7 +61,6 @@ module EnsemblRest
62
61
  URI::encode path
63
62
  end
64
63
 
65
- # TODO: add tests to check if this default stuff is ok
66
64
  def self.fetch_data(path, opts, mod) # :nodoc:
67
65
  # what we should set as content-type in the header
68
66
  # to keep ensembl happy when the the user does not
@@ -42,5 +42,22 @@ module EnsemblRest
42
42
  return EnsemblRest.fetch_data path, opts, 'features'
43
43
  end
44
44
 
45
+ ##
46
+ # Uses the given identifier to return translation related features.
47
+ def self.feature_translation(id, opts = {})
48
+ opts = EnsemblRest.parse_options opts
49
+ path = EnsemblRest.build_path "/feature/translation/#{id}", opts
50
+
51
+ if opts['content-type'] == 'ruby'
52
+ plain_opts = opts.clone
53
+ plain_opts['content-type'] = 'application/json'
54
+ return JSON.parse feature_translation id, plain_opts
55
+ end
56
+
57
+ return EnsemblRest.fetch_data path, opts, 'features'
58
+
59
+ end
60
+
45
61
  end
62
+
46
63
  end
@@ -33,6 +33,70 @@ module EnsemblRest
33
33
  end
34
34
 
35
35
 
36
+ ##
37
+ # Lists the available analyses by logic name and the database type those logic names are found in.
38
+ def self.info_analysis(species, opts = {})
39
+ opts = EnsemblRest.parse_options opts
40
+ path = EnsemblRest.build_path "/info/analysis/#{species}", opts
41
+
42
+ if opts['content-type'] == 'ruby'
43
+ plain_opts = opts.clone
44
+ plain_opts['content-type'] = 'application/json'
45
+ return JSON.parse info_analysis species, plain_opts
46
+ end
47
+
48
+ return EnsemblRest.fetch_data path, opts, 'information'
49
+ end
50
+
51
+
52
+ ##
53
+ # Lists all available biotypes for the given species.
54
+ def self.info_biotypes(species, opts = {})
55
+ opts = EnsemblRest.parse_options opts
56
+ path = EnsemblRest.build_path "/info/biotypes/#{species}", opts
57
+
58
+ if opts['content-type'] == 'ruby'
59
+ plain_opts = opts.clone
60
+ plain_opts['content-type'] = 'application/json'
61
+ return JSON.parse info_biotypes species, plain_opts
62
+ end
63
+
64
+ return EnsemblRest.fetch_data path, opts, 'information'
65
+ end
66
+
67
+ ##
68
+ #
69
+ def self.info_compara_methods(opts = {})
70
+ opts = EnsemblRest.parse_options opts
71
+ path = EnsemblRest.build_path "/info/compara/methods", opts
72
+
73
+ if opts['content-type'] == 'ruby'
74
+ plain_opts = opts.clone
75
+ plain_opts['content-type'] = 'application/json'
76
+ return JSON.parse info_compara_methods plain_opts
77
+ end
78
+
79
+ return EnsemblRest.fetch_data path, opts, 'information'
80
+ end
81
+
82
+
83
+ ##
84
+ #
85
+ def self.info_compara_species_sets_method(method, opts = {})
86
+ opts = EnsemblRest.parse_options opts
87
+ path = EnsemblRest.build_path "/info/compara/species_sets/#{method}", opts
88
+
89
+ if opts['content-type'] == 'ruby'
90
+ plain_opts = opts.clone
91
+ plain_opts['content-type'] = 'application/json'
92
+ return JSON.parse info_compara_species_sets_method method, plain_opts
93
+ end
94
+
95
+ return EnsemblRest.fetch_data path, opts, 'information'
96
+ end
97
+
98
+
99
+
36
100
  ##
37
101
  # Lists all available comparative genomics databases and their data release
38
102
  def self.info_comparas(opts = {})
@@ -2,6 +2,37 @@ require_relative 'helper'
2
2
 
3
3
  class TestComparativeGenomics < Test::Unit::TestCase
4
4
 
5
+
6
+ context 'alignment_block' do
7
+
8
+ setup do
9
+ EnsemblRest.connect_db
10
+ end
11
+
12
+ should 'support a basic call and return the correct data' do
13
+ align = ComparativeGenomics.alignment_block 'homo sapiens', '2:106040000-106040050:1'
14
+ assert align.index 'GTAGCAGGAAGAATGTTTATCTCTGTGTCTTGTCTTTCTGGTTAAAGGTAT'
15
+ end
16
+
17
+ sleep(1)
18
+
19
+ end
20
+
21
+
22
+ context 'alignment_slice' do
23
+
24
+ setup do
25
+ EnsemblRest.connect_db
26
+ end
27
+
28
+ should 'support a basic call and return the correct data' do
29
+ align = ComparativeGenomics.alignment_slice 'homo sapiens', '2:106040000-106040050:1'
30
+ assert align.index 'GTAGCAGGAAGAATGTTTATCTCTGTGTCTTGTCTTTCTGGTTAAAGGTAT'
31
+ end
32
+
33
+ end
34
+
35
+
5
36
  context 'genetree_id' do
6
37
 
7
38
  setup do
@@ -13,6 +44,8 @@ class TestComparativeGenomics < Test::Unit::TestCase
13
44
  assert tree.index('Euteleostomi') && tree.index('Sarcopterygii')
14
45
  end
15
46
 
47
+ sleep(1)
48
+
16
49
  should 'work with nh response type' do
17
50
  tree1 = ComparativeGenomics.genetree_id 'ENSGT00390000003602',
18
51
  response: 'nh',
@@ -25,6 +58,8 @@ class TestComparativeGenomics < Test::Unit::TestCase
25
58
  assert tree2.index 'xiphophorus_maculatus'
26
59
  end
27
60
 
61
+ sleep(1)
62
+
28
63
  should 'return a Bio::PhyloXML object' do
29
64
  tree = ComparativeGenomics.genetree_id 'ENSGT00390000003602',
30
65
  response: 'ruby'
@@ -94,6 +129,8 @@ class TestComparativeGenomics < Test::Unit::TestCase
94
129
  assert_nothing_raised { JSON.parse hom }
95
130
  end
96
131
 
132
+ sleep(1)
133
+
97
134
  should 'return a xml object' do
98
135
  hom = ComparativeGenomics.homology_id 'ENSG00000157764',
99
136
  response: 'xml'
@@ -41,6 +41,8 @@ class TestCrossReference < Test::Unit::TestCase
41
41
  assert ref.index 'BROVCA2'
42
42
  end
43
43
 
44
+ sleep(1)
45
+
44
46
  should 'return a JSON object' do
45
47
  refs = CrossReference.xrefs_name 'human', 'BRCA2', response: 'json'
46
48
  assert_nothing_raised { JSON.parse refs }
@@ -23,6 +23,8 @@ class TestFeatures < Test::Unit::TestCase
23
23
  end
24
24
  end
25
25
 
26
+ sleep(1)
27
+
26
28
  should 'raise error if no feature is given' do
27
29
  assert_raises RuntimeError do
28
30
  Features.feature_id 'ENSG00000157764', response: 'json'
@@ -54,6 +56,8 @@ class TestFeatures < Test::Unit::TestCase
54
56
  assert fts.index '140624564' # gene end here
55
57
  end
56
58
 
59
+ sleep(1)
60
+
57
61
  should 'support multiple features' do
58
62
  assert_nothing_raised do
59
63
  Features.feature_region 'human', '7:140424943-140624564',
@@ -72,5 +76,18 @@ class TestFeatures < Test::Unit::TestCase
72
76
 
73
77
  end
74
78
 
79
+ context 'feature_translation' do
80
+
81
+ setup do
82
+ EnsemblRest.connect_db
83
+ end
84
+
85
+ should 'support a basic call and return the correct data' do
86
+ ft = Features.feature_translation 'ENSP00000288602'
87
+ assert ft.index('SSF56112')
88
+ end
89
+
90
+ end
91
+
75
92
 
76
93
  end
@@ -32,8 +32,75 @@ class TestInformation < Test::Unit::TestCase
32
32
  assert info.index 'chromosome' # coordinate_system should be this
33
33
  end
34
34
 
35
+ sleep(1)
36
+
35
37
  end
36
38
 
39
+ context 'info_analysis' 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
+ assert_nothing_raised do
47
+ info = Information.info_analysis 'homo sapiens'
48
+ end
49
+ end
50
+
51
+ sleep(1)
52
+
53
+ end
54
+
55
+ context 'info_biotypes' do
56
+
57
+ setup do
58
+ EnsemblRest.connect_db
59
+ end
60
+
61
+ should 'support a basic call and return the correct data' do
62
+ assert_nothing_raised do
63
+ info = Information.info_biotypes 'homo sapiens'
64
+ end
65
+ end
66
+
67
+ sleep(1)
68
+
69
+ end
70
+
71
+ context 'info_compara_methods' 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
+ assert_nothing_raised do
79
+ info = Information.info_compara_methods
80
+ end
81
+ end
82
+
83
+ sleep(1)
84
+
85
+ end
86
+
87
+ context 'info_compara_species_sets_method' do
88
+
89
+ setup do
90
+ EnsemblRest.connect_db
91
+ end
92
+
93
+ should 'support a basic call and return the correct data' do
94
+ assert_nothing_raised do
95
+ info = Information.info_compara_species_sets_method 'EPO'
96
+ end
97
+ end
98
+
99
+ sleep(1)
100
+
101
+ end
102
+
103
+
37
104
 
38
105
  context 'info_comparas' do
39
106
 
@@ -48,6 +115,8 @@ class TestInformation < Test::Unit::TestCase
48
115
  assert info.index 'release' # number of the databases
49
116
  end
50
117
 
118
+ sleep(1)
119
+
51
120
  end
52
121
 
53
122
 
@@ -79,6 +148,8 @@ class TestInformation < Test::Unit::TestCase
79
148
  assert info.index '1' # so we know the server is alive
80
149
  end
81
150
 
151
+ sleep(1)
152
+
82
153
  end
83
154
 
84
155
 
@@ -93,6 +164,8 @@ class TestInformation < Test::Unit::TestCase
93
164
  assert info.index 'release' # we expect a release number
94
165
  end
95
166
 
167
+ sleep(1)
168
+
96
169
  end
97
170
 
98
171
 
@@ -16,6 +16,8 @@ class TestLookup < Test::Unit::TestCase
16
16
  assert look.index 'ENSG00000157764' # exactly this one
17
17
  end
18
18
 
19
+ sleep(1)
20
+
19
21
  should 'support the full parameter' do
20
22
  look_plain = Lookup.lookup_id 'ENSG00000157764'
21
23
  look_full = Lookup.lookup_id 'ENSG00000157764', format: 'full'
@@ -47,6 +47,8 @@ class TestMapping < Test::Unit::TestCase
47
47
  assert map.index '-1' # strand -1
48
48
  end
49
49
 
50
+ sleep(1)
51
+
50
52
  should 'return the right mapping' do
51
53
  map = Mapping.map_from_cdna 'ENST00000288602', '100..300',
52
54
  response: 'ruby'
@@ -61,6 +61,8 @@ class TestOntologies < Test::Unit::TestCase
61
61
  assert ont.index 'GO:0043231' # and this one, too
62
62
  end
63
63
 
64
+ sleep(1)
65
+
64
66
  should 'support the subset parameter' do
65
67
  ont1 = Ontologies.ontology_descendents 'GO:0005667', subset: 'goslim_generic'
66
68
  ont2 = Ontologies.ontology_descendents 'GO:0005667'
@@ -85,6 +87,8 @@ class TestOntologies < Test::Unit::TestCase
85
87
  assert ont.index 'GO:0044451' # his parent
86
88
  end
87
89
 
90
+ sleep(1)
91
+
88
92
  should 'return a ruby object' do
89
93
  ont = Ontologies.ontology_id 'GO:0005667', response: 'ruby'
90
94
  assert_instance_of Hash, ont
@@ -15,6 +15,8 @@ class TestSequence < Test::Unit::TestCase
15
15
  assert_equal seq2.size, 18
16
16
  end
17
17
 
18
+ sleep(1)
19
+
18
20
  should 'expand the sequence 10 pairs upstream' do
19
21
  seq1 = Sequence.sequence_id 'ENSE00001154485',
20
22
  response: 'text',
@@ -35,16 +37,7 @@ class TestSequence < Test::Unit::TestCase
35
37
  assert_instance_of Bio::Sequence, seq
36
38
  end
37
39
 
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
40
+ sleep(1)
48
41
 
49
42
  should 'return multiple sequences' do
50
43
  response = Sequence.sequence_id 'ENSG00000157764',
@@ -97,6 +90,8 @@ class TestSequence < Test::Unit::TestCase
97
90
  assert_nothing_raised { JSON.parse seq }
98
91
  end
99
92
 
93
+ sleep(1)
94
+
100
95
  should 'return a Bio::Sequence object' do
101
96
  seq = Sequence.sequence_region 'human',
102
97
  'X:1000000..1000100:1',
@@ -41,6 +41,8 @@ class TestTaxonomy < Test::Unit::TestCase
41
41
  assert tax.index 'man' # and this common name
42
42
  end
43
43
 
44
+ sleep(1)
45
+
44
46
  should 'work both with name and NBCI taxon id' do
45
47
  assert_nothing_raised do
46
48
  Taxonomy.taxonomy_classification 'Homo sapiens'
@@ -14,6 +14,8 @@ class TestVariation < Test::Unit::TestCase
14
14
  assert var.index '140453136' # and starts here
15
15
  end
16
16
 
17
+ sleep(1)
18
+
17
19
  should 'return the correct data' do
18
20
  data = JSON.parse Variation.vep_id 'COSM476', 'human'
19
21
  var = data['data'].first
metadata CHANGED
@@ -1,60 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-ensembl-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Alberto Donizetti
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-09-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bio
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 1.4.3
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.4.3
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: libxml-ruby
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '2'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '2'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: shoulda
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rdoc
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: bundler
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: jeweler
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
@@ -133,25 +146,29 @@ files:
133
146
  homepage: http://github.com/ALTree/bio-ensembl-rest
134
147
  licenses:
135
148
  - MIT
136
- metadata: {}
137
149
  post_install_message:
138
150
  rdoc_options: []
139
151
  require_paths:
140
152
  - lib
141
153
  required_ruby_version: !ruby/object:Gem::Requirement
154
+ none: false
142
155
  requirements:
143
- - - '>='
156
+ - - ! '>='
144
157
  - !ruby/object:Gem::Version
145
158
  version: '0'
159
+ segments:
160
+ - 0
161
+ hash: -796222272840481707
146
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
+ none: false
147
164
  requirements:
148
- - - '>='
165
+ - - ! '>='
149
166
  - !ruby/object:Gem::Version
150
167
  version: '0'
151
168
  requirements: []
152
169
  rubyforge_project:
153
- rubygems_version: 2.0.3
170
+ rubygems_version: 1.8.25
154
171
  signing_key:
155
- specification_version: 4
172
+ specification_version: 3
156
173
  summary: Ruby Ensembl REST api
157
174
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e112aedd2a2a78c4f241301731d39e2a3f094942
4
- data.tar.gz: 483b616adf1743cac1b35088b59fa4d68e85e915
5
- SHA512:
6
- metadata.gz: 7fa0521d7923a7b9aafe1427258037a27b3794c736f36b9c0bec00d2b68b051b22195abbb3bec34307735a8274fcd9e58bfbb55b02ca2db745f76748f19dd90c
7
- data.tar.gz: f91ecf17d9f0a267851e936efa1d4522160d54b56ba892ef1c2ad7f659f8fcdd1e1ed0a1301cc464f519566eedaf1c5894292791acc31144116dc68caf4cb07f