Class: Ensembl::Variation::CompressedGenotypeVar
- Inherits:
-
Connection
- Object
- ActiveRecord::Base
- Connection
- Ensembl::Variation::CompressedGenotypeVar
- Defined in:
- lib/ensembl/variation/activerecord.rb
Instance Method Summary collapse
- #genotype_code_ids ⇒ Object
- #individual_genotypes ⇒ Object
- #individual_ids ⇒ Object
- #unpacked_genotypes ⇒ Object
Methods inherited from Connection
Methods included from TableNameOverrides
Instance Method Details
#genotype_code_ids ⇒ Object
113 114 115 |
# File 'lib/ensembl/variation/activerecord.rb', line 113 def genotype_code_ids unpack_genotypes.select.each_with_index{|str,i| i.odd?} end |
#individual_genotypes ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ensembl/variation/activerecord.rb', line 92 def individual_genotypes nil if genotypes.nil? # To decrease number of DB queries needed # FIXME: Should be in GenotypeCodes class or should use caching allele_codes=GenotypeCode.eager_load(:allele_code).where(:genotype_code_id=>genotype_code_ids.uniq).inject({}){|hsh,gc|hsh[gc.genotype_code_id]=gc.allele_code.allele;hsh} @igs||=unpacked_genotypes.map{|s| IndividualGenotype.new({ individual_id: s[0], genotype_code_id: s[1], allele: allele_codes[s[1]] })} end |
#individual_ids ⇒ Object
109 110 111 |
# File 'lib/ensembl/variation/activerecord.rb', line 109 def individual_ids unpack_genotypes.select.each_with_index{|str,i| i.even?} end |
#unpacked_genotypes ⇒ Object
105 106 107 |
# File 'lib/ensembl/variation/activerecord.rb', line 105 def unpacked_genotypes unpack_genotypes.each_slice(2).map{|sl| sl } end |