ensembl 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d611b86a6388c3b9f18b20afc620fec340c4dcb
4
- data.tar.gz: f31b33ac5b62dfd3d31bec25bf81c17ca000d2d9
3
+ metadata.gz: 1b0618223d20c9cb1f0f508faddc5707238f2b2f
4
+ data.tar.gz: 5448bf0f6e4fc28e05051be6a62deaa04d3c2b9d
5
5
  SHA512:
6
- metadata.gz: 05b85ee36ab9423a3e769c618c72836cb67188b7b00f5559a3bb23aab3505f4680a82cddf54b3cf297e681144573fe920dc781e47e1e2ed1cb6f0a6450fdc320
7
- data.tar.gz: 51318a992a372d690148e9ddde1adced896a3bdeb1dfe12e5f393d1689b3deb801325383ff9aedfbe0dce0d7b188a0166998ddb5ad306d0c95f65f35b86d6e46
6
+ metadata.gz: 7e54bfca14adacc0f0638b166291358df6d1374898faed897ffbc44ae7e2d5175b4fdcdb96b815a0f6d56c3e72220e474e83a08f762950db757dc4b487bde51a
7
+ data.tar.gz: c4f615f25b5e7b1deac38d456e50600f2dd1dede15f6d4fa0b13a85b0ec28211efdd50c62298a009fa7aca46e510f977d0c3bcaefd2a14a4745f984d1a69ca9d
data/ensembl.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'mysql2', '~> 0.3'
24
24
  spec.add_dependency 'activerecord', '~> 4.1'
25
+ spec.add_dependency 'activerecord-tableless', '~> 1.0'
25
26
 
26
27
  spec.add_development_dependency "bundler", "~> 1.6"
27
28
  spec.add_development_dependency "rake", '~> 10.3'
@@ -1,5 +1,6 @@
1
1
  module Ensembl
2
2
  module Core
3
+
3
4
  module StableIdHistory
4
5
  def previous_stable_ids
5
6
  StableIdEvent.where(new_stable_id: stable_id)
@@ -47,7 +47,6 @@ module Ensembl
47
47
 
48
48
  class AttribSet < ModelBase
49
49
  belongs_to :attrib
50
-
51
50
  end
52
51
 
53
52
  class AttribType < ModelBase
@@ -66,6 +65,32 @@ module Ensembl
66
65
  belongs_to :variation
67
66
  belongs_to :subsnp_handle, foreign_key: 'subsnp_id'
68
67
 
68
+ def individual_genotypes
69
+ nil if genotypes.nil?
70
+
71
+ # To decrease number of DB queries needed
72
+ # FIXME: Should be in GenotypeCodes class or should use caching
73
+ genotype_codes=genotype_code_ids.uniq.inject({}) { |hsh, gc_id | hsh[gc_id]=GenotypeCode.find gc_id;hsh }
74
+
75
+ @igs||=unpacked_genotypes.map{|s| IndividualGenotype.new({ individual_id: s[0],genotype_code_id:s[1]})}
76
+ end
77
+
78
+ def unpacked_genotypes
79
+ unpack_genotypes.each_slice(2).map{|sl| sl }
80
+ end
81
+
82
+ def individual_ids
83
+ unpack_genotypes.select.each_with_index{|str,i| i.even?}
84
+ end
85
+
86
+ def genotype_code_ids
87
+ unpack_genotypes.select.each_with_index{|str,i| i.odd?}
88
+ end
89
+
90
+ protected
91
+ def unpack_genotypes
92
+ @g_unpacked||=genotypes.unpack('ww*') unless genotypes.nil?
93
+ end
69
94
  end
70
95
 
71
96
  class CoordSystem < ModelBase
@@ -95,8 +120,8 @@ module Ensembl
95
120
  end
96
121
 
97
122
  class GenotypeCode < ModelBase
123
+
98
124
  belongs_to :allele_code
99
- belongs_to :genotype_code
100
125
 
101
126
  end
102
127
 
@@ -177,29 +202,26 @@ module Ensembl
177
202
  class PhenotypeFeatureAttrib < Connection
178
203
  belongs_to :attrib_type
179
204
  belongs_to :phenotype_feature
180
-
181
205
  end
182
206
 
183
207
  class Population < ModelBase
184
208
  self.extend Ensembl::SearchByName
185
209
 
186
- has_many :population_synonyms
187
- #has_many :synonyms, through: :population_synonyms, source: :synonym
188
210
  has_many :alleles
211
+ has_many :population_synonyms
189
212
 
190
213
  has_many :individual_populations
191
214
  has_many :individuals, through: :individual_populations
192
215
 
193
- has_many :population_structures, foreign_key: 'super_population_id'
216
+ has_many :sub_population_structures, foreign_key: 'super_population_id', class_name: 'PopulationStructure'
194
217
  has_many :sub_populations, through: :population_structures, source: :sub_population
195
- has_many :parents, through: :population_structures, source: :super_populaton#, foreign_key: 'sub_population_id'
218
+
219
+ has_many :super_population_structures, foreign_key: 'sub_population_id', class_name: 'PopulationStructure'
220
+ has_many :super_populations, through: :population_structures, source: :super_populaton
196
221
 
197
222
  has_many :population_genotypes
198
223
 
199
- def parent
200
- ps=PopulationStructure.find_by(sub_population: id)
201
- ps.super_population unless ps.nil?
202
- end
224
+ scope :displayable, -> { where(display:'LD')}
203
225
 
204
226
  def all_individual_populations
205
227
  IndividualPopulation.where(population_id: sub_population_ids(self)<<id)
@@ -233,8 +255,8 @@ module Ensembl
233
255
  belongs_to :variation
234
256
  belongs_to :population
235
257
  belongs_to :subsnp_handle, foreign_key: 'subsnp_id'
236
-
237
258
  belongs_to :genotype_code
259
+
238
260
  has_one :allele_code, through: :genotype_code
239
261
  end
240
262
 
@@ -309,10 +331,10 @@ module Ensembl
309
331
  class StructuralVariationSample < ModelBase
310
332
  belongs_to :structural_variation
311
333
  belongs_to :individual
334
+ belongs_to :strain, foreign_key: 'strain_id', class_name: 'Individual'
312
335
  end
313
336
 
314
337
  class Source < ModelBase
315
-
316
338
  end
317
339
 
318
340
  class Study < ModelBase
@@ -449,7 +471,6 @@ module Ensembl
449
471
  belongs_to :short_name, foreign_key: 'short_name_attrib_id', class_name: 'Attrib'
450
472
  has_many :structural_variations
451
473
 
452
- #has_many :variation_set_structures, foreign_key: 'variation_set_super'
453
474
  has_many :sub_variation_set_structures, foreign_key: 'variation_set_super', class_name: 'VariationSetStructure'
454
475
  has_many :sub_variation_sets, through: :sub_variation_set_structures , source: :sub_variation_set
455
476
 
@@ -0,0 +1,22 @@
1
+ require 'active_record'
2
+ require 'activerecord-tableless'
3
+
4
+ module Ensembl
5
+ module Variation
6
+ class IndividualGenotype < ActiveRecord::Base
7
+ has_no_table
8
+
9
+ column :individual_id, :integer
10
+ column :genotype_code_id, :integer
11
+
12
+ belongs_to :individual
13
+ belongs_to :genotype_code
14
+
15
+ has_one :allele_code, through: :genotype_code
16
+
17
+ delegate :individual_populations, to: :individual
18
+ delegate :populations, to: :individual
19
+
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Ensembl
2
- VERSION = "0.0.4"
2
+ VERSION = '0.0.5'
3
3
  end
data/lib/ensembl.rb CHANGED
@@ -110,3 +110,4 @@ end
110
110
 
111
111
  require File.dirname(__FILE__) + '/ensembl/core/activerecord.rb'
112
112
  require File.dirname(__FILE__) + '/ensembl/variation/activerecord.rb'
113
+ require File.dirname(__FILE__) + '/ensembl/variation/tableless.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ensembl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristjan Metsalu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord-tableless
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +110,7 @@ files:
96
110
  - lib/ensembl.rb
97
111
  - lib/ensembl/core/activerecord.rb
98
112
  - lib/ensembl/variation/activerecord.rb
113
+ - lib/ensembl/variation/tableless.rb
99
114
  - lib/ensembl/version.rb
100
115
  homepage: https://github.com/kmetsalu/ensembl
101
116
  licenses: