Class Ensembl::Core::Gene
In: lib/ensembl/core/activerecord.rb
Parent: DBConnection

DESCRIPTION

The Gene class provides an interface to the gene table. This table contains mappings of genes to a SeqRegion.

This class uses ActiveRecord to access data in the Ensembl database. See the general documentation of the Ensembl module for more information on what this means and what methods are available.

This class includes the mixin Sliceable, which means that it is mapped to a SeqRegion object and a Slice can be created for objects of this class. See Sliceable and Slice for more information.

USAGE

 puts Gene.find_by_biotype('protein_coding').length

Methods

Included Modules

Sliceable

External Aliases

gene_attribs -> attribs

Public Class methods

DESCRIPTION

The Gene#find_all_by_name class method searches the Xrefs for that name and returns an array of the corresponding Gene objects. If the name is not found, it returns an empty array.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1073
1073:       def self.find_all_by_name(name)
1074:         answer = Array.new
1075:         xrefs = Ensembl::Core::Xref.find_all_by_display_label(name)
1076:         xrefs.each do |xref|
1077:           answer.push(Ensembl::Core::Gene.find_by_display_xref_id(xref.xref_id))
1078:         end
1079:       
1080:         return answer
1081:       end

DESCRIPTION

The Gene#find_by_name class method searches the Xrefs for that name and returns one Gene objects (even if there should be more). If the name is not found, it returns nil.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1087
1087:       def self.find_by_name(name)
1088:         all_names = self.find_all_by_name(name)
1089:         if all_names.length == 0
1090:           return nil
1091:         else
1092:           return all_names[0]
1093:         end
1094:       end

DESCRIPTION

The Gene#find_by_stable_id class method fetches a Gene object based on its stable ID (i.e. the "ENSG" accession number). If the name is not found, it returns nil.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1100
1100:       def self.find_by_stable_id(stable_id)
1101:         gene_stable_id = GeneStableId.find_by_stable_id(stable_id)
1102:         if gene_stable_id.nil?
1103:           return nil
1104:         else
1105:           return gene_stable_id.gene
1106:         end
1107:       end

Public Instance methods

DESCRIPTION

The Gene#all_xrefs method is a convenience method in that it combines three methods into one. It collects all xrefs for the gene itself, plus all xrefs for all transcripts for the gene, and all xrefs for all translations for those transcripts.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1114
1114:       def all_xrefs
1115:         answer = Array.new
1116:         answer.push(self.xrefs)
1117:         self.transcripts.each do |transcript|
1118:           answer.push(transcript.xrefs)
1119:           if ! transcript.translation.nil?
1120:             answer.push(transcript.translation.xrefs)
1121:           end
1122:         end
1123:         answer.flatten!
1124:         return answer
1125:       end

DESCRIPTION

The Gene#display_label method returns the default name of the gene.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1062
1062:       def display_label
1063:         return Xref.find(self.display_xref_id).display_label
1064:       end
display_name()

Alias for display_label

DESCRIPTION

The Gene#go_terms method returns all GO terms associated with a gene.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1129
1129:       def go_terms
1130:         go_db_id = ExternalDb.find_by_db_name('GO').id
1131:         return self.all_xrefs.select{|x| x.external_db_id == go_db_id}.collect{|x| x.dbprimary_acc}.uniq
1132:       end

DESCRIPTION

The Gene#hgnc returns the HGNC symbol for the gene.

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1136
1136:       def hgnc
1137:         hgnc_db_id = ExternalDb.find_by_db_name('HGNC_curated_gene').id
1138:         xref = self.all_xrefs.select{|x| x.external_db_id == hgnc_db_id}[0]
1139:         return nil if xref.nil?
1140:         return xref.display_label
1141:       end
label()

Alias for display_label

name()

Alias for display_label

DESCRIPTION

The Gene#stable_id method returns the stable_id of the gene (i.e. the ENSG id).

[Source]

      # File lib/ensembl/core/activerecord.rb, line 1055
1055:       def stable_id
1056:         return self.gene_stable_id.stable_id
1057:         
1058:       end

[Validate]