Class: Bio::FinishM::ProbedGraph

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/assembly/probed_graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log

Instance Attribute Details

#graphObject

Returns the value of attribute graph.



3
4
5
# File 'lib/assembly/probed_graph.rb', line 3

def graph
  @graph
end

#probe_node_directionsObject

Returns the value of attribute probe_node_directions.



3
4
5
# File 'lib/assembly/probed_graph.rb', line 3

def probe_node_directions
  @probe_node_directions
end

#probe_node_readsObject

Returns the value of attribute probe_node_reads.



3
4
5
# File 'lib/assembly/probed_graph.rb', line 3

def probe_node_reads
  @probe_node_reads
end

#probe_nodesObject

Returns the value of attribute probe_nodes.



3
4
5
# File 'lib/assembly/probed_graph.rb', line 3

def probe_nodes
  @probe_nodes
end

#read_to_nodesObject

Most likely a ReadToNode object



11
12
13
# File 'lib/assembly/probed_graph.rb', line 11

def read_to_nodes
  @read_to_nodes
end

#velvet_result_directoryObject

Returns the value of attribute velvet_result_directory.



5
6
7
# File 'lib/assembly/probed_graph.rb', line 5

def velvet_result_directory
  @velvet_result_directory
end

#velvet_sequencesObject

Most likely a BinarySequenceStore



8
9
10
# File 'lib/assembly/probed_graph.rb', line 8

def velvet_sequences
  @velvet_sequences
end

Instance Method Details

#adjusted_leash_length(probe_index, starting_leash_length) ⇒ Object

The leash is the number of base pairs from the start of the probe, but the path finding algorithm simply uses the combined length of all the nodes without reference to the actual probe sequence. So if the probe is near the end of a long node, then path finding may fail. So adjust the leash length to account for this (or keep the nil if the starting_leash_length is nil)



58
59
60
61
62
63
# File 'lib/assembly/probed_graph.rb', line 58

def adjusted_leash_length(probe_index, starting_leash_length)
  return nil if starting_leash_length.nil?

  read = @probe_node_reads[probe_index]
  return read.offset_from_start_of_node+starting_leash_length
end

#completely_probed?Boolean

Were all the probe recovered through the process?

Returns:

  • (Boolean)


14
15
16
# File 'lib/assembly/probed_graph.rb', line 14

def completely_probed?
  !(@probe_nodes.find{|node| node.nil?})
end

#initial_path_from_probe(probe_index) ⇒ Object

Make a Bio::Velvet::Graph::OrientedNodeTrail with just one step in it - the node that corresponds to the probe_index



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/assembly/probed_graph.rb', line 28

def initial_path_from_probe(probe_index)
  initial_path = Bio::Velvet::Graph::OrientedNodeTrail.new
  node = @probe_nodes[probe_index]
  raise "No node found for probe #{probe_index}" if node.nil?
  direction = @probe_node_directions[probe_index]

  way = direction ?
  Bio::Velvet::Graph::OrientedNodeTrail::START_IS_FIRST :
    Bio::Velvet::Graph::OrientedNodeTrail::END_IS_FIRST
  initial_path.add_node node, way
  return initial_path
end

#missing_probe_indicesObject



18
19
20
21
22
23
24
# File 'lib/assembly/probed_graph.rb', line 18

def missing_probe_indices
  missings = []
  @probe_nodes.each_with_index do |probe, i|
    missings.push(i+1) if probe.nil?
  end
  return missings
end

#paired_nodes(node) ⇒ Object

Return a list of node IDs that are connected through paired-end linkages. This method probably belongs in the Node class except that that is in bio-velvet and yet requires sequence_id_to_node_ids_hash. If all reads are single ended then this method always returns []



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/assembly/probed_graph.rb', line 90

def paired_nodes(node)
  to_return_node_ids = Set.new
  log.debug "Found #{node.short_reads.length} short reads associated with node #{node}" if log.debug?
  node.short_reads.each do |read|
    pair_read_id = @velvet_sequences.pair_id(read.read_id)
    unless pair_read_id.nil? #i.e. if read is paired
      @read_to_nodes[pair_read_id].each do |node_id|
        to_return_node_ids << node_id
      end
    end
  end
  # Convert node IDs to node objects and return
  return to_return_node_ids.to_a
end

#subgraph(probe_indices) ⇒ Object

Return a new ProbedGraph that is the same as the current one except that only probe specified in the given probe_indices enumerable are accepted



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/assembly/probed_graph.rb', line 68

def subgraph(probe_indices)
  to_return = Bio::FinishM::ProbedGraph.new
  to_return.graph = @graph
  to_return.velvet_result_directory = @velvet_result_directory
  to_return.velvet_sequences = @velvet_sequences

  to_return.probe_nodes = []
  to_return.probe_node_directions = []
  to_return.probe_node_reads = []
  probe_indices.each do |i|
    to_return.probe_nodes.push @probe_nodes[i-1]
    to_return.probe_node_directions.push @probe_node_directions[i-1]
    to_return.probe_node_reads.push @probe_node_reads[i-1]
  end

  return to_return
end

#velvet_oriented_node(probe_index) ⇒ Object

Return a Bio::Velvet::Graph::OrientedNodeTrail::OrientedNode corresponding to the index of the probe and its direction



43
44
45
46
47
48
49
50
# File 'lib/assembly/probed_graph.rb', line 43

def velvet_oriented_node(probe_index)
  node = @probe_nodes[probe_index]
  if node.nil?
    return nil
  else
    return initial_path_from_probe(probe_index)[0]
  end
end