class Bio::Transmembrane::TransmembraneDomainDefinition

Attributes

start[RW]
stop[RW]

Public Class Methods

new(start=nil, stop=nil) click to toggle source

A new TMD. The length is stop-start+1, so start and stop are 'inclusive'

# File lib/bio/transmembrane.rb, line 123
def initialize(start=nil, stop=nil)
  @start = start
  @stop = stop
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/bio/transmembrane.rb, line 132
def <=>(other)
  length <=> other.length
end
==(other) click to toggle source
# File lib/bio/transmembrane.rb, line 136
def ==(other)
  start == other.start and
  stop == other.stop
end
intersection(another_transmembrane_domain_defintion) click to toggle source

Return a range representing the overlap of this transmembrane domain with another

Code inspired by billsiggelkow.com/2008/8/29/ruby-range-intersection

# File lib/bio/transmembrane.rb, line 160
def intersection(another_transmembrane_domain_defintion)
  res = (@start..@stop).to_a & (another_transmembrane_domain_defintion.start..another_transmembrane_domain_defintion.stop).to_a
  res.empty? ? nil : (res.first..res.last)
end
Also aliased as: overlap
length() click to toggle source
# File lib/bio/transmembrane.rb, line 128
def length
  @stop-@start+1
end
overlap(another_transmembrane_domain_defintion)
Alias for: intersection
overlap_length(another_transmembrane_domain_defintion) click to toggle source

Return the number of amino acids that overlap with another transmembrane domain, or 0 if none are found

# File lib/bio/transmembrane.rb, line 152
def overlap_length(another_transmembrane_domain_defintion)
  intersection(another_transmembrane_domain_defintion).to_a.length
end
sequence(protein_sequence_string, nterm_offset=0, cterm_offset=0) click to toggle source
# File lib/bio/transmembrane.rb, line 141
def sequence(protein_sequence_string, nterm_offset=0, cterm_offset=0)
  one = start+nterm_offset-1
  one = 0 if one < 0
  two = stop+cterm_offset-1
  two = 0 if two < 0
  
  protein_sequence_string[(one)..(two)]
end