class Ensembl::Core::Intron

The Intron class describes an intron.

This class does not use ActiveRecord and is only defined within the API. There is no introns table in the Ensembl database.

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

@example

exon1 = Ensembl::Core::Exon.find(292811)
exon2 = Ensembl::Core::Exon.find(292894)
intron = Ensembl::Core::Intron.new(exon1,exon2)
puts intron.to_yaml

transcript = Ensembl::Core::Transcript.find(58972)
puts transcript.introns.to_yaml

Attributes

next_exon[RW]
previous_exon[RW]
seq_region[RW]
seq_region_end[RW]
seq_region_start[RW]
seq_region_strand[RW]
transcript[RW]

Public Class Methods

new(exon_1, exon_2) click to toggle source
# File lib/bio-ensembl/core/transcript.rb, line 34
def initialize(exon_1, exon_2)
  # Check if these are actually two adjacent exons from the same transcript
  ok = true

  transcript = nil
  exon_1.transcripts.each do |t|
    transcript = t if exon_2.transcripts.include?(t)
  end
  raise ArgumentError, "Arguments should be adjacent exons of same transcript" if transcript.nil?
  
  rank_1 = ExonTranscript.find_by_transcript_id_and_exon_id(transcript.id, exon_1.id).rank
  rank_2 = ExonTranscript.find_by_transcript_id_and_exon_id(transcript.id, exon_2.id).rank
  raise ArgumentError, "Arguments should be adjacent exons of same transcript" if (rank_2 - rank_1).abs > 1
  
  @previous_exon, @next_exon = [exon_1, exon_2].sort_by{|e| e.seq_region_start}
  @transcript = transcript
  @seq_region = @previous_exon.seq_region
  @seq_region_start = @previous_exon.seq_region_end + 1
  @seq_region_end = @next_exon.seq_region_start - 1
  @seq_region_strand = @previous_exon.seq_region_strand
end