Class: Bio::FinishM::BadFormatWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/assembly/bad_format_writer.rb

Instance Method Summary collapse

Constructor Details

#initializeBadFormatWriter

Returns a new instance of BadFormatWriter.



4
5
6
# File 'lib/assembly/bad_format_writer.rb', line 4

def initialize
  @to_yamlify = []
end

Instance Method Details

#add_metapath(name, metapath) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/assembly/bad_format_writer.rb', line 8

def add_metapath(name, metapath)
  to_write = []
  metapath.each do |onode_or_bubble|
    if onode_or_bubble.kind_of?(Bio::Velvet::Graph::OrientedNodeTrail::OrientedNode)
      next_to_write = {}
      next_to_write['type'] = 'regular'
      next_to_write['node'] = onode_or_bubble.to_shorthand
      next_to_write['coverage'] = onode_or_bubble.node.coverage
      to_write << next_to_write
    else
      # bubble
      paths = []
      onode_or_bubble.each_path do |path|
        next_to_write = {}
        next_to_write['nodes'] = path.to_shorthand
        next_to_write['coverage'] = path.coverage
        paths << next_to_write
      end
      to_write << {
        'type' => 'bubble',
        'paths' => paths
        }
    end
  end

  @to_yamlify << {
    'contig_name' => name,
    'graph' => to_write.to_yaml
    }
end

#write(output_io) ⇒ Object



43
44
45
# File 'lib/assembly/bad_format_writer.rb', line 43

def write(output_io)
  output_io.print yaml
end

#yamlObject



39
40
41
# File 'lib/assembly/bad_format_writer.rb', line 39

def yaml
  @to_yamlify.to_yaml
end