Class: Bio::AssemblyGraphAlgorithms::SingleCoherentWanderer::DistancedOrientedNodeSet

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

Overview

An oriented node some distance from the origin of exploration

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



210
211
212
# File 'lib/assembly/single_coherent_wanderer.rb', line 210

def distance
  @distance
end

#oriented_trailObject

Returns the value of attribute oriented_trail.



210
211
212
# File 'lib/assembly/single_coherent_wanderer.rb', line 210

def oriented_trail
  @oriented_trail
end

Instance Method Details

#add_oriented_node_and_copy(oriented_node, recoherence_kmer) ⇒ Object

Create a copy of this object, then add the given oriented_node to this object, and discard objects from the rear of the trail if they are now of no use for recoherence. Update the distance



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/assembly/single_coherent_wanderer.rb', line 226

def add_oriented_node_and_copy(oriented_node, recoherence_kmer)
  d = DistancedOrientedNodeSet.new
  new_trail =  @oriented_trail.trail+[oriented_node]

  # Remove unneeded rear nodes that cannot contribute to the recoherence
  # calculation going forward
  cumulative_length = 0
  i = new_trail.length - 1
  while i >= 0 and cumulative_length < recoherence_kmer
    cumulative_length += new_trail[i].node.length_alone
    i -= 1
  end
  i += 1
  d.oriented_trail = Bio::Velvet::Graph::OrientedNodeTrail.new
  d.oriented_trail.trail = new_trail[i..-1]
  # Update distance
  d.distance = @distance+oriented_node.node.length_alone

  return d
end

#last_node_recoherent?(recoherence_kmer, sequence_hash) ⇒ Boolean

Is the head nodes single recoherent? Return false if not, otherwise true

Returns:

  • (Boolean)


248
249
250
251
252
253
254
255
# File 'lib/assembly/single_coherent_wanderer.rb', line 248

def last_node_recoherent?(recoherence_kmer, sequence_hash)
  @@single_recoherencer ||= Bio::AssemblyGraphAlgorithms::SingleCoherentPathsBetweenNodesFinder.new
  return @@single_recoherencer.validate_last_node_of_path_by_recoherence(
    @oriented_trail,
    recoherence_kmer,
    sequence_hash
    )
end

#to_sObject



257
258
259
# File 'lib/assembly/single_coherent_wanderer.rb', line 257

def to_s
  "#{@oriented_trail.to_s}(#{@distance})"
end

#to_settableObject

Using Set object, often we want two separate objects to be considered equal even if they are distinct objects



214
215
216
217
218
219
220
221
# File 'lib/assembly/single_coherent_wanderer.rb', line 214

def to_settable
  settable = []
  @oriented_trail.each do |onode|
    settable.push onode.node_id
    settable.push onode.first_side
  end
  return settable
end