Class: Bio::Transmembrane::TransmembraneProtein
- Inherits:
-
Object
- Object
- Bio::Transmembrane::TransmembraneProtein
show all
- Includes:
- Enumerable
- Defined in:
- lib/bio/transmembrane.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TransmembraneProtein.
8
9
10
11
|
# File 'lib/bio/transmembrane.rb', line 8
def initialize
@transmembrane_domains = []
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/bio/transmembrane.rb', line 5
def name
@name
end
|
#transmembrane_domains ⇒ Object
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_length ⇒ Object
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
|
#each ⇒ Object
51
52
53
|
# File 'lib/bio/transmembrane.rb', line 51
def each
@transmembrane_domains.each{|t| yield t}
end
|
#has_domain? ⇒ Boolean
29
30
31
|
# File 'lib/bio/transmembrane.rb', line 29
def has_domain?
!@transmembrane_domains.empty?
end
|
#maximum_length ⇒ Object
25
26
27
|
# File 'lib/bio/transmembrane.rb', line 25
def maximum_length
@transmembrane_domains.max.length
end
|
#minimum_length ⇒ Object
21
22
23
|
# File 'lib/bio/transmembrane.rb', line 21
def minimum_length
@transmembrane_domains.min.length
end
|
#multiple_transmembrane_domains? ⇒ 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
|