|
vg
tools for working with variation graphs
|
#include <snarl_manager_decomposition.hpp>
Classes | |
| struct | ChainPosition |
| The place of a chain node in its chain. More... | |
| class | NodeDirectory |
| class | TraversalSet |
| class | TraversalSurvey |
Public Member Functions | |
| SnarlManagerDecomposition (const SnarlManager &manager, const HandleGraph &graph) | |
| ~SnarlManagerDecomposition () override=default | |
| net_handle_t | get_snarl_net (const Snarl *snarl) const |
| Get the start-to-end traversal of a snarl. More... | |
| const Snarl * | get_snarl (const net_handle_t &net) const |
| net_handle_t | get_root () const override |
| bool | is_root (const net_handle_t &net) const override |
| bool | is_snarl (const net_handle_t &net) const override |
| bool | is_chain (const net_handle_t &net) const override |
| bool | is_node (const net_handle_t &net) const override |
| bool | is_sentinel (const net_handle_t &net) const override |
| net_handle_t | get_net (const handle_t &handle, const HandleGraph *handle_graph) const override |
| handle_t | get_handle (const net_handle_t &net, const HandleGraph *handle_graph) const override |
| net_handle_t | get_parent (const net_handle_t &child) const override |
| net_handle_t | get_bound (const net_handle_t &snarl, bool get_end, bool face_in) const override |
| net_handle_t | flip (const net_handle_t &net) const override |
| Flip a traversal, or turn a sentinel to face the other way. More... | |
| net_handle_t | canonical (const net_handle_t &net) const override |
| endpoint_t | starts_at (const net_handle_t &traversal) const override |
| endpoint_t | ends_at (const net_handle_t &traversal) const override |
| net_handle_t | get_parent_traversal (const net_handle_t &traversal_start, const net_handle_t &traversal_end) const override |
Public Member Functions inherited from handlegraph::SnarlDecomposition | |
| virtual | ~SnarlDecomposition ()=default |
| template<typename Iteratee > | |
| bool | for_each_child (const net_handle_t &parent, const Iteratee &iteratee) const |
| template<typename Iteratee > | |
| bool | for_each_traversal (const net_handle_t &item, const Iteratee &iteratee) const |
| template<typename Iteratee > | |
| bool | follow_net_edges (const net_handle_t &here, const HandleGraph *graph, bool go_left, const Iteratee &iteratee) const |
| template<typename Iteratee > | |
| bool | for_each_tippy_child (const net_handle_t &parent, const Iteratee &iteratee) const |
| template<typename Iteratee > | |
| bool | for_each_traversal_start (const net_handle_t &traversal, const Iteratee &) const |
| template<typename Iteratee > | |
| bool | for_each_traversal_end (const net_handle_t &traversal, const Iteratee &) const |
| net_handle_t | get_start_bound (const net_handle_t &parent) const |
| net_handle_t | get_end_bound (const net_handle_t &parent) const |
| bool | starts_at_start (const net_handle_t &net) const |
| bool | starts_at_end (const net_handle_t &net) const |
| bool | starts_at_tip (const net_handle_t &net) const |
| bool | ends_at_start (const net_handle_t &net) const |
| bool | ends_at_end (const net_handle_t &net) const |
| bool | ends_at_tip (const net_handle_t &net) const |
Protected Member Functions | |
| bool | for_each_child_impl (const net_handle_t &traversal, const std::function< bool(const net_handle_t &)> &iteratee) const override |
| bool | for_each_traversal_impl (const net_handle_t &item, const std::function< bool(const net_handle_t &)> &iteratee) const override |
| bool | follow_net_edges_impl (const net_handle_t &here, const HandleGraph *handle_graph, bool go_left, const std::function< bool(const net_handle_t &)> &iteratee) const override |
Protected Member Functions inherited from handlegraph::SnarlDecomposition | |
| virtual bool | for_each_tippy_child_impl (const net_handle_t &parent, const std::function< bool(const net_handle_t &)> &iteratee) const |
| virtual bool | for_each_traversal_start_impl (const net_handle_t &traversal, const std::function< bool(const net_handle_t &)> &iteratee) const |
| virtual bool | for_each_traversal_end_impl (const net_handle_t &traversal, const std::function< bool(const net_handle_t &)> &iteratee) const |
Private Member Functions | |
| Visit | snarl_bound (const Snarl *snarl, bool get_end) const |
| const Snarl * | snarl_of_number (uint64_t number) const |
| Get the manager's Snarl for a snarl number. More... | |
| net_handle_t | snarl_net (const Snarl *snarl, bool forward) const |
| net_handle_t | chain_net (const Chain &chain) const |
| Get a chain's start-to-end net handle. More... | |
| const Chain & | chain_of_net (const net_handle_t &net) const |
| Get the chain that a chain's net handle is for. More... | |
| net_handle_t | chain_node_net (const Chain &chain, size_t position, bool is_reverse) const |
| bool | for_each_snarl_child (const Snarl *parent, const std::function< bool(const net_handle_t &)> &iteratee) const |
| Call a function on each child of a snarl, or of the root if given null. More... | |
| bool | for_each_chain_child (const net_handle_t &traversal, const std::function< bool(const net_handle_t &)> &iteratee) const |
| Call a function on each chain node and snarl of a chain. More... | |
| std::optional< net_handle_t > | next_in_chain (const net_handle_t &here) const |
| net_handle_t | sibling_entered_by (const HandleGraph &graph, const handle_t &handle, const Snarl *parent) const |
| bool | for_each_sibling_ahead (const HandleGraph &graph, const net_handle_t &here, const std::function< bool(const net_handle_t &)> &iteratee) const |
| bool | for_each_traversal_from (const net_handle_t &element, endpoint_t start, const std::function< bool(const net_handle_t &)> &iteratee) const |
| bool | follow_right (const HandleGraph &graph, const net_handle_t &here, const std::function< bool(const net_handle_t &)> &iteratee) const |
| std::pair< net_handle_t, endpoint_t > | parent_endpoint (const net_handle_t &net, bool is_start) const |
| TraversalSet | traversals_of (const net_handle_t &item) const |
Private Attributes | |
| const SnarlManager & | manager |
| The manager whose snarls the view presents. More... | |
| NodeDirectory | directory |
| TraversalSurvey | survey |
Additional Inherited Members | |
Public Types inherited from handlegraph::SnarlDecomposition | |
| enum | endpoint_t { START , END , TIP } |
A view of the snarls and chains in a SnarlManager, through the SnarlDecomposition interface.
A chain alternates chain nodes and snarls, starting and ending with a chain node. Each chain node has a position, counting from 0 at the start bound of the chain. The snarl of rank i lies between the chain nodes at positions i and i + 1.
Each snarl is oriented forward along its chain. So a Snarl that is reversed in parent starts at its end() flipped and ends at its start() flipped.
In a looping chain, the last snarl leads back into the first chain node. That node is both bounds of the chain, and one child at position 0.
Each node that is not a chain node is a free node. It is a trivial chain whose start-to-end traversal visits the node forward.
The view keeps a reference to the manager, which must outlive it and must not change. It does not keep the graph. A graph passed to a method must have the same nodes and edges as the graph the view was made with.
| vg::SnarlManagerDecomposition::SnarlManagerDecomposition | ( | const SnarlManager & | manager, |
| const HandleGraph & | graph | ||
| ) |
Make a view of the snarls in a SnarlManager.
Walk the graph to find which traversals of each snarl and chain are realizable.
| std::invalid_argument | If the manager holds a unary snarl. |
|
overridedefault |
|
overridevirtual |
Get the canonical traversal of a net graph element.
For a snarl, chain or node, pick the first realizable traversal among start-to-end, start-to-tip, end-to-tip, start-to-start, end-to-end and tip-to-tip. For a sentinel, pick its bound facing in.
TODO: An element with no realizable traversal gets start-to-end, but the interface requires the canonical traversal to be realizable. Such elements exist: IntegratedSnarlFinder makes a snarl around a cycle that walks from both of its bounds fall into and never leave.
Implements handlegraph::SnarlDecomposition.
|
private |
Get a chain's start-to-end net handle.
|
private |
Get the net handle for the chain node at a position, oriented in reverse along the chain if is_reverse, and forward along it otherwise.
|
private |
Get the chain that a chain's net handle is for.
|
overridevirtual |
Return the kind of location at which the given traversal ends.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Flip a traversal, or turn a sentinel to face the other way.
Implements handlegraph::SnarlDecomposition.
|
overrideprotectedvirtual |
Call a function on each realizable traversal that comes just after or just before a traversal in its parent.
In a looping chain, going right from the last snarl gives the first chain node.
Implements handlegraph::SnarlDecomposition.
|
private |
Do follow_net_edges() going right.
Find the net graph elements that edges from the end of here lead into, and give each realizable traversal of them that starts at the endpoint the edge leads into.
|
private |
Call a function on each chain node and snarl of a chain.
|
overrideprotectedvirtual |
Call a function on each child of the root, a snarl, a chain or a trivial chain.
The root or a snarl gives its chains in the manager's order, then its free nodes in ID order. A chain traversal other than start-to-end and end-to-start gives the children in chain order, each start-to-end.
Implements handlegraph::SnarlDecomposition.
|
private |
Call a function on each sibling that an edge from the end of a traversal leads into.
A sibling is a chain or trivial chain in the same parent, or a sentinel of the parent facing out. A looping chain, a sentinel facing out, and a traversal that ends at a tip have no siblings ahead.
|
private |
Call a function on each child of a snarl, or of the root if given null.
|
private |
Call a function on each realizable traversal of a net graph element that starts at the given endpoint.
|
overrideprotectedvirtual |
Call a function on each realizable traversal of a net graph element.
Give them ordered by start endpoint, then end endpoint, each in the order START, END, TIP. A sentinel is its own only traversal.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Get a sentinel of a snarl, or a boundary node of a chain.
A looping chain gives its first chain node as both bounds.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Get the graph handle for a node, a trivial chain, or a sentinel.
A sentinel gives its boundary node, oriented the way the sentinel faces.
| std::invalid_argument | If the net handle is for a snarl, the root, or a chain that holds a snarl. |
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Turn a handle to an oriented node into a net handle for a start-to-end or end-to-start traversal of the node, as appropriate.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Get the parent snarl of a chain, or the parent chain of a snarl or node. If the child is start-to-end or end-to-start, and the parent is a chain, the chain comes out facing the same way, accounting for the relative orientation of the child snarl or node in the chain. Otherwise, everything is produced as start-to-end, even if that is not actually a realizable traversal of a snarl or chain. May not be called on the root snarl.
Also works on snarl boundary sentinels.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Get the traversal of a snarl or chain from one of its children or bounds to another.
| std::invalid_argument | If the two arguments are in different snarls or chains, or if the traversal between them is not realizable. |
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Get a net handle referring to a tip-to-tip traversal of the contents of the root snarl. TODO: Special handling for circular things in the root snarl? Circular traversal type?
Implements handlegraph::SnarlDecomposition.
| const Snarl * vg::SnarlManagerDecomposition::get_snarl | ( | const net_handle_t & | net | ) | const |
Get the manager's Snarl for a traversal of a snarl.
| std::invalid_argument | If the net handle is not for a snarl. |
| net_handle_t vg::SnarlManagerDecomposition::get_snarl_net | ( | const Snarl * | snarl | ) | const |
Get the start-to-end traversal of a snarl.
|
overridevirtual |
Returns true if the given net handle refers to (a traversal of) a chain.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Returns true if the given net handle refers to (a traversal of) a single node, and thus has a corresponding handle_t.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Return true if the given handle refers to (a traversal of) the root snarl, and false otherwise.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Return true if the given net handle is a snarl bound sentinel (in either inward or outward orientation), and false otherwise.
Implements handlegraph::SnarlDecomposition.
|
overridevirtual |
Returns true if the given net handle refers to (a traversal of) a snarl.
Implements handlegraph::SnarlDecomposition.
|
private |
Get the next child in a chain after a chain node or snarl.
Return nullopt when here ends at a tip, leaves its chain at a bound, or is a free node.
|
private |
Find the snarl or chain, and its endpoint, where a traversal of it can start or end at a net graph element or sentinel.
| net | One of:
|
| std::invalid_argument | If net is the root, a child of the root, a sentinel facing the wrong way, or a node traversal that does not enter or leave its chain at a bound. |
|
private |
Get the child of a snarl or the root that a handle enters.
If the handle leaves the parent, return the sentinel of the parent for that bound, facing out.
| std::logic_error | If the handle enters a chain between its bounds. |
|
private |
Get a snarl's start bound oriented into the snarl, or its end bound oriented out of it.
|
private |
Get a snarl's net handle, start-to-end if forward and end-to-start otherwise.
|
private |
Get the manager's Snarl for a snarl number.
|
overridevirtual |
Return the kind of location at which the given traversal starts.
Implements handlegraph::SnarlDecomposition.
|
private |
Get the realizable traversals of a net graph element. A sentinel's only traversal is itself.
|
private |
Tells the view each node's place in its chain, and the snarl that contains it.
|
private |
The manager whose snarls the view presents.
|
private |
Tells the view which traversals of each snarl and chain are realizable.
1.9.1