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.



8
9
10
11
# File 'lib/bio/transmembrane.rb', line 8

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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/bio/transmembrane.rb', line 5

def name
  @name
end

#transmembrane_domainsObject

Returns the value of attribute transmembrane_domains.



5
6
7
# File 'lib/bio/transmembrane.rb', line 5

def transmembrane_domains
  @transmembrane_domains
end

Instance Method Details

#average_lengthObject



17
18
19
# File 'lib/bio/transmembrane.rb', line 17

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)



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

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



51
52
53
# File 'lib/bio/transmembrane.rb', line 51

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

#has_domain?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/bio/transmembrane.rb', line 29

def has_domain?
  !@transmembrane_domains.empty?
end

#maximum_lengthObject



25
26
27
# File 'lib/bio/transmembrane.rb', line 25

def maximum_length
  @transmembrane_domains.max.length
end

#minimum_lengthObject



21
22
23
# File 'lib/bio/transmembrane.rb', line 21

def minimum_length
  @transmembrane_domains.min.length
end

#multiple_transmembrane_domains?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/bio/transmembrane.rb', line 33

def multiple_transmembrane_domains?
  @transmembrane_domains.length > 1
end

#overlaps(another_transmembrane_protein) ⇒ Object



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

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



13
14
15
# File 'lib/bio/transmembrane.rb', line 13

def push(transmembrane_domain)
  @transmembrane_domains.push transmembrane_domain
end