Class: Cluster

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-cd-hit-report/cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg = {}) ⇒ Cluster

Returns a new instance of Cluster.



4
5
6
7
# File 'lib/bio-cd-hit-report/cluster.rb', line 4

def initialize(arg={})
  self.name = arg[:name]
  self.data = arg[:data] 
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'lib/bio-cd-hit-report/cluster.rb', line 2

def data
  @data
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/bio-cd-hit-report/cluster.rb', line 2

def name
  @name
end

Instance Method Details

#cluster_idObject



9
10
11
# File 'lib/bio-cd-hit-report/cluster.rb', line 9

def cluster_id
  name.scan(/Cluster\s(.*)/).join
end

#entriesObject



27
28
29
# File 'lib/bio-cd-hit-report/cluster.rb', line 27

def entries
  data.split("\n").map{|line|line.scan(/>(.+)\.{3}/)}
end

#membersObject



13
14
15
# File 'lib/bio-cd-hit-report/cluster.rb', line 13

def members
  entries.join(',')
end

#representativeObject Also known as: rep_seq



17
18
19
# File 'lib/bio-cd-hit-report/cluster.rb', line 17

def representative
  data.split("\n").map{|line|line.scan(/>(.+)\.{3}\s\*/)}.join
end

#sizeObject Also known as: length



22
23
24
# File 'lib/bio-cd-hit-report/cluster.rb', line 22

def size
  entries.size
end