Class: Bio::FinishM::ReadToNode
- Inherits:
-
Object
- Object
- Bio::FinishM::ReadToNode
- Includes:
- Logging
- Defined in:
- lib/assembly/read_to_node.rb
Instance Method Summary collapse
-
#[](read_id) ⇒ Object
Return an array of node IDs that include the given read id.
-
#initialize(filename) ⇒ ReadToNode
constructor
A new instance of ReadToNode.
Methods included from Logging
Constructor Details
#initialize(filename) ⇒ ReadToNode
Returns a new instance of ReadToNode.
4 5 6 7 8 9 10 11 |
# File 'lib/assembly/read_to_node.rb', line 4 def initialize(filename) @bindings = Bio::FinishM::VelvetCBinding.new log.debug "Reading ReadToNode file #{filename}.." raise "Unable to find readToNode binary file" unless File.exist?(filename) @read_to_node = @bindings.read_read_id_to_node_id_lookup_table(filename) log.debug "Finished reading ReadToNode file" @cache = {} end |
Instance Method Details
#[](read_id) ⇒ Object
Return an array of node IDs that include the given read id
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/assembly/read_to_node.rb', line 14 def [](read_id) # cache cache = @cache[read_id] return cache unless cache.nil? res = @bindings.get_read_id_to_node_id_indexation(@read_to_node, read_id) # # typedef struct { # # IDnum num_nodes; # # ReadIdNodeId* read_ids_node_ids; # # } ReadIdToNodeIdIndexation; # class ReadIdToNodeIdIndexationStruct < FFI::Struct # layout :num_nodes, :int32, # :read_ids_node_ids, :pointer # end to_return = [] structs = FFI::Pointer.new(Bio::FinishM::VelvetCBinding::ReadIdNodeIdStruct, res[:read_ids_node_ids].pointer) 0.upto(res[:num_nodes]-1) do |i| to_return << Bio::FinishM::VelvetCBinding::ReadIdNodeIdStruct.new(structs[i])[:node_id].abs end @cache[read_id] = to_return return to_return end |