Class: Ms::Load::Fasta

Inherits:
Tap::Tasks::Load
  • Object
show all
Defined in:
lib/ms/load/fasta.rb

Overview

:startdoc::task loads entries in a fasta file

Loads entries from a fasta file.

Constant Summary collapse

Entry =
Ms::Fasta::Entry

Instance Method Summary collapse

Instance Method Details

#entry_break?(io) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'lib/ms/load/fasta.rb', line 16

def entry_break?(io)
  if c = io.getc
    io.ungetc(c)
    c == ?>
  else
    true
  end
end

#load(io) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ms/load/fasta.rb', line 25

def load(io)
  header = io.readline
  sequence = []
  while !entry_break?(io)
    sequence << io.readline
  end
  
  case
  when !self.header
    sequence.join('')
  when !self.sequence
    header
  else
    "#{header}#{sequence.join('')}"
  end
end