Class: Ensembl::Variation::VariationFeature

Inherits:
DBConnection show all
Defined in:
lib/ensembl/variation/variation.rb

Overview

The VariationFeature class gives information about the genomic position of each Variation, including also validation status and consequence type.

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.

Examples:

# SLOWER QUERY
vf = VariationFeature.find_by_variation_name('rs10111')
# FASTER QUERY
vf = Variation.find_by_name('rs10111').variation_feature

puts vf.seq_region_start, vf.seq_region_end, vf.allele_string
puts vf.variation.ancestral_allele
genomic_region = vf.fetch_region (returns an Ensembl::Core::Slice)
genomic_region.genes
up_region,down_region = vf.flanking_seq (returns two Ensembl::Core::Slice)

Instance Method Summary collapse

Methods inherited from DBConnection

connect, ensemblgenomes_connect

Methods inherited from DBRegistry::Base

generic_connect, get_info, get_name_from_db

Instance Method Details

#consequence_typeObject

workaround as ActiveRecord do not parse SET field in MySQL



105
106
107
# File 'lib/ensembl/variation/variation.rb', line 105

def consequence_type # workaround as ActiveRecord do not parse SET field in MySQL
  "#{attributes_before_type_cast['consequence_type']}" 
end

#fetch_region(up = 5000, down = 5000) ⇒ Slice

Based on Perl API ‘get_all_Genes’ method for Variation class. Get a genomic region starting from the Variation coordinates, expanding the region upstream and downstream.

Parameters:

  • up (Integer) (defaults to: 5000)

    Length of upstream flanking region

  • down (Integer) (defaults to: 5000)

    Length of downstream flanking region

Returns:

  • (Slice)

    Slice object containing the variation



116
117
118
119
120
# File 'lib/ensembl/variation/variation.rb', line 116

def fetch_region(up = 5000, down = 5000)
  sr = core_connection(self.seq_region_id)
  slice = Ensembl::Core::Slice.fetch_by_region(Ensembl::Core::CoordSystem.find(sr.coord_system_id).name,sr.name,self.seq_region_start-up,self.seq_region_end+down)
  return slice
end

#flanking_seqObject



122
123
124
125
126
127
128
# File 'lib/ensembl/variation/variation.rb', line 122

def flanking_seq
  sr = core_connection(self.seq_region_id)
  f = Variation.find(self.variation_id).flanking_sequence
  slice_up = Ensembl::Core::Slice.fetch_by_region(Ensembl::Core::CoordSystem.find(sr.coord_system_id).name,sr.name,f.up_seq_region_start,f.up_seq_region_end,self.seq_region_strand)
  slice_down = Ensembl::Core::Slice.fetch_by_region(Ensembl::Core::CoordSystem.find(sr.coord_system_id).name,sr.name,f.down_seq_region_start,f.down_seq_region_end,self.seq_region_strand)
  return slice_up,slice_down
end

#transcript_variationsObject



130
131
132
133
134
135
136
137
138
# File 'lib/ensembl/variation/variation.rb', line 130

def transcript_variations
  tvs = TranscriptVariation.find_all_by_variation_feature_id(self.variation_feature_id)
  if tvs[0].nil? then # the variation is not stored in the database, so run the calculations
    sr = core_connection(self.seq_region_id)
    return custom_transcript_variation(self,sr)
  else
    return tvs # the variation is already present in the database
  end  
end