Class: Bio::Transmembrane::TransmembraneProtein

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bio/transmembrane.rb

Direct Known Subclasses

OrientedTransmembraneDomainProtein

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTransmembraneProtein

Returns a new instance of TransmembraneProtein.



40
41
42
43
# File 'lib/bio/transmembrane.rb', line 40

def initialize
  # default no domains to empty array not nil
  @transmembrane_domains = []
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



37
38
39
# File 'lib/bio/transmembrane.rb', line 37

def name
  @name
end

#transmembrane_domainsObject

Returns the value of attribute transmembrane_domains.



37
38
39
# File 'lib/bio/transmembrane.rb', line 37

def transmembrane_domains
  @transmembrane_domains
end

Instance Method Details

#average_lengthObject



49
50
51
# File 'lib/bio/transmembrane.rb', line 49

def average_length
  @transmembrane_domains.inject(0){|sum,cur| sum+cur.length}.to_f/@transmembrane_domains.length.to_f
end

#best_overlap(another_transmembrane_protein) ⇒ Object

return the pair of transmembrane domains that overlaps the best (ie for the longest period)



76
77
78
79
80
81
# File 'lib/bio/transmembrane.rb', line 76

def best_overlap(another_transmembrane_protein)
  max = @transmembrane_domains.pairs(another_transmembrane_protein.transmembrane_domains).collect {|t1,t2|
    [t1.overlap_length(t2), [t1,t2]]
  }.max {|a,b| a[0] <=> b[0]}
  max[0] == 0 ? nil : max[1]
end

#eachObject



83
84
85
# File 'lib/bio/transmembrane.rb', line 83

def each
  @transmembrane_domains.each{|t| yield t}
end

#has_domain?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/bio/transmembrane.rb', line 61

def has_domain?
  !@transmembrane_domains.empty?
end

#maximum_lengthObject



57
58
59
# File 'lib/bio/transmembrane.rb', line 57

def maximum_length
  @transmembrane_domains.max.length
end

#minimum_lengthObject



53
54
55
# File 'lib/bio/transmembrane.rb', line 53

def minimum_length
  @transmembrane_domains.min.length
end

#multiple_transmembrane_domains?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/bio/transmembrane.rb', line 65

def multiple_transmembrane_domains?
  @transmembrane_domains.length > 1
end

#overlaps(another_transmembrane_protein) ⇒ Object



69
70
71
72
73
# File 'lib/bio/transmembrane.rb', line 69

def overlaps(another_transmembrane_protein)
  @transmembrane_domains.pairs(another_transmembrane_protein.transmembrane_domains).collect {|t1,t2|
    t1.intersection(t2) == () ? nil : [t1,t2]
  }.reject {|a| a.nil?}
end

#push(transmembrane_domain) ⇒ Object



45
46
47
# File 'lib/bio/transmembrane.rb', line 45

def push(transmembrane_domain)
  @transmembrane_domains.push transmembrane_domain
end

#residue_number_contained?(residue_number) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
94
95
# File 'lib/bio/transmembrane.rb', line 87

def residue_number_contained?(residue_number)
  contained = false
  @transmembrane_domains.each do |tmd|
    if tmd.start <= residue_number and tmd.stop >= residue_number
      contained = true
    end
  end
  contained
end