Skip to content

Commit

Permalink
Add basic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Aug 22, 2024
1 parent d8a222e commit 98d5fc9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 11 deletions.
64 changes: 57 additions & 7 deletions ext/odgi/odgi.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,66 @@
#include <rice/rice.hpp>
#include <rice/stl.hpp>

#include "odgi-api.h"

using namespace Rice;

String rb_odgi_version() {
return detail::to_ruby(odgi_version());
}

extern "C" void Init_odgi()
{
define_module("Odgi")
.define_module_function("odgi_version", &rb_odgi_version);
Module rb_mODGI = define_module("ODGI");
Module rb_cFFI = define_module_under(rb_mODGI, "FFI");
Class rb_cGraph = define_class_under<graph_t>(rb_cFFI, "Graph");
Class rb_cHandle = define_class_under<handle_t>(rb_cFFI, "Handle");
Class rb_cPathHandle = define_class_under<path_handle_t>(rb_cFFI, "PathHandle");
Class rb_cStepHandle = define_class_under<step_handle_t>(rb_cFFI, "StepHandle");
Class rb_cEdgeHandle = define_class_under<edge_t>(rb_cFFI, "EdgeHandle");

rb_cFFI
.define_singleton_function("odgi_version", &odgi_version)
.define_singleton_function("odgi_long_long_size", &odgi_long_long_size)
.define_singleton_function("odgi_handle_i_size", &odgi_handle_i_size)
.define_singleton_function("odgi_step_handle_i_size", &odgi_step_handle_i_size)
.define_singleton_function("odgi_load_graph", &odgi_load_graph)
.define_singleton_function("odgi_free_graph", &odgi_free_graph)
.define_singleton_function("odgi_get_node_count", &odgi_get_node_count)
.define_singleton_function("odgi_max_node_id", &odgi_max_node_id)
.define_singleton_function("odgi_min_node_id", &odgi_min_node_id)
.define_singleton_function("odgi_get_path_count", &odgi_get_path_count)
// .define_singleton_function("odgi_for_each_path_handle", &odgi_for_each_path_handle)
// .define_singleton_function("odgi_for_each_handle", &odgi_for_each_handle)
// .define_singleton_function("odgi_follow_edges", &odgi_follow_edges)
.define_singleton_function("odgi_edge_first_handle", &odgi_edge_first_handle)
.define_singleton_function("odgi_edge_second_handle", &odgi_edge_second_handle)
.define_singleton_function("odgi_has_node", &odgi_has_node)
.define_singleton_function("odgi_get_sequence", &odgi_get_sequence)
.define_singleton_function("odgi_get_id", &odgi_get_id)
.define_singleton_function("odgi_get_is_reverse", &odgi_get_is_reverse)
.define_singleton_function("odgi_get_length", &odgi_get_length)
.define_singleton_function("odgi_has_path", &odgi_has_path)
.define_singleton_function("odgi_path_is_empty", &odgi_path_is_empty)
.define_singleton_function("odgi_get_path_handle", &odgi_get_path_handle)
.define_singleton_function("odgi_get_step_count", &odgi_get_step_count)
.define_singleton_function("odgi_get_handle_of_step", &odgi_get_handle_of_step)
.define_singleton_function("odgi_get_path", &odgi_get_path)
.define_singleton_function("odgi_path_begin", &odgi_path_begin)
.define_singleton_function("odgi_path_end", &odgi_path_end)
.define_singleton_function("odgi_path_back", &odgi_path_back)
.define_singleton_function("odgi_step_path_id", &odgi_step_path_id)
.define_singleton_function("odgi_step_is_reverse", &odgi_step_is_reverse)
.define_singleton_function("odgi_step_prev_id", &odgi_step_prev_id)
.define_singleton_function("odgi_step_prev_rank", &odgi_step_prev_rank)
.define_singleton_function("odgi_step_next_id", &odgi_step_next_id)
.define_singleton_function("odgi_step_next_rank", &odgi_step_next_rank)
.define_singleton_function("odgi_step_eq", &odgi_step_eq)
.define_singleton_function("odgi_path_front_end", &odgi_path_front_end)
.define_singleton_function("odgi_get_next_step", &odgi_get_next_step)
.define_singleton_function("odgi_get_previous_step", &odgi_get_previous_step)
.define_singleton_function("odgi_has_edge", &odgi_has_edge)
.define_singleton_function("odgi_is_path_front_end", &odgi_is_path_front_end)
.define_singleton_function("odgi_is_path_end", &odgi_is_path_end)
.define_singleton_function("odgi_has_next_step", &odgi_has_next_step)
.define_singleton_function("odgi_has_previous_step", &odgi_has_previous_step)
.define_singleton_function("odgi_get_path_handle_of_step", &odgi_get_path_handle_of_step)
// .define_singleton_function("odgi_for_each_step_in_path", &odgi_for_each_step_in_path)
// .define_singleton_function("odgi_for_each_step_on_handle", &odgi_for_each_step_on_handle)
.define_singleton_function("odgi_get_path_name", &odgi_get_path_name);
}
2 changes: 1 addition & 1 deletion lib/odgi/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Odgi
module ODGI
VERSION = '0.0.0'
end
2 changes: 1 addition & 1 deletion odgi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require_relative 'lib/odgi/version'

Gem::Specification.new do |spec|
spec.name = 'odgi'
spec.version = Odgi::VERSION
spec.version = ODGI::VERSION
spec.authors = ['kojix2']
spec.email = ['[email protected]']

Expand Down
11 changes: 9 additions & 2 deletions test/odgi_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

class OdgiTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Odgi::VERSION
refute_nil ::ODGI::VERSION
end

def test_odgi_version
assert_kind_of String, Odgi.odgi_version
assert_kind_of String, ODGI::FFI.odgi_version
end

def test_odgi_load_graph
graph = ODGI::FFI.odgi_load_graph(
File.join(File.dirname(__dir__), "odgi", "test", "DRB1-3123_sorted.og")
)
assert_kind_of ODGI::FFI::Graph, graph
end
end

0 comments on commit 98d5fc9

Please sign in to comment.