diff --git a/bdsg/cmake_bindings/bdsg/graph_proxy.cpp b/bdsg/cmake_bindings/bdsg/graph_proxy.cpp index 8dbdc45b..51b58d61 100644 --- a/bdsg/cmake_bindings/bdsg/graph_proxy.cpp +++ b/bdsg/cmake_bindings/bdsg/graph_proxy.cpp @@ -1,4 +1,3 @@ -#include <__ostream/basic_ostream.h> #include #include #include @@ -10,11 +9,12 @@ #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/graph_proxy_1.cpp b/bdsg/cmake_bindings/bdsg/graph_proxy_1.cpp index c6d35542..5ec8be43 100644 --- a/bdsg/cmake_bindings/bdsg/graph_proxy_1.cpp +++ b/bdsg/cmake_bindings/bdsg/graph_proxy_1.cpp @@ -1,4 +1,3 @@ -#include <__ostream/basic_ostream.h> #include #include #include @@ -10,11 +9,12 @@ #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include diff --git a/bdsg/cmake_bindings/bdsg/internal/base_packed_graph.cpp b/bdsg/cmake_bindings/bdsg/internal/base_packed_graph.cpp index 9b05b171..6a4dddde 100644 --- a/bdsg/cmake_bindings/bdsg/internal/base_packed_graph.cpp +++ b/bdsg/cmake_bindings/bdsg/internal/base_packed_graph.cpp @@ -1,15 +1,15 @@ -#include <__ostream/basic_ostream.h> #include #include #include #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/internal/eades_algorithm.cpp b/bdsg/cmake_bindings/bdsg/internal/eades_algorithm.cpp index 17eb73e5..59105e96 100644 --- a/bdsg/cmake_bindings/bdsg/internal/eades_algorithm.cpp +++ b/bdsg/cmake_bindings/bdsg/internal/eades_algorithm.cpp @@ -2,9 +2,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/bdsg/cmake_bindings/bdsg/internal/hash_map.cpp b/bdsg/cmake_bindings/bdsg/internal/hash_map.cpp index 28c647f9..5895a74d 100644 --- a/bdsg/cmake_bindings/bdsg/internal/hash_map.cpp +++ b/bdsg/cmake_bindings/bdsg/internal/hash_map.cpp @@ -13,11 +13,11 @@ #include #include #include +#include #include #include // __str__ #include #include -#include #include #include @@ -1041,6 +1041,11 @@ void bind_bdsg_internal_hash_map(std::function< pybind11::module &(std::string c cl.def( pybind11::init( [](){ return new bdsg::wang_hash(); } ) ); cl.def("__call__", (unsigned long (bdsg::wang_hash::*)(const long long &) const) &bdsg::wang_hash::operator(), "C++: bdsg::wang_hash::operator()(const long long &) const --> unsigned long", pybind11::arg("x")); } + { // bdsg::wang_hash file:bdsg/internal/hash_map.hpp line:120 + pybind11::class_, std::shared_ptr>> cl(M("bdsg"), "wang_hash_long_void_t", ""); + cl.def( pybind11::init( [](){ return new bdsg::wang_hash(); } ) ); + cl.def("__call__", (unsigned long (bdsg::wang_hash::*)(const long &) const) &bdsg::wang_hash::operator(), "C++: bdsg::wang_hash::operator()(const long &) const --> unsigned long", pybind11::arg("x")); + } { // bdsg::wang_hash file:bdsg/internal/hash_map.hpp line:120 pybind11::class_, std::shared_ptr>> cl(M("bdsg"), "wang_hash_char_void_t", ""); cl.def( pybind11::init( [](){ return new bdsg::wang_hash(); } ) ); diff --git a/bdsg/cmake_bindings/bdsg/internal/is_single_stranded.cpp b/bdsg/cmake_bindings/bdsg/internal/is_single_stranded.cpp index 13c66a63..80f4ec6d 100644 --- a/bdsg/cmake_bindings/bdsg/internal/is_single_stranded.cpp +++ b/bdsg/cmake_bindings/bdsg/internal/is_single_stranded.cpp @@ -2,9 +2,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/bdsg/cmake_bindings/bdsg/internal/mapped_structs_1.cpp b/bdsg/cmake_bindings/bdsg/internal/mapped_structs_1.cpp index 0dfe15a0..0d53dc05 100644 --- a/bdsg/cmake_bindings/bdsg/internal/mapped_structs_1.cpp +++ b/bdsg/cmake_bindings/bdsg/internal/mapped_structs_1.cpp @@ -1,8 +1,8 @@ -#include <__ostream/basic_ostream.h> #include #include #include #include +#include #include // __str__ #include #include @@ -50,18 +50,18 @@ void bind_bdsg_internal_mapped_structs_1(std::function< pybind11::module &(std:: pybind11::class_, std::shared_ptr>> cl(M("bdsg"), "IntVectorFor_bdsg_CompatBackend_t", ""); cl.def( pybind11::init( [](){ return new bdsg::IntVectorFor(); } ) ); } - { // bdsg::PackedDeque file:bdsg/internal/packed_structs.hpp line:404 + { // bdsg::PackedDeque file:bdsg/internal/packed_structs.hpp line:410 pybind11::class_, std::shared_ptr>> cl(M("bdsg"), "PackedDeque_bdsg_STLBackend_t", ""); cl.def( pybind11::init( [](){ return new bdsg::PackedDeque(); } ) ); cl.def( pybind11::init( [](bdsg::PackedDeque const &o){ return new bdsg::PackedDeque(o); } ) ); cl.def("assign", (class bdsg::PackedDeque<> & (bdsg::PackedDeque::*)(const class bdsg::PackedDeque<> &)) &bdsg::PackedDeque<>::operator=, "C++: bdsg::PackedDeque<>::operator=(const class bdsg::PackedDeque<> &) --> class bdsg::PackedDeque<> &", pybind11::return_value_policy::automatic, pybind11::arg("other")); - cl.def("set", (void (bdsg::PackedDeque::*)(const unsigned long &, const unsigned long long &)) &bdsg::PackedDeque<>::set, "C++: bdsg::PackedDeque<>::set(const unsigned long &, const unsigned long long &) --> void", pybind11::arg("i"), pybind11::arg("value")); - cl.def("get", (unsigned long long (bdsg::PackedDeque::*)(const unsigned long &) const) &bdsg::PackedDeque<>::get, "C++: bdsg::PackedDeque<>::get(const unsigned long &) const --> unsigned long long", pybind11::arg("i")); - cl.def("__getitem__", (unsigned long long (bdsg::PackedDeque::*)(unsigned long) const) &bdsg::PackedDeque<>::operator[], "C++: bdsg::PackedDeque<>::operator[](unsigned long) const --> unsigned long long", pybind11::arg("i")); - cl.def("push_front", (void (bdsg::PackedDeque::*)(const unsigned long long &)) &bdsg::PackedDeque<>::push_front, "C++: bdsg::PackedDeque<>::push_front(const unsigned long long &) --> void", pybind11::arg("value")); - cl.def("append_front", (void (bdsg::PackedDeque::*)(const unsigned long long &)) &bdsg::PackedDeque<>::append_front, "C++: bdsg::PackedDeque<>::append_front(const unsigned long long &) --> void", pybind11::arg("value")); - cl.def("push_back", (void (bdsg::PackedDeque::*)(const unsigned long long &)) &bdsg::PackedDeque<>::push_back, "C++: bdsg::PackedDeque<>::push_back(const unsigned long long &) --> void", pybind11::arg("value")); - cl.def("append_back", (void (bdsg::PackedDeque::*)(const unsigned long long &)) &bdsg::PackedDeque<>::append_back, "C++: bdsg::PackedDeque<>::append_back(const unsigned long long &) --> void", pybind11::arg("value")); + cl.def("set", (void (bdsg::PackedDeque::*)(const unsigned long &, const unsigned long &)) &bdsg::PackedDeque<>::set, "C++: bdsg::PackedDeque<>::set(const unsigned long &, const unsigned long &) --> void", pybind11::arg("i"), pybind11::arg("value")); + cl.def("get", (unsigned long (bdsg::PackedDeque::*)(const unsigned long &) const) &bdsg::PackedDeque<>::get, "C++: bdsg::PackedDeque<>::get(const unsigned long &) const --> unsigned long", pybind11::arg("i")); + cl.def("__getitem__", (unsigned long (bdsg::PackedDeque::*)(unsigned long) const) &bdsg::PackedDeque<>::operator[], "C++: bdsg::PackedDeque<>::operator[](unsigned long) const --> unsigned long", pybind11::arg("i")); + cl.def("push_front", (void (bdsg::PackedDeque::*)(const unsigned long &)) &bdsg::PackedDeque<>::push_front, "C++: bdsg::PackedDeque<>::push_front(const unsigned long &) --> void", pybind11::arg("value")); + cl.def("append_front", (void (bdsg::PackedDeque::*)(const unsigned long &)) &bdsg::PackedDeque<>::append_front, "C++: bdsg::PackedDeque<>::append_front(const unsigned long &) --> void", pybind11::arg("value")); + cl.def("push_back", (void (bdsg::PackedDeque::*)(const unsigned long &)) &bdsg::PackedDeque<>::push_back, "C++: bdsg::PackedDeque<>::push_back(const unsigned long &) --> void", pybind11::arg("value")); + cl.def("append_back", (void (bdsg::PackedDeque::*)(const unsigned long &)) &bdsg::PackedDeque<>::append_back, "C++: bdsg::PackedDeque<>::append_back(const unsigned long &) --> void", pybind11::arg("value")); cl.def("pop_front", (void (bdsg::PackedDeque::*)()) &bdsg::PackedDeque<>::pop_front, "C++: bdsg::PackedDeque<>::pop_front() --> void"); cl.def("pop_back", (void (bdsg::PackedDeque::*)()) &bdsg::PackedDeque<>::pop_back, "C++: bdsg::PackedDeque<>::pop_back() --> void"); cl.def("reserve", (void (bdsg::PackedDeque::*)(const unsigned long &)) &bdsg::PackedDeque<>::reserve, "C++: bdsg::PackedDeque<>::reserve(const unsigned long &) --> void", pybind11::arg("future_size")); @@ -70,14 +70,14 @@ void bind_bdsg_internal_mapped_structs_1(std::function< pybind11::module &(std:: cl.def("clear", (void (bdsg::PackedDeque::*)()) &bdsg::PackedDeque<>::clear, "C++: bdsg::PackedDeque<>::clear() --> void"); cl.def("memory_usage", (unsigned long (bdsg::PackedDeque::*)() const) &bdsg::PackedDeque<>::memory_usage, "C++: bdsg::PackedDeque<>::memory_usage() const --> unsigned long"); } - { // bdsg::PackedSet file:bdsg/internal/packed_structs.hpp line:513 + { // bdsg::PackedSet file:bdsg/internal/packed_structs.hpp line:519 pybind11::class_, std::shared_ptr>> cl(M("bdsg"), "PackedSet_bdsg_STLBackend_t", ""); cl.def( pybind11::init( [](){ return new bdsg::PackedSet(); } ) ); cl.def( pybind11::init( [](bdsg::PackedSet const &o){ return new bdsg::PackedSet(o); } ) ); cl.def("assign", (class bdsg::PackedSet<> & (bdsg::PackedSet::*)(const class bdsg::PackedSet<> &)) &bdsg::PackedSet<>::operator=, "C++: bdsg::PackedSet<>::operator=(const class bdsg::PackedSet<> &) --> class bdsg::PackedSet<> &", pybind11::return_value_policy::automatic, pybind11::arg("other")); - cl.def("insert", (void (bdsg::PackedSet::*)(const unsigned long long &)) &bdsg::PackedSet<>::insert, "C++: bdsg::PackedSet<>::insert(const unsigned long long &) --> void", pybind11::arg("value")); - cl.def("find", (bool (bdsg::PackedSet::*)(const unsigned long long &) const) &bdsg::PackedSet<>::find, "C++: bdsg::PackedSet<>::find(const unsigned long long &) const --> bool", pybind11::arg("value")); - cl.def("remove", (void (bdsg::PackedSet::*)(const unsigned long long &)) &bdsg::PackedSet<>::remove, "C++: bdsg::PackedSet<>::remove(const unsigned long long &) --> void", pybind11::arg("value")); + cl.def("insert", (void (bdsg::PackedSet::*)(const unsigned long &)) &bdsg::PackedSet<>::insert, "C++: bdsg::PackedSet<>::insert(const unsigned long &) --> void", pybind11::arg("value")); + cl.def("find", (bool (bdsg::PackedSet::*)(const unsigned long &) const) &bdsg::PackedSet<>::find, "C++: bdsg::PackedSet<>::find(const unsigned long &) const --> bool", pybind11::arg("value")); + cl.def("remove", (void (bdsg::PackedSet::*)(const unsigned long &)) &bdsg::PackedSet<>::remove, "C++: bdsg::PackedSet<>::remove(const unsigned long &) --> void", pybind11::arg("value")); cl.def("size", (unsigned long (bdsg::PackedSet::*)() const) &bdsg::PackedSet<>::size, "C++: bdsg::PackedSet<>::size() const --> unsigned long"); cl.def("empty", (bool (bdsg::PackedSet::*)() const) &bdsg::PackedSet<>::empty, "C++: bdsg::PackedSet<>::empty() const --> bool"); cl.def("set_load_factors", (void (bdsg::PackedSet::*)(double, double)) &bdsg::PackedSet<>::set_load_factors, "C++: bdsg::PackedSet<>::set_load_factors(double, double) --> void", pybind11::arg("min_load_factor"), pybind11::arg("max_load_factor")); diff --git a/bdsg/cmake_bindings/bdsg/overlays/packed_path_position_overlay.cpp b/bdsg/cmake_bindings/bdsg/overlays/packed_path_position_overlay.cpp index edc24003..62c3df1e 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/packed_path_position_overlay.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/packed_path_position_overlay.cpp @@ -5,10 +5,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/overlays/packed_reference_path_overlay.cpp b/bdsg/cmake_bindings/bdsg/overlays/packed_reference_path_overlay.cpp index 67018282..a8354adf 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/packed_reference_path_overlay.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/packed_reference_path_overlay.cpp @@ -8,10 +8,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/overlays/path_position_overlays.cpp b/bdsg/cmake_bindings/bdsg/overlays/path_position_overlays.cpp index ae0f68a0..d5c5166b 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/path_position_overlays.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/path_position_overlays.cpp @@ -11,10 +11,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/overlays/path_subgraph_overlay.cpp b/bdsg/cmake_bindings/bdsg/overlays/path_subgraph_overlay.cpp index a233cadf..1a0108b9 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/path_subgraph_overlay.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/path_subgraph_overlay.cpp @@ -5,12 +5,10 @@ #include #include #include +#include #include #include // __str__ #include -#include -#include -#include #include #include diff --git a/bdsg/cmake_bindings/bdsg/overlays/reference_path_overlay.cpp b/bdsg/cmake_bindings/bdsg/overlays/reference_path_overlay.cpp index eb7882e3..c0019f96 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/reference_path_overlay.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/reference_path_overlay.cpp @@ -6,10 +6,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/overlays/strand_split_overlay.cpp b/bdsg/cmake_bindings/bdsg/overlays/strand_split_overlay.cpp index 921c1a39..ab973652 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/strand_split_overlay.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/strand_split_overlay.cpp @@ -2,10 +2,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/bdsg/overlays/vectorizable_overlays.cpp b/bdsg/cmake_bindings/bdsg/overlays/vectorizable_overlays.cpp index 7971419e..00ce99c0 100644 --- a/bdsg/cmake_bindings/bdsg/overlays/vectorizable_overlays.cpp +++ b/bdsg/cmake_bindings/bdsg/overlays/vectorizable_overlays.cpp @@ -5,10 +5,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/bdsg/packed_graph.cpp b/bdsg/cmake_bindings/bdsg/packed_graph.cpp index 94ec4ee8..5bc325a8 100644 --- a/bdsg/cmake_bindings/bdsg/packed_graph.cpp +++ b/bdsg/cmake_bindings/bdsg/packed_graph.cpp @@ -1,4 +1,3 @@ -#include <__ostream/basic_ostream.h> #include #include #include @@ -11,11 +10,12 @@ #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include #include diff --git a/bdsg/cmake_bindings/bdsg/snarl_distance_index.cpp b/bdsg/cmake_bindings/bdsg/snarl_distance_index.cpp index a606f738..e6569117 100644 --- a/bdsg/cmake_bindings/bdsg/snarl_distance_index.cpp +++ b/bdsg/cmake_bindings/bdsg/snarl_distance_index.cpp @@ -1,4 +1,3 @@ -#include <__ostream/basic_ostream.h> #include #include #include @@ -7,11 +6,12 @@ #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/expanding_overlay_graph.cpp b/bdsg/cmake_bindings/handlegraph/expanding_overlay_graph.cpp index 804cbdea..2c99fe48 100644 --- a/bdsg/cmake_bindings/handlegraph/expanding_overlay_graph.cpp +++ b/bdsg/cmake_bindings/handlegraph/expanding_overlay_graph.cpp @@ -2,10 +2,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/handle_graph.cpp b/bdsg/cmake_bindings/handlegraph/handle_graph.cpp index 4a500e79..b59b52b8 100644 --- a/bdsg/cmake_bindings/handlegraph/handle_graph.cpp +++ b/bdsg/cmake_bindings/handlegraph/handle_graph.cpp @@ -1,10 +1,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/mutable_path_metadata.cpp b/bdsg/cmake_bindings/handlegraph/mutable_path_metadata.cpp index 671eee18..a59d28c3 100644 --- a/bdsg/cmake_bindings/handlegraph/mutable_path_metadata.cpp +++ b/bdsg/cmake_bindings/handlegraph/mutable_path_metadata.cpp @@ -6,10 +6,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/mutable_path_mutable_handle_graph.cpp b/bdsg/cmake_bindings/handlegraph/mutable_path_mutable_handle_graph.cpp index 1485b7b8..432bd94a 100644 --- a/bdsg/cmake_bindings/handlegraph/mutable_path_mutable_handle_graph.cpp +++ b/bdsg/cmake_bindings/handlegraph/mutable_path_mutable_handle_graph.cpp @@ -1,4 +1,3 @@ -#include <__ostream/basic_ostream.h> #include #include #include @@ -14,11 +13,12 @@ #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/path_handle_graph.cpp b/bdsg/cmake_bindings/handlegraph/path_handle_graph.cpp index b65caf20..ac6541bc 100644 --- a/bdsg/cmake_bindings/handlegraph/path_handle_graph.cpp +++ b/bdsg/cmake_bindings/handlegraph/path_handle_graph.cpp @@ -3,10 +3,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/path_metadata.cpp b/bdsg/cmake_bindings/handlegraph/path_metadata.cpp index 39db277b..69d7c0c4 100644 --- a/bdsg/cmake_bindings/handlegraph/path_metadata.cpp +++ b/bdsg/cmake_bindings/handlegraph/path_metadata.cpp @@ -3,10 +3,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/path_position_handle_graph.cpp b/bdsg/cmake_bindings/handlegraph/path_position_handle_graph.cpp index 5d3a981a..02289a4a 100644 --- a/bdsg/cmake_bindings/handlegraph/path_position_handle_graph.cpp +++ b/bdsg/cmake_bindings/handlegraph/path_position_handle_graph.cpp @@ -4,10 +4,10 @@ #include #include #include +#include #include #include // __str__ #include -#include #include #include diff --git a/bdsg/cmake_bindings/handlegraph/trivially_serializable.cpp b/bdsg/cmake_bindings/handlegraph/trivially_serializable.cpp index d99cc6e8..32bc937c 100644 --- a/bdsg/cmake_bindings/handlegraph/trivially_serializable.cpp +++ b/bdsg/cmake_bindings/handlegraph/trivially_serializable.cpp @@ -1,13 +1,13 @@ -#include <__ostream/basic_ostream.h> #include #include #include #include +#include #include +#include #include // __str__ #include #include -#include #include #include diff --git a/bdsg/cmake_bindings/std/bdsg/internal/binder_hook_bind.cpp b/bdsg/cmake_bindings/std/bdsg/internal/binder_hook_bind.cpp index ea646472..1502dff2 100644 --- a/bdsg/cmake_bindings/std/bdsg/internal/binder_hook_bind.cpp +++ b/bdsg/cmake_bindings/std/bdsg/internal/binder_hook_bind.cpp @@ -1,4 +1,5 @@ #include +#include #include #include // __str__ #include diff --git a/bdsg/docs/assets/simple_nested_chain.dist b/bdsg/docs/assets/simple_nested_chain.dist new file mode 100644 index 00000000..4336a427 Binary files /dev/null and b/bdsg/docs/assets/simple_nested_chain.dist differ diff --git a/bdsg/docs/assets/simple_nested_chain.hg b/bdsg/docs/assets/simple_nested_chain.hg new file mode 100644 index 00000000..29b38fd9 Binary files /dev/null and b/bdsg/docs/assets/simple_nested_chain.hg differ diff --git a/bdsg/docs/assets/simple_nested_chain.png b/bdsg/docs/assets/simple_nested_chain.png new file mode 100644 index 00000000..54c9a26c Binary files /dev/null and b/bdsg/docs/assets/simple_nested_chain.png differ diff --git a/bdsg/docs/assets/simple_nested_chain.svg b/bdsg/docs/assets/simple_nested_chain.svg new file mode 100644 index 00000000..d0fbb0d2 --- /dev/null +++ b/bdsg/docs/assets/simple_nested_chain.svg @@ -0,0 +1,729 @@ + + + + + + + + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + C + + + + + + + + + + + + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + + + + + + Chain 1-10 + + + Snarl 1-4 + + + + Snarl 4-8 + + + + + Chain 5-7 + + + Snarl 5-7 + + + + Snarl 8-10 + + + + + + + + + diff --git a/bdsg/docs/img/exampleGraph.png b/bdsg/docs/img/exampleGraph.png old mode 100755 new mode 100644 index 77e937e7..c30bd6ad Binary files a/bdsg/docs/img/exampleGraph.png and b/bdsg/docs/img/exampleGraph.png differ diff --git a/bdsg/docs/img/exampleGraph.svg b/bdsg/docs/img/exampleGraph.svg new file mode 100644 index 00000000..9ab41f81 --- /dev/null +++ b/bdsg/docs/img/exampleGraph.svg @@ -0,0 +1,566 @@ + + + + + + + + + + + + + CGA + + + + + + TTGG + + + + + + CCGT + + + + + + C + + + + + + GT + + + + + + GATAA + + + + + + CGG + + + + + + ACA + + + + + + GCCG + + + + + + + ATATAAC + + + + + + + + + + + + + + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + + + + diff --git a/bdsg/docs/img/exampleGraphPath.png b/bdsg/docs/img/exampleGraphPath.png old mode 100755 new mode 100644 index 00490248..93fe67fa Binary files a/bdsg/docs/img/exampleGraphPath.png and b/bdsg/docs/img/exampleGraphPath.png differ diff --git a/bdsg/docs/img/simple_nested_chain.png b/bdsg/docs/img/simple_nested_chain.png new file mode 100644 index 00000000..54c9a26c Binary files /dev/null and b/bdsg/docs/img/simple_nested_chain.png differ diff --git a/bdsg/docs/rst/tutorial.rst b/bdsg/docs/rst/tutorial.rst index 4b8f05ef..7b2238b3 100644 --- a/bdsg/docs/rst/tutorial.rst +++ b/bdsg/docs/rst/tutorial.rst @@ -8,26 +8,34 @@ Tutorial import os os.chdir('exdata') -**************** -Creating Graphs -**************** -Let's say that you wanted to create the following graph: - -.. image:: /img/exampleGraph.png - -This graph is a combination of nodes (labelled as `n0`, `n1`, ..., `n9`) and directed edges (arrows). +************* +Preliminaries +************* +See the `vg wiki `_ for an explanation of our variation graph data model. Graph Objects ============= +`libbdsg` implements the `handlegraph `_ interface in which all objects in the graph are accessed using `handles `_. +The most basic graphs implement the :class:`bdsg.handlegraph.HandleGraph` interface, which defines a graph containing nodes and edges. +Individual nodes in the graph are pointed at by :class:`bdsg.handlegraph.handle_t` objects. +Graph implementations can include additional `handlegraph` interfaces to add additional graph features and functionality. -*Edges* and *nodes* are accessed through an implementation of the :class:`bdsg.handlegraph.HandleGraph` interface. Individual nodes in the graph are pointed at by :class:`bdsg.handlegraph.handle_t` objects. - -Paths exist in graphs that implement the :class:`bdsg.handlegraph.PathHandleGraph`. Paths are accessed through :class:`bdsg.handlegraph.path_handle_t`, which is a series of :class:`bdsg.handlegraph.step_handle_t` linked together. Each :class:`bdsg.handlegraph.step_handle_t` points to the node in that step, and also contains directional information regarding the nodes preceeding and following it. +Paths exist in graphs that implement the :class:`bdsg.handlegraph.PathHandleGraph`. Paths are accessed through :class:`bdsg.handlegraph.path_handle_t`, which is a series of :class:`bdsg.handlegraph.step_handle_t` linked together. Each :class:`bdsg.handlegraph.step_handle_t` points to the node traversal along a path, and also contains directional information regarding the nodes preceding and following it. Handles are pointers to specific pieces of the graph, and it is not possible to operate on them directly, aside from comparing whether the objects are equal. To get information regarding the object that each handle is pointing to, it is necessary to use the corresponding `get` accessor method on the graph that issued the handle. Reference materials for these methods can be found at the :ref:`api`, as well as the :ref:`glossary`, which contains lists sorted by object type for :ref:`accessor`, :ref:`mutator`, and :ref:`iterator`. + +**************** +Creating Graphs +**************** +Let's say that you wanted to create the following graph: + +.. image:: /img/exampleGraph.png + +This graph is a combination of nodes (labelled as `n1`, `n2`, ..., `n10`) and bidirected edges. + Making a Graph =============== First, we must create the graph, then make each node and keep track of their handles. We're going to be using the **HashGraph**, :class:`bdsg.bdsg.HashGraph`, which is a good all-around graph that implements :class:`bdsg.handlegraph.MutablePathDeletableHandleGraph`. @@ -37,28 +45,29 @@ First, we must create the graph, then make each node and keep track of their han from bdsg.bdsg import HashGraph gr = HashGraph() seq = ["CGA", "TTGG", "CCGT", "C", "GT", "GATAA", "CGG", "ACA", "GCCG", "ATATAAC"] - n = [] + n = ["node0"] #Add a placeholder so that the indices are the same as the node ids for s in seq: n.append(gr.create_handle(s)) -Now we link together these nodes using their handles. Note that each of these handles is directional, and we create each edge from the first handle to the second. In order to create both of the edges between `n5` and `n8` (since each can follow the other) we use ``create_edge`` twice. +Now we link together these nodes using their handles. Note that each of these handles is directional, and we create each edge from the first handle traversing the node in the forward direction to the second handle, also traversed in the forward direction. In order to create both of the edges between `n7` and `n9` we use ``create_edge`` twice, once going from `n7` to `n9`, and once going from `n9` to `n7`. +Since the handles are all traversing nodes in the forward orientation by default, this creates the edge from the right side of `n7` to the left side of `n9`, then from the right side of `n9` to the left side of `n7`. .. testcode:: - gr.create_edge(n[0], n[1]) gr.create_edge(n[1], n[2]) gr.create_edge(n[2], n[3]) - gr.create_edge(n[2], n[4]) + gr.create_edge(n[3], n[4]) gr.create_edge(n[3], n[5]) - gr.create_edge(n[5], n[6]) - # Connect the end of n5 to the start of n8 - gr.create_edge(n[5], n[8]) + gr.create_edge(n[4], n[6]) gr.create_edge(n[6], n[7]) - gr.create_edge(n[6], n[8]) + # Connect the end of n7 to the start of n9 gr.create_edge(n[7], n[9]) - gr.create_edge(n[8], n[9]) - # Connect the end of n8 back around to the start of n5 - gr.create_edge(n[8], n[5]) + gr.create_edge(n[7], n[8]) + gr.create_edge(n[7], n[9]) + gr.create_edge(n[8], n[10]) + gr.create_edge(n[9], n[10]) + # Connect the end of n9 back around to the start of n7 + gr.create_edge(n[9], n[7]) Traversing Edges ================ @@ -71,40 +80,40 @@ If we wanted to traverse these edges, we could do it using the iterator method : gr.follow_edges(handle, False, lambda y: lis.append(y)) return lis - print(f'n0: {gr.get_sequence(n[0])}') - next_node = next_node_list(n[0])[0] - print(f'n1: {gr.get_sequence(next_node)}') - next_node = next_node_list(next_node)[0] + print(f'n1: {gr.get_sequence(n[1])}') + next_node = next_node_list(n[1])[0] print(f'n2: {gr.get_sequence(next_node)}') + next_node = next_node_list(next_node)[0] + print(f'n3: {gr.get_sequence(next_node)}') Which will output the following: .. testoutput:: - n0: CGA - n1: TTGG - n2: CCGT + n1: CGA + n2: TTGG + n3: CCGT Creating a Path =============== -Generating a linear sequence from this graph could be done in infinitely many ways, due to the interal loop between `n5`, `n6`, and `n8`. If we wanted to define a single consensus sequence, we would do this by defining a path. +Generating a linear sequence from this graph could be done in infinitely many ways, due to the internal loop between `n7`, and `n9`. If we wanted to define a single sequence, for example to represent a reference haplotype in the graph, we would do this by defining a path. .. image:: /img/exampleGraphPath.png -To create the hilighted path, we would need to create a :class:`bdsg.handlegraph.path_handle_t` in the graph, and then append each :class:`bdsg.handlegraph.handle_t` to the end of the path. +To create the highlighted path, we would need to create a :class:`bdsg.handlegraph.path_handle_t` in the graph, and then append each :class:`bdsg.handlegraph.handle_t` to the end of the path. .. testcode:: path = gr.create_path_handle("path") - gr.append_step(path, n[0]) gr.append_step(path, n[1]) gr.append_step(path, n[2]) - gr.append_step(path, n[4]) + gr.append_step(path, n[3]) gr.append_step(path, n[5]) gr.append_step(path, n[6]) gr.append_step(path, n[7]) - gr.append_step(path, n[9]) + gr.append_step(path, n[8]) + gr.append_step(path, n[10]) .. warning:: @@ -114,8 +123,8 @@ To create the hilighted path, we would need to create a :class:`bdsg.handlegraph # the following code runs without error badpath = gr.create_path_handle("badpath") - gr.append_step(badpath, n[0]) - gr.append_step(badpath, n[3]) + gr.append_step(badpath, n[1]) + gr.append_step(badpath, n[4]) Traversing a path ================= @@ -148,6 +157,266 @@ Which will output the following: ACA ATATAAC +******************** +Using Graph Overlays +******************** + +The libhandlegraph library defines generic graph interfaces that describe different functionalities of a graph. +Some of these functionalities are part of the `libbdsg` graph implementations while others must be added on top of an existing graph using an *overlay*. +For example, the :class:`bdsg.handlegraph.PathPositionHandleGraph` defines an interface for accessing the sequence positions along paths in a graph. +The :class:`bdsg.bdsg.PositionOverlay` and :class:`bdsg.bdsg.ReferencePathOverlay` are two different implementations of overlays that can be applied to a graph to add this functionality. +In C++, :class:`bdsg.bdsg.OverlayHelpers` are used to add specific combinations of overlays to graphs. + +bdsg.bdsg.PositionOverlay +========================= + +A :class:`bdsg.bdsg.PositionOverlay` adds the :class:`bdsg.handlegraph.PathPositionHandleGraph` functionality to a graph, allowing it to find the sequence positions along paths. +For example, using the same example graph as above, say we want to find the offsets along all paths that traverse node `n6`. +First, we'll add a second path to make this more interesting. + +.. testcode:: + + path = gr.create_path_handle("path1") + gr.append_step(path, n[1]) + gr.append_step(path, n[2]) + gr.append_step(path, n[3]) + gr.append_step(path, n[4]) + gr.append_step(path, n[6]) + gr.append_step(path, n[7]) + gr.append_step(path, n[9]) + gr.append_step(path, n[7]) + gr.append_step(path, n[9]) + gr.append_step(path, n[10]) + +We do this by creating a `bdsg.bdsg.PositionOverlay`, then getting a `bdsg.handlegraph.step_handle_t` that points to the node `n7` on the path `path`. +The `bdsg.bdsg.PositionOverlay` can be queried using :func:`bdsg.handlegraph.get_position_of_step` to find the position of the given step. + +.. testcode:: + from bdsg.bdsg import PositionOverlay + + # Get the overlay + position_graph = PositionOverlay(gr) + + # Helper function that prints the path name and offset along the path of a step + def print_step(step) : + print(gr.get_path_name(gr.get_path_handle_of_step(step)), position_graph.get_position_of_step(step)) + return True + + # Run print_step() for each step on node n7 + gr.for_each_step_on_handle(nodes[7], print_step) + + +.. testoutput:: + + 17 + 21 + +************************************************************ +Using a SnarlDistanceIndex to Traverse a Snarl Decomposition +************************************************************ + +A :class:`bdsg.bdsg.SnarlDistanceIndex` implements the :class:`bdsg.handlegraph.SnarlDecomposition` interface and additionally adds minimum distance finding functionality. +It can be used to explore the snarl decomposition of a graph. +Similar to a :class:`bdsg.handlegraph.handle_t` used to point to a node in a graph, a :class:`bdsg.handlegraph.net_handle_t` is used to point to a node in the snarl tree, which represents a snarl, chain, or node in the graph. +The snarl decomposition is described in more detail in the `vg wiki snarls page `_. + +libbdsg does not support building a distance index, it must be build using the `vg toolkit `_. + +.. code-block:: bash + + vg index -j example_graph.dist example_graph.hg + + +We will use the following graph and corresponding distance index for this example. + +.. image:: /img/simple_nested_chain.png + +Start by loading the distance index. + +.. testcode:: + + from bdsg.bdsg import SnarlDistanceIndex + from bdsg.bdsg import HashGraph + + distance_index = SnarlDistanceIndex() + distance_index.deserialize("/assets/simple_nested_chain.dist") + + graph = bdsg.bdsg.HashGraph() + graph.deserialize("/assets/simple_nested_chain.hg") + + + +Finding Ancestors in a Snarl Tree +================================= + +Starting from a node in the graph, its ancestors in the snarl decomposition can be found using :func:`bdsg.handlegraph.SnarlDecomposition.get_parent`. +Lets look for the ancestors of node `n6` in the snarl decomposition. + +.. testcode:: + + net = distance_index.get_node_net_handle(6) + while not distance_index.is_root(net): + print(distance_index.net_handle_as_string(net)) + net = distance_index.get_parent(net) + +.. testoutput:: + + node 6fd + node 6fd pretending to be a chain in a simple snarl + simple snarl 5fd->7fdtraversing start->end + chain 5fd->7fdtraversing start->end + snarl 4fd->8fdtraversing start->end + chain 1fd->10fdtraversing start->end + +In the snarl decomposition, a node is always the child of a chain, which may contain only that node. +Node `n6` therefore has a parent that is a chain containing only node `n6`. + + +Finding Descendants in a Snarl Tree +=================================== + +Now lets go in the other direction, finding the descendants of a net, starting from the root. + +.. testcode:: + + root = distance_index.get_root() + + children = [] + def get_and_print_child(net): + nonlocal children + print(distance_index.net_handle_as_string(net)) + children.append(net) + return True + success = distance_index.for_each_child(root, get_and_print_child) + + chain = children[0] + success = distance_index.for_each_child(chain, get_and_print_child) + +.. testoutput:: + + chain 1fd->10fdtraversing start->end + node 1fd + simple snarl 1fd->4fdtraversing start->end + node 4fd + snarl 4fd->8fdtraversing start->end + node 8fd + simple snarl 8fd->10fdtraversing start->end + node 10fd + +The root contains only one child, the top-level chain. +The top-level chain contains node 1, snarl 1-4, node 4, etc. +This produces: + + + +Finding Siblings in a Snarl Tree +================================ + +Now lets traverse the snarl tree horizontally to get the siblings of a :class:`bdsg.handlegraph.net_handle_t`. +This is done using :func:`bdsg.handlegraph.SnarlDecomposition.follow_net_edges`. +Starting from a node or snarl in a chain, we can use this function to walk through the chain in either direction. + +Be careful of which direction you are traversing in. +A :class:`bdsg.handlegraph.net_handle_t` encodes an orientation. +For a node, the orientation is relative to the orientation of the node. That is, a forward or left-to-right :class:`bdsg.handlegraph.net_handle_t` represents a left-to-right traversal of the node. +For a chain, the orientation is arbitrary- either of the boundary nodes could be considered the start or end node. +For a snarl, the orientation is relative to that of the parent chain. The start node of a snarl is the node that occurs first in a start-to-end traversal of the parent chain. + + +Starting from a :class:`bdsg.handlegraph.net_handle_t` to a chain, we can get the start or end node with :func:`bdsg.handlegraph.SnarlDecomposition.get_bound`. +:func:`bdsg.handlegraph.SnarlDecomposition.get_bound` takes as input a boolean `get_end` which is `True` to get the end bound and `False` to get the start bound, and a boolean `face_in` which decides whether to orient the node into or out of the chain. + +.. testcode:: + + chain = distance_index.get_parent(distance_index.get_node_net_handle(1)) + chain_child = distance_index.get_bound(chain, False, True) + print(distance_index.net_handle_as_string(chain_child)) + +.. testoutput:: + + node 1fd + +In this particular case, the start node of the chain happens to be node `n1`. + + +Now we can check the next node in the chain by walking along the chain from the node. +:func:`bdsg.handlegraph.SnarlDecomposition.follow_net_edges` checks all next steps from a given :class:`bdsg.handlegraph.net_handle_t` and runs a helper function on each adjacent :class:`bdsg.handlegraph.net_handle_t` that it finds. +When walking along a chain, there is only ever a maximum of one adjacent :class:`bdsg.handlegraph.net_handle_t`. + +.. testcode:: + + next_children = [] + def get_and_print_child(net): + print(distance_index.net_handle_as_string(net)) + next_children.append(net) + return True + success = distance_index.follow_net_edges(chain_child, graph, False, get_and_print_child) + chain_child = next_children.pop() + success = distance_index.follow_net_edges(chain_child, graph, False, get_and_print_child) + chain_child = next_children.pop() + success = distance_index.follow_net_edges(chain_child, graph, False, get_and_print_child) + chain_child = next_children.pop() + +.. testoutput:: + + simple snarl 1fd->4fdtraversing start->end + node 4fd + snarl 4fd->8fdtraversing start->end + +The same functions can be used to traverse a snarl. +Since the bound of a snarl is technically a node side rather than a node, `get_bound` on a snarl returns a *sentinel* representing the bound of the snarl. +:func:`bdsg.handlegraph.SnarlDecomposition.follow_net_edges` now checks all next adjacent edges in the snarl's netgraph. +Thus starting from the start bound of snarl 4-8 (the right side of node `n4`), there are two adjacent edges leading to chain 5-8 and to the end bound, the left side of node `n8`. + +.. testcode:: + + # chain_child is currently snarl 4-8 + snarl_bound = distance_index.get_bound(chain_child, False, True) + print(distance_index.net_handle_as_string(snarl_bound)) + + print("children of snarl:") + next_children.clear() + success = distance_index.follow_net_edges(snarl_bound, graph, False, get_and_print_child) + +.. testoutput:: + + sentinel of snarl 4fd->8fdtraversing start->end + children of snarl: + sentinel of snarl 4fd->8fdtraversing end->end + chain 5fd->7fdtraversing start->end + +Note that the `follow_net_edges` follows in edges in the netgraph of the snarl, so it only returns siblings of the input :class:`bdsg.handlegraph.net_handle_t`. +Since the input was the bound of the snarl, only children of the snarl will be returned. +Thus we find the chain 5-7 rather than the node `n5`. + +We can continue use `follow_net_edges` to find all edges in a netgraph. + +.. testcode:: + + def print_snarl_edges(snarl): + def print_edge_to(n): + print("\t->"+distance_index.net_handle_as_string(n)) + return True + def print_outgoing_edges(n): + print(distance_index.net_handle_as_string(n)) + distance_index.follow_net_edges(n, graph, False, print_edge_to) + + print(distance_index.net_handle_as_string(distance_index.flip(n))) + distance_index.follow_net_edges(n, graph, True, print_edge_to) + return True + + distance_index.for_each_child(snarl, print_outgoing_edges) + print_snarl_edges(distance_index.get_parent(next_children[1])) + + +.. testoutput:: + + chain 5fd->7fdtraversing start->end + ->sentinel of snarl 4fd->8fdtraversing end->end + chain 5fd->7fdtraversing end->start + ->sentinel of snarl 4fd->8fdtraversing start->start + + ************************* Saving and Loading Graphs *************************