Class: Bio::Assembly::Caf

Inherits:
Bio::Assembly show all
Defined in:
lib/bio-assembly/caf.rb

Defined Under Namespace

Classes: Contig, Read

Instance Method Summary collapse

Methods inherited from Bio::Assembly

open, register_parser

Constructor Details

#initialize(path) ⇒ Caf

Returns a new instance of Caf.



8
9
10
# File 'lib/bio-assembly/caf.rb', line 8

def initialize(path)
   @file = File.new(path, 'r') 
end

Instance Method Details

#each_contigObject

iterator that return one contig at a time



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bio-assembly/caf.rb', line 12

def each_contig
  contig = Contig.new
  feature = Hash.new
  @file.each do |line|
    feature = parse_blocks(line,feature) # search the file for CAF blocks like DNA and Sequence
    if feature[:type] == :read and feature[:parsed]
      read = convert_to_read(feature)
      contig.add_read(read)
      feature = Hash.new
    elsif feature[:type] == :contig and feature[:parsed]
      contig = convert_to_contig(contig,feature)
      yield contig
      contig = Contig.new
      feature = Hash.new
    end
  end
end