Class: Rbfam::Alignment

Inherits:
Object
  • Object
show all
Includes:
CommonHelpers
Defined in:
lib/rbfam/modules/alignment.rb

Constant Summary collapse

LINE_REGEXP =
/^([\w\.]+)\/(\d+)\-(\d+)\s+([AUGC\.]+)$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommonHelpers

included

Constructor Details

#initialize(family) ⇒ Alignment

Returns a new instance of Alignment.



9
10
11
# File 'lib/rbfam/modules/alignment.rb', line 9

def initialize(family)
  @family = family
end

Instance Attribute Details

#familyObject (readonly)

Returns the value of attribute family.



7
8
9
# File 'lib/rbfam/modules/alignment.rb', line 7

def family
  @family
end

#seedObject (readonly)

Returns the value of attribute seed.



7
8
9
# File 'lib/rbfam/modules/alignment.rb', line 7

def seed
  @seed
end

Instance Method Details

#entries(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rbfam/modules/alignment.rb', line 13

def entries(options = {})
  options = { alignment: :seed, limit: false }.merge(options)

  @parsed_entries ||= (pull_from_server(options[:alignment]) || "").split(/\n/).reject do |line|
    line =~ /^#/
  end.select do |line|
    line =~ LINE_REGEXP
  end[options[:limit] ? 0...options[:limit] : 0..-1].map(&method(:parse_line)).tap do
    @seed = options[:alignment] == :seed
  end
end

#load_entries!(options = {}) ⇒ Object



29
30
31
# File 'lib/rbfam/modules/alignment.rb', line 29

def load_entries!(options = {})
  @parsed_entries = family.load_entries!(options)
end

#save_entries!Object



25
26
27
# File 'lib/rbfam/modules/alignment.rb', line 25

def save_entries!
  entries.each { |sequence| sequence.save!(seed: seed) }
end