Class: Ensembl::Variation::VariationFeature

Inherits:
DBConnection show all
Defined in:
lib/bio-ensembl/variation/variation_feature.rb,
lib/bio-ensembl/variation/variation_feature62.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



61
62
63
# File 'lib/bio-ensembl/variation/variation_feature.rb', line 61

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

#consequence_typesObject

workaround as ActiveRecord do not parse SET field in MySQL



74
75
76
# File 'lib/bio-ensembl/variation/variation_feature62.rb', line 74

def consequence_types # workaround as ActiveRecord do not parse SET field in MySQL
  "#{attributes_before_type_cast['consequence_types']}" 
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



72
73
74
75
76
# File 'lib/bio-ensembl/variation/variation_feature.rb', line 72

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



78
79
80
81
82
83
84
# File 'lib/bio-ensembl/variation/variation_feature.rb', line 78

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



86
87
88
89
90
91
92
93
94
# File 'lib/bio-ensembl/variation/variation_feature.rb', line 86

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