ensembl 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/ensembl.gemspec +26 -0
- data/lib/ensembl/variation/activerecord.rb +404 -0
- data/lib/ensembl/version.rb +3 -0
- data/lib/ensembl.rb +65 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f634df833fdd290fdaabfb479ea71c7c2205161a
|
4
|
+
data.tar.gz: d5251a5716e27400796a2b9965e0549faa184576
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d4a98f6b86529f6e33d21223df70ccf70130b7af422a8eb28c7441af19399bb0630cba05e9e78d8ff2d41647751eecfac44aafe8887bf6107afcecfb57c8e53f
|
7
|
+
data.tar.gz: 3a24b0eb6f72384e3864c78d71cd14e961eeba6c16bc049cffe73f123efa06d188ce8ede4443738a9f65fbb8ad16dcfece12bf0f163d704ebee213111118dc51
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
|
24
|
+
.idea
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kristjan Metsalu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Ensembl
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ensembl'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ensembl
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require 'ensembl'
|
22
|
+
|
23
|
+
### ENSEMBL.ORG database - Default configuration
|
24
|
+
|
25
|
+
Ensembl::Variation::Variation.first
|
26
|
+
|
27
|
+
Ensembl::Variation::Variation.first.source
|
28
|
+
|
29
|
+
### Custom database
|
30
|
+
|
31
|
+
# Set following values before using
|
32
|
+
|
33
|
+
Ensembl.host = 'myhost.example.com'
|
34
|
+
Ensembl.port = 3306 # default
|
35
|
+
Ensembl.username = 'anonymous' # default
|
36
|
+
Ensembl.password = '' # default
|
37
|
+
Ensembl.database = 'homo_sapiens_variation_75_37' # default
|
38
|
+
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( https://github.com/kmetsalu/ensembl/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/ensembl.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ensembl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ensembl"
|
8
|
+
spec.version = Ensembl::VERSION
|
9
|
+
spec.authors = ["Kristjan Metsalu"]
|
10
|
+
spec.email = ["kristjan.metsalu@ut.ee"]
|
11
|
+
spec.summary = %q{ Gem to access Ensembl.org databases through API }
|
12
|
+
spec.description = %q{ If it gets better than summary then I'm gonna add it }
|
13
|
+
spec.homepage = "https://github.com/kmetsalu/ensembl"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'mysql2', '~> 0.3'
|
22
|
+
spec.add_dependency 'activerecord', '~> 4.1'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", '~> 10.3'
|
26
|
+
end
|
@@ -0,0 +1,404 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module Ensembl
|
4
|
+
module Variation
|
5
|
+
class Allele < Ensembl::ModelBase
|
6
|
+
belongs_to :variation
|
7
|
+
belongs_to :population
|
8
|
+
belongs_to :subsnp_handle
|
9
|
+
belongs_to :allele_code
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class AlleleCode < Ensembl::ModelBase
|
14
|
+
has_many :genotype_codes
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
class AssociateStudy < Ensembl::Connection
|
19
|
+
belongs_to :study, foreign_key: 'study1_id', class_name: 'Study'
|
20
|
+
belongs_to :associated_study, foreign_key: 'study2_id', class_name: 'Study'
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class Attrib < Ensembl::ModelBase
|
25
|
+
belongs_to :attrib_type
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
class AttribSet < Ensembl::ModelBase
|
30
|
+
belongs_to :attrib
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class AttribType < Ensembl::ModelBase
|
35
|
+
has_many :attribs, class_name: 'Attrib'
|
36
|
+
has_many :pheotype_feature_attrib
|
37
|
+
has_many :phenotype_features, through: :phenotype_feature_attrib
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
class CompressedGenotypeRegion < Ensembl::Connection
|
42
|
+
belongs_to :individual
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class CompressedGenotypeVar < Ensembl::Connection
|
47
|
+
belongs_to :variation
|
48
|
+
belongs_to :subsnp_handle, foreign_key: 'subsnp_id'
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
class CoordSystem < Ensembl::ModelBase
|
53
|
+
end
|
54
|
+
|
55
|
+
class FailedAllele < Ensembl::ModelBase
|
56
|
+
belongs_to :failed_description
|
57
|
+
belongs_to :allele
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
class FailedDescription < Ensembl::ModelBase
|
62
|
+
belongs_to :failed_variation
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class FailedStructuralVariation < Ensembl::ModelBase
|
67
|
+
belongs_to :structural_variation
|
68
|
+
belongs_to :failed_description
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class FailedVariation < Ensembl::ModelBase
|
73
|
+
belongs_to :variation
|
74
|
+
has_one :failed_description
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
class GenotypeCode < Ensembl::ModelBase
|
79
|
+
belongs_to :allele_code
|
80
|
+
belongs_to :genotype_code
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class Individual < Ensembl::ModelBase
|
85
|
+
belongs_to :individual_type
|
86
|
+
belongs_to :father, foreign_key: 'father_individual_id', class_name: 'Individual'
|
87
|
+
belongs_to :mother, foreign_key: 'mother_individual_id', class_name: 'Individual'
|
88
|
+
|
89
|
+
has_many :individual_populations
|
90
|
+
has_many :populations, through: :individual_populations
|
91
|
+
|
92
|
+
has_many :individual_synonyms, foreign_key: :synonym_id
|
93
|
+
has_many :synonyms, through: :individual_synonyms
|
94
|
+
|
95
|
+
scope :with_fathers, -> { where.not(father:nil) }
|
96
|
+
scope :with_mothers, -> { where.not(mother:nil) }
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
class IndividualGenotypeMultipleBp < Ensembl::Connection
|
101
|
+
belongs_to :variation
|
102
|
+
belongs_to :individual
|
103
|
+
belongs_to :subsnp_handle, foreign_key: 'subsnp_id'
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
class IndividualPopulation < Ensembl::Connection
|
108
|
+
belongs_to :individual
|
109
|
+
belongs_to :population
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
class IndividualSynonym < Ensembl::Connection
|
114
|
+
belongs_to :individual
|
115
|
+
belongs_to :source
|
116
|
+
belongs_to :synonym, class_name: 'Individual'
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
class IndividualType < Ensembl::ModelBase
|
121
|
+
has_many :individuals
|
122
|
+
end
|
123
|
+
|
124
|
+
class Meta < Ensembl::ModelBase
|
125
|
+
# TODO: Link with others
|
126
|
+
end
|
127
|
+
|
128
|
+
class MetaCoord < Ensembl::Connection
|
129
|
+
end
|
130
|
+
|
131
|
+
class MotifFreatureVariation < Ensembl::ModelBase
|
132
|
+
belongs_to :variation_feature
|
133
|
+
end
|
134
|
+
|
135
|
+
class Phenotype < Ensembl::ModelBase
|
136
|
+
has_many :phenotype_features
|
137
|
+
end
|
138
|
+
|
139
|
+
class PhenotypeFeature < Ensembl::ModelBase
|
140
|
+
# Hack because using type column in the database
|
141
|
+
self.inheritance_column = ':_no_inheritance_column'
|
142
|
+
|
143
|
+
belongs_to :phenotype
|
144
|
+
belongs_to :source
|
145
|
+
belongs_to :study
|
146
|
+
|
147
|
+
has_many :phenotype_feature_attrib
|
148
|
+
has_many :attrib_types, through: :phenotype_feature_attrib
|
149
|
+
|
150
|
+
def variation
|
151
|
+
Variation.find_by name: object_id
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
class PhenotypeFeatureAttrib < Ensembl::Connection
|
157
|
+
belongs_to :attrib_type
|
158
|
+
belongs_to :phenotype_feature
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
class Population < Ensembl::ModelBase
|
163
|
+
has_many :population_synonyms
|
164
|
+
has_many :synonyms, through: :population_synonyms, source: :synonym
|
165
|
+
has_many :alleles
|
166
|
+
|
167
|
+
has_many :individual_populations
|
168
|
+
has_many :individuals, through: :individual_populations
|
169
|
+
|
170
|
+
has_many :population_structures, foreign_key: 'super_population_id'
|
171
|
+
has_many :sub_populations, through: :population_structures, source: :sub_population
|
172
|
+
|
173
|
+
has_many :population_genotypes
|
174
|
+
|
175
|
+
def all_individual_populations
|
176
|
+
IndividualPopulation.where(population_id: sub_populations.pluck(:population_id))
|
177
|
+
end
|
178
|
+
|
179
|
+
def all_individuals
|
180
|
+
Individual.where individual_id: all_individual_populations.pluck(:individual_id)
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
class PopulationSynonym < Ensembl::Connection
|
186
|
+
belongs_to :synonym, foreign_key: 'synonym_id', class_name: 'Population'
|
187
|
+
belongs_to :population
|
188
|
+
belongs_to :source
|
189
|
+
end
|
190
|
+
|
191
|
+
class PopulationGenotype < Ensembl::ModelBase
|
192
|
+
belongs_to :variation
|
193
|
+
belongs_to :population
|
194
|
+
belongs_to :subsnp_handle, foreign_key: 'subsnp_id'
|
195
|
+
belongs_to :genotype_code
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
class PopulationStructure < Ensembl::Connection
|
200
|
+
belongs_to :population, foreign_key: 'super_population_id', class_name: 'Population'
|
201
|
+
belongs_to :sub_population, foreign_key: 'sub_population_id', class_name: 'Population'
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
class ProteinFunctionPredictions < Ensembl::Connection
|
206
|
+
end
|
207
|
+
|
208
|
+
class Publication < Ensembl::ModelBase
|
209
|
+
end
|
210
|
+
|
211
|
+
class RegulatoryFeatureVariation < Ensembl::ModelBase
|
212
|
+
belongs_to :variation_feature
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
class SeqRegion < Ensembl::ModelBase
|
217
|
+
belongs_to :coord_system
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
class StrainGtypePoly < Ensembl::Connection
|
222
|
+
belongs_to :variation
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
class StructuralVariation < Ensembl::ModelBase
|
227
|
+
belongs_to :source
|
228
|
+
belongs_to :study
|
229
|
+
|
230
|
+
belongs_to :class_attrib, foreign_key: 'class_attrib_id', class_name: 'Attrib'
|
231
|
+
has_one :classification, through: :class_attrib, source: :attrib_type
|
232
|
+
|
233
|
+
belongs_to :clinical_significance_attrib, foreign_key: 'clinical_significance_id', class_name: 'Attrib'
|
234
|
+
has_one :clinical_significance, through: :clinical_significance_attrib, source: :attrib_type
|
235
|
+
|
236
|
+
has_many :structural_variation_associations
|
237
|
+
has_many :supporting_structural_variations, through: :structural_variation_associations
|
238
|
+
|
239
|
+
has_many :structural_variation_samples
|
240
|
+
has_many :individuals, through: :structural_variation_samples, source: :individual
|
241
|
+
|
242
|
+
has_many :variation_sets
|
243
|
+
|
244
|
+
scope :with_supporting_structural_variations, -> { joins(:structural_variation_associations).where.not structural_variation_associations: nil }
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
class StructuralVariationAssociation < Ensembl::Connection
|
249
|
+
belongs_to :structural_variation
|
250
|
+
belongs_to :supporting_structural_variation, foreign_key: 'supporting_structural_variation_id', class_name: 'StructuralVariation'
|
251
|
+
end
|
252
|
+
|
253
|
+
class StructuralVariationFeature < Ensembl::ModelBase
|
254
|
+
belongs_to :seq_region
|
255
|
+
belongs_to :structural_variation
|
256
|
+
belongs_to :source
|
257
|
+
belongs_to :study
|
258
|
+
belongs_to :variation_set
|
259
|
+
|
260
|
+
belongs_to :class_attrib, foreign_key: 'class_attrib_id', class_name: 'Attrib'
|
261
|
+
has_one :classification, through: :class_attrib, source: :attrib_type
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
class StructuralVariationSample < Ensembl::ModelBase
|
266
|
+
belongs_to :structural_variation
|
267
|
+
belongs_to :individual
|
268
|
+
end
|
269
|
+
|
270
|
+
class Study < Ensembl::ModelBase
|
271
|
+
has_many :study_variations
|
272
|
+
has_many :variations, through: :study_variations
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
class Source < Ensembl::ModelBase
|
277
|
+
|
278
|
+
end
|
279
|
+
|
280
|
+
class Study < Ensembl::ModelBase
|
281
|
+
has_many :associate_studies, foreign_key: 'study1_id'
|
282
|
+
has_many :associated_studies, through: :associate_studies, source: :associated_study
|
283
|
+
|
284
|
+
# FIXME: No data in database
|
285
|
+
has_many :variations, through: :study_variations
|
286
|
+
end
|
287
|
+
|
288
|
+
# FIXME: No data in database
|
289
|
+
class StudyVariation < Ensembl::Connection
|
290
|
+
belongs_to :study
|
291
|
+
belongs_to :variation
|
292
|
+
end
|
293
|
+
|
294
|
+
class SubmitterHandle < Ensembl::Connection
|
295
|
+
self.primary_key = 'handle_id'
|
296
|
+
end
|
297
|
+
|
298
|
+
class SubsnpHandle < Ensembl::Connection
|
299
|
+
self.primary_key = 'subsnp_id'
|
300
|
+
|
301
|
+
has_many :subsnp_maps
|
302
|
+
end
|
303
|
+
|
304
|
+
class SubsnpMap < Ensembl::Connection
|
305
|
+
belongs_to :variation
|
306
|
+
belongs_to :subsnp_handle, foreign_key: 'subsnp_id'
|
307
|
+
end
|
308
|
+
|
309
|
+
class TaggedVariationFeature < Ensembl::ModelBase
|
310
|
+
belongs_to :variation_feature
|
311
|
+
belongs_to :population
|
312
|
+
end
|
313
|
+
|
314
|
+
class TranscriptVariation < Ensembl::ModelBase
|
315
|
+
belongs_to :variation_feature
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
class TranslationMd5 < Ensembl::ModelBase
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
class Variation < Ensembl::ModelBase
|
324
|
+
belongs_to :source
|
325
|
+
has_many :variation_synonyms
|
326
|
+
has_many :failed_variations
|
327
|
+
has_many :alleles
|
328
|
+
has_many :population_genotypes
|
329
|
+
has_many :study_variations
|
330
|
+
has_many :studies, through: :study_variations
|
331
|
+
has_many :variation_citations
|
332
|
+
has_many :publications, through: :variation_citations
|
333
|
+
has_many :subsnp_maps
|
334
|
+
has_many :variation_genenames
|
335
|
+
has_many :variation_hgvs, class_name: 'VariationHgvs'
|
336
|
+
has_many :variation_sets
|
337
|
+
|
338
|
+
def phenotype_features
|
339
|
+
PhenotypeFeature.where(object_id: name, type: 'Variation')
|
340
|
+
end
|
341
|
+
|
342
|
+
def all_phenotype_features
|
343
|
+
object_ids = variation_synonyms.pluck :name
|
344
|
+
object_ids<<name
|
345
|
+
PhenotypeFeature.where(object_id: object_ids, type: 'Variation')
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
class VariationCitation < Ensembl::Connection
|
350
|
+
self.table_name = 'variation_citation'
|
351
|
+
belongs_to :variation
|
352
|
+
belongs_to :publication
|
353
|
+
end
|
354
|
+
|
355
|
+
class VariationFeature < Ensembl::ModelBase
|
356
|
+
belongs_to :variation
|
357
|
+
belongs_to :source
|
358
|
+
has_many :transcript_variations
|
359
|
+
has_many :motif_freature_variations
|
360
|
+
has_many :tagged_variation_features
|
361
|
+
|
362
|
+
end
|
363
|
+
|
364
|
+
class VariationGenename < Ensembl::Connection
|
365
|
+
belongs_to :variation
|
366
|
+
end
|
367
|
+
|
368
|
+
class VariationHgvs < Ensembl::Connection
|
369
|
+
belongs_to :variation
|
370
|
+
end
|
371
|
+
|
372
|
+
class VariationSet < Ensembl::ModelBase
|
373
|
+
belongs_to :short_name, foreign_key: 'short_name_attrib_id', class_name: 'Attrib'
|
374
|
+
has_many :structural_variations
|
375
|
+
|
376
|
+
has_many :variation_set_structures
|
377
|
+
has_many :sub_variation_sets, through: :variation_set_structures, source: :sub_variation_set
|
378
|
+
|
379
|
+
has_many :variations
|
380
|
+
end
|
381
|
+
|
382
|
+
class VariationSetStructuralVariation < Ensembl::Connection
|
383
|
+
belongs_to :structural_variation
|
384
|
+
belongs_to :variation_set
|
385
|
+
end
|
386
|
+
|
387
|
+
class VariationSetStructure < Ensembl::Connection
|
388
|
+
belongs_to :super_variation_set, foreign_key: 'super_variation_set_id', class_name: 'VariationSet'
|
389
|
+
belongs_to :sub_variation_set, foreign_key: 'sub_variation_set_id', class_name: 'VariationSet'
|
390
|
+
end
|
391
|
+
|
392
|
+
class VariationSetVariation < Ensembl::Connection
|
393
|
+
belongs_to :variation
|
394
|
+
belongs_to :variation_set
|
395
|
+
end
|
396
|
+
|
397
|
+
class VariationSynonym < Ensembl::ModelBase
|
398
|
+
belongs_to :variation
|
399
|
+
belongs_to :source
|
400
|
+
end
|
401
|
+
|
402
|
+
|
403
|
+
end
|
404
|
+
end
|
data/lib/ensembl.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "ensembl/version"
|
2
|
+
require 'active_record'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
|
5
|
+
module Ensembl
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
attr_accessor :host, :port, :database, :username, :password
|
10
|
+
|
11
|
+
def host
|
12
|
+
@host||='ensembldb.ensembl.org'
|
13
|
+
end
|
14
|
+
|
15
|
+
def port
|
16
|
+
@port||=3306
|
17
|
+
end
|
18
|
+
|
19
|
+
def username
|
20
|
+
@username||='anonymous'
|
21
|
+
end
|
22
|
+
|
23
|
+
def password
|
24
|
+
@password||=''
|
25
|
+
end
|
26
|
+
|
27
|
+
def database
|
28
|
+
@database||='homo_sapiens_variation_75_37'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
module TableNameOverrides
|
34
|
+
def table_name
|
35
|
+
self.name.split('::').last.underscore || ''
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module PrimaryKeyOverrides
|
40
|
+
def primary_key
|
41
|
+
self.table_name + '_id'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Connection < ActiveRecord::Base
|
46
|
+
self.extend TableNameOverrides
|
47
|
+
|
48
|
+
self.abstract_class = true
|
49
|
+
|
50
|
+
self.establish_connection :adapter => "mysql2",
|
51
|
+
:host => Ensembl.host,
|
52
|
+
:username => Ensembl.username,
|
53
|
+
:password => Ensembl.password,
|
54
|
+
:database => Ensembl.database
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
class ModelBase < Connection
|
59
|
+
self.extend PrimaryKeyOverrides
|
60
|
+
|
61
|
+
self.abstract_class = true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
require File.dirname(__FILE__) + '/ensembl/variation/activerecord.rb'
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ensembl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristjan Metsalu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mysql2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.3'
|
69
|
+
description: " If it gets better than summary then I'm gonna add it "
|
70
|
+
email:
|
71
|
+
- kristjan.metsalu@ut.ee
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- ensembl.gemspec
|
82
|
+
- lib/ensembl.rb
|
83
|
+
- lib/ensembl/variation/activerecord.rb
|
84
|
+
- lib/ensembl/version.rb
|
85
|
+
homepage: https://github.com/kmetsalu/ensembl
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Gem to access Ensembl.org databases through API
|
109
|
+
test_files: []
|