Class: Ensembl::Variation::GenotypeCode
- Inherits:
-
ModelBase
- Object
- ActiveRecord::Base
- Connection
- ModelBase
- Ensembl::Variation::GenotypeCode
- Defined in:
- lib/ensembl/variation/activerecord.rb
Class Method Summary collapse
- .genotype_for(genotype_code_id) ⇒ Object
- .genotypes_for(genotype_code_ids) ⇒ Object
- .genotypes_hash_for(genotype_code_ids) ⇒ Object
Methods included from PrimaryKeyOverrides
Methods inherited from Connection
Methods included from TableNameOverrides
Class Method Details
.genotype_for(genotype_code_id) ⇒ Object
152 153 154 |
# File 'lib/ensembl/variation/activerecord.rb', line 152 def self.genotype_for(genotype_code_id) joins(:allele_code).where(genotype_code_id: genotype_code_id).order(:haplotype_id).pluck('allele_code.allele').join('|') end |
.genotypes_for(genotype_code_ids) ⇒ Object
156 157 158 |
# File 'lib/ensembl/variation/activerecord.rb', line 156 def self.genotypes_for(genotype_code_ids) includes(:allele_code).where(genotype_code_id: genotype_code_ids).pluck('genotype_code.genotype_code_id','genotype_code.haplotype_id','allele_code.allele').group_by{|r| r[0]}.map{|k,v| [k,v.sort_by{|f,s| f[1]<=>s[1]}.map{|v| v[2]}.join('|')]} end |
.genotypes_hash_for(genotype_code_ids) ⇒ Object
160 161 162 |
# File 'lib/ensembl/variation/activerecord.rb', line 160 def self.genotypes_hash_for(genotype_code_ids) genotypes_for(genotype_code_ids).to_h end |