Class: Ensembl::Core::Intron

Inherits:
Object
  • Object
show all
Includes:
Sliceable
Defined in:
lib/bio-ensembl/core/transcript.rb

Overview

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.

Examples:

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sliceable

#length, #project, #seq, #slice, #start, #stop, #strand, #transform

Constructor Details

#initialize(exon_1, exon_2) ⇒ Intron

Returns a new instance of Intron.

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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

Instance Attribute Details

#next_exonObject

Returns the value of attribute next_exon.



32
33
34
# File 'lib/bio-ensembl/core/transcript.rb', line 32

def next_exon
  @next_exon
end

#previous_exonObject

Returns the value of attribute previous_exon.



32
33
34
# File 'lib/bio-ensembl/core/transcript.rb', line 32

def previous_exon
  @previous_exon
end

#seq_regionObject

Returns the value of attribute seq_region.



31
32
33
# File 'lib/bio-ensembl/core/transcript.rb', line 31

def seq_region
  @seq_region
end

#seq_region_endObject

Returns the value of attribute seq_region_end.



31
32
33
# File 'lib/bio-ensembl/core/transcript.rb', line 31

def seq_region_end
  @seq_region_end
end

#seq_region_startObject

Returns the value of attribute seq_region_start.



31
32
33
# File 'lib/bio-ensembl/core/transcript.rb', line 31

def seq_region_start
  @seq_region_start
end

#seq_region_strandObject

Returns the value of attribute seq_region_strand.



31
32
33
# File 'lib/bio-ensembl/core/transcript.rb', line 31

def seq_region_strand
  @seq_region_strand
end

#transcriptObject

Returns the value of attribute transcript.



32
33
34
# File 'lib/bio-ensembl/core/transcript.rb', line 32

def transcript
  @transcript
end