Class: Ensembl::Variation::CompressedGenotypeVar

Inherits:
Connection
  • Object
show all
Defined in:
lib/ensembl/variation/activerecord.rb

Instance Method Summary collapse

Methods included from TableNameOverrides

#table_name

Instance Method Details

#genotype_code_idsObject



86
87
88
# File 'lib/ensembl/variation/activerecord.rb', line 86

def genotype_code_ids
  unpack_genotypes.select.each_with_index{|str,i| i.odd?}
end

#individual_genotypesObject



68
69
70
71
72
73
74
75
76
# File 'lib/ensembl/variation/activerecord.rb', line 68

def individual_genotypes
  nil if genotypes.nil?

  # To decrease number of DB queries needed
  # FIXME: Should be in GenotypeCodes class or should use caching
  genotype_codes=genotype_code_ids.uniq.inject({}) { |hsh, gc_id | hsh[gc_id]=GenotypeCode.find gc_id;hsh  }

  @igs||=unpacked_genotypes.map{|s| IndividualGenotype.new({ individual_id:  s[0],genotype_code_id:s[1]})}
end

#individual_idsObject



82
83
84
# File 'lib/ensembl/variation/activerecord.rb', line 82

def individual_ids
  unpack_genotypes.select.each_with_index{|str,i| i.even?}
end

#unpacked_genotypesObject



78
79
80
# File 'lib/ensembl/variation/activerecord.rb', line 78

def unpacked_genotypes
  unpack_genotypes.each_slice(2).map{|sl| sl }
end