pangenome / odgi

Optimized Dynamic Genome/Graph Implementation: understanding pangenome graphs
https://doi.org/10.1093/bioinformatics/btac308
MIT License
196 stars 40 forks source link

Python API function divide_handle() can not get the offsets list input #481

Open hahahafeifeifei opened 1 year ago

hahahafeifeifei commented 1 year ago

Hi,

I used the Python API of ODGI to do the graph manipulation and used divide_handle() to split the specific node in the graph. I can successfully get the new handle when input is one offset, such as a=gr.divide_handle(gr.get_handle(146860, True), 2). But when the input is an offsets list, such as a=gr.divide_handle(gr.get_handle(146860, True), [2, 5]), it fails.

The error message is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: divide_handle(): incompatible function arguments. The following argument types are supported:
    1. (self: odgi.graph, arg0: odgi.handle, arg1: std::vector<unsigned long, std::allocator<unsigned long> >) -> std::vector<handlegraph::handle_t, std::allocator<handlegraph::handle_t> >
    2. (self: odgi.graph, arg0: odgi.handle, arg1: int) -> Tuple[odgi.handle, odgi.handle]

Invoked with: <odgi.graph object at 0x150b05d6ce30>, <odgi.handle object at 0x150b05d702f0>, [2, 5]

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

Is there a problem with my command?

Thanks!

ekg commented 1 year ago

Could you give a minimal test case to show how this breaks? Starting from just an empty graph and building up the example.

On Mon, Mar 6, 2023, 09:15 hahahafeifeifei @.***> wrote:

Hi,

I used the Python API of ODGI to do the graph manipulation and used divide_handle() to split the specific node in the graph. I can successfully get the new handle when input is one offset, such as a=gr.divide_handle(gr.get_handle(146860, True), 2). But when the input is an offsets list, such as a=gr.divide_handle(gr.get_handle(146860, True), [2, 5]), it fails.

The error message is:

Traceback (most recent call last): File "", line 1, in TypeError: divide_handle(): incompatible function arguments. The following argument types are supported:

  1. (self: odgi.graph, arg0: odgi.handle, arg1: std::vector<unsigned long, std::allocator >) -> std::vector<handlegraph::handle_t, std::allocator >
  2. (self: odgi.graph, arg0: odgi.handle, arg1: int) -> Tuple[odgi.handle, odgi.handle]

Invoked with: <odgi.graph object at 0x150b05d6ce30>, <odgi.handle object at 0x150b05d702f0>, [2, 5]

Did you forget to #include <pybind11/stl.h>? Or <pybind11/complex.h>, <pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic conversions are optional and require extra headers to be included when compiling your pybind11 module.

Is there a problem with my command?

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/pangenome/odgi/issues/481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABDQELS7RAMBMEEJBUQTSDW2XWRJANCNFSM6AAAAAAVRFXM5Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

hahahafeifeifei commented 1 year ago

Hi Erik!

Thanks for your reply. I use the GFA graph with only one node S 1 AGCATCACCCGGCGACGTTGATGCTGT as the example. Firstly, I use odgi build -g test.gfa -o test.og to build the og file.

Then I use the python API to split this node:

gr=odgi.graph()
gr.load("test.og")
gr.get_sequence(a)
a=gr.get_handle(1,False)
b=gr.divide_handle(a,12)

I can successfully split the node and get the gfa file:

H   VN:Z:1.0
S   2   AGCATCACCCGG
L   2   +   3   +   0M
S   3   CGACGTTGATGCTGT

But if I use the offsets list as the input:

gr=odgi.graph()
gr.load("test.og")
gr.get_sequence(a)
a=gr.get_handle(1,False)
b=gr.divide_handle(a,[12,20])

I get the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: divide_handle(): incompatible function arguments. The following argument types are supported:
    1. (self: odgi.graph, arg0: odgi.handle, arg1: std::vector<unsigned long, std::allocator<unsigned long> >) -> std::vector<handlegraph::handle_t, std::allocator<handlegraph::handle_t> >
    2. (self: odgi.graph, arg0: odgi.handle, arg1: int) -> Tuple[odgi.handle, odgi.handle]

Invoked with: <odgi.graph object at 0x149bcf56cf70>, <odgi.handle object at 0x149bcf56d0f0>, [12, 20]

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included