Sorted Glossary of Methods

This page divides the Handle Graph API methods by category. It is written in terms of the Python methods, but applies equally well to the C++ interface.

Mutator Methods

The following lists breaks out methods from the various handle graph interfaces by what types of objects they modify.

Node Mutators

bdsg.handlegraph.MutableHandleGraph

bdsg.handlegraph.MutableHandleGraph.create_handle(*args, **kwargs)

Overloaded function.

  1. create_handle(self: bdsg.handlegraph.MutableHandleGraph, sequence: str) -> bdsg.handlegraph.handle_t

Create a new node with the given sequence and return the handle.

The sequence may not be empty.

C++: handlegraph::MutableHandleGraph::create_handle(const std::string &) –> struct handlegraph::handle_t

  1. create_handle(self: bdsg.handlegraph.MutableHandleGraph, sequence: str, id: int) -> bdsg.handlegraph.handle_t

Create a new node with the given id and sequence, then return the handle.

The sequence may not be empty. The ID must be strictly greater than 0.

C++: handlegraph::MutableHandleGraph::create_handle(const std::string &, const long long &) –> struct handlegraph::handle_t

bdsg.handlegraph.MutableHandleGraph.divide_handle(*args, **kwargs)

Overloaded function.

  1. divide_handle(self: bdsg.handlegraph.MutableHandleGraph, handle: bdsg.handlegraph.handle_t, offsets: bdsg.std.vector_unsigned_long) -> bdsg.std.vector_handlegraph_handle_t

Split a handle’s underlying node at the given offsets in the handle’s

orientation. Returns all of the handles to the parts. Other handles to the node being split may be invalidated. The split pieces stay in the same local forward orientation as the original node, but the returned handles come in the order and orientation appropriate for the handle passed in. Updates stored paths. This invalidates the passed handles, but not other handles.

C++: handlegraph::MutableHandleGraph::divide_handle(const struct handlegraph::handle_t &, const class std::vector<unsigned long> &) –> class std::vector<handlegraph::handle_t>

  1. divide_handle(self: bdsg.handlegraph.MutableHandleGraph, handle: bdsg.handlegraph.handle_t, offset: int) -> Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]

Specialization of divide_handle for a single division point

C++: handlegraph::MutableHandleGraph::divide_handle(const struct handlegraph::handle_t &, unsigned long) –> struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t>

bdsg.handlegraph.MutableHandleGraph.apply_orientation(self: bdsg.handlegraph.MutableHandleGraph, handle: bdsg.handlegraph.handle_t) bdsg.handlegraph.handle_t
Alter the node that the given handle corresponds to so the orientation

indicated by the handle becomes the node’s local forward orientation. Rewrites all edges pointing to the node and the node’s sequence to reflect this. Invalidates all handles to the node (including the one passed). Returns a new, valid handle to the node in its new forward orientation. Note that it is possible for the node’s ID to change. Does not update any stored paths. May change the ordering of the underlying graph.

C++: handlegraph::MutableHandleGraph::apply_orientation(const struct handlegraph::handle_t &) –> struct handlegraph::handle_t

bdsg.handlegraph.DeletableHandleGraph

bdsg.handlegraph.DeletableHandleGraph.destroy_handle(self: bdsg.handlegraph.DeletableHandleGraph, handle: bdsg.handlegraph.handle_t) None
Remove the node belonging to the given handle and all of its edges.

Either destroys any paths in which the node participates, or leaves a “hidden”, un-iterateable handle in the path to represent the sequence of the removed node. Invalidates the destroyed handle. May be called during serial for_each_handle iteration ONLY on the node being iterated. May NOT be called during parallel for_each_handle iteration. May NOT be called on the node from which edges are being followed during follow_edges. May NOT be called during iteration over paths, if it could destroy a path. May NOT be called during iteration along a path, if it could destroy that path.

C++: handlegraph::DeletableHandleGraph::destroy_handle(const struct handlegraph::handle_t &) –> void

Edge Mutators

bdsg.handlegraph.MutableHandleGraph

bdsg.handlegraph.MutableHandleGraph.create_edge(*args, **kwargs)

Overloaded function.

  1. create_edge(self: bdsg.handlegraph.MutableHandleGraph, left: bdsg.handlegraph.handle_t, right: bdsg.handlegraph.handle_t) -> None

Create an edge connecting the given handles in the given order and orientations.

Ignores existing edges.

C++: handlegraph::MutableHandleGraph::create_edge(const struct handlegraph::handle_t &, const struct handlegraph::handle_t &) –> void

  1. create_edge(self: bdsg.handlegraph.MutableHandleGraph, edge: Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]) -> None

Convenient wrapper for create_edge.

C++: handlegraph::MutableHandleGraph::create_edge(const struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t> &) –> void

bdsg.handlegraph.DeletableHandleGraph

bdsg.handlegraph.DeletableHandleGraph.destroy_edge(*args, **kwargs)

Overloaded function.

  1. destroy_edge(self: bdsg.handlegraph.DeletableHandleGraph, left: bdsg.handlegraph.handle_t, right: bdsg.handlegraph.handle_t) -> None

Remove the edge connecting the given handles in the given order and orientations.

Ignores nonexistent edges. Does not update any stored paths.

C++: handlegraph::DeletableHandleGraph::destroy_edge(const struct handlegraph::handle_t &, const struct handlegraph::handle_t &) –> void

  1. destroy_edge(self: bdsg.handlegraph.DeletableHandleGraph, edge: Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]) -> None

Convenient wrapper for destroy_edge.

C++: handlegraph::DeletableHandleGraph::destroy_edge(const struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t> &) –> void

Path Mutators

bdsg.handlegraph.MutablePathHandleGraph

bdsg.handlegraph.MutablePathHandleGraph.create_path_handle(*args, **kwargs)

Overloaded function.

  1. create_path_handle(self: bdsg.handlegraph.MutablePathHandleGraph, name: str) -> bdsg.handlegraph.path_handle_t

  2. create_path_handle(self: bdsg.handlegraph.MutablePathHandleGraph, name: str, is_circular: bool) -> bdsg.handlegraph.path_handle_t

Create a path with the given name. The caller must ensure that no path

with the given name exists already, or the behavior is undefined. Returns a handle to the created empty path. Handles to other paths must remain valid.

C++: handlegraph::MutablePathHandleGraph::create_path_handle(const std::string &, bool) –> struct handlegraph::path_handle_t

bdsg.handlegraph.MutablePathHandleGraph.set_circularity(self: bdsg.handlegraph.MutablePathHandleGraph, path: bdsg.handlegraph.path_handle_t, circular: bool) None
Make a path circular or non-circular. If the path is becoming circular, the

last step is joined to the first step. If the path is becoming linear, the step considered “last” is unjoined from the step considered “first” according to the method path_begin.

C++: handlegraph::MutablePathHandleGraph::set_circularity(const struct handlegraph::path_handle_t &, bool) –> void

bdsg.handlegraph.MutablePathHandleGraph.destroy_path(self: bdsg.handlegraph.MutablePathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) None

Destroy the given path. Invalidates handles to the path and its steps.

C++: handlegraph::MutablePathHandleGraph::destroy_path(const struct handlegraph::path_handle_t &) –> void

Path Step Mutators

bdsg.handlegraph.MutablePathHandleGraph

bdsg.handlegraph.MutablePathHandleGraph.append_step(self: bdsg.handlegraph.MutablePathHandleGraph, path: bdsg.handlegraph.path_handle_t, to_append: bdsg.handlegraph.handle_t) bdsg.handlegraph.step_handle_t
Append a visit to a node to the given path. Returns a handle to the new

final step on the path which is appended. If the path is cirular, the new step is placed between the steps considered “last” and “first” by the method path_begin. Handles to prior steps on the path, and to other paths, must remain valid.

C++: handlegraph::MutablePathHandleGraph::append_step(const struct handlegraph::path_handle_t &, const struct handlegraph::handle_t &) –> struct handlegraph::step_handle_t

bdsg.handlegraph.MutablePathHandleGraph.prepend_step(self: bdsg.handlegraph.MutablePathHandleGraph, path: bdsg.handlegraph.path_handle_t, to_prepend: bdsg.handlegraph.handle_t) bdsg.handlegraph.step_handle_t
Prepend a visit to a node to the given path. Returns a handle to the new

first step on the path which is appended. If the path is cirular, the new step is placed between the steps considered “last” and “first” by the method path_begin. Handles to later steps on the path, and to other paths, must remain valid.

C++: handlegraph::MutablePathHandleGraph::prepend_step(const struct handlegraph::path_handle_t &, const struct handlegraph::handle_t &) –> struct handlegraph::step_handle_t

bdsg.handlegraph.MutablePathHandleGraph.rewrite_segment(self: bdsg.handlegraph.MutablePathHandleGraph, segment_begin: bdsg.handlegraph.step_handle_t, segment_end: bdsg.handlegraph.step_handle_t, new_segment: bdsg.std.vector_handlegraph_handle_t) Tuple[bdsg.handlegraph.step_handle_t, bdsg.handlegraph.step_handle_t]
Delete a segment of a path and rewrite it as some other sequence of

steps. Returns a pair of step_handle_t’s that indicate the range of the new segment in the path. The segment to delete should be designated by the first (begin) and past-last (end) step handles. If the step that is returned by path_begin is deleted, path_begin will now return the first step from the new segment or, in the case that the new segment is empty, the step used as segment_end. Empty ranges consist of two copies of the same step handle. Empty ranges in empty paths consist of two copies of the end sentinel handle for the path. Rewriting an empty range inserts before the provided end handle.

C++: handlegraph::MutablePathHandleGraph::rewrite_segment(const struct handlegraph::step_handle_t &, const struct handlegraph::step_handle_t &, const class std::vector<handlegraph::handle_t> &) –> struct std::pair<struct handlegraph::step_handle_t, struct handlegraph::step_handle_t>

Graph Mutators

bdsg.handlegraph.MutableHandleGraph

bdsg.handlegraph.MutableHandleGraph.optimize(*args, **kwargs)

Overloaded function.

  1. optimize(self: bdsg.handlegraph.MutableHandleGraph) -> None

  2. optimize(self: bdsg.handlegraph.MutableHandleGraph, allow_id_reassignment: bool) -> None

Adjust the representation of the graph in memory to improve performance.

Optionally, allow the node IDs to be reassigned to further improve performance. Note: Ideally, this method is called one time once there is expected to be few graph modifications in the future. This may invalidate outstanding handles.

C++: handlegraph::MutableHandleGraph::optimize(bool) –> void

bdsg.handlegraph.MutableHandleGraph.apply_ordering(*args, **kwargs)

Overloaded function.

  1. apply_ordering(self: bdsg.handlegraph.MutableHandleGraph, order: bdsg.std.vector_handlegraph_handle_t) -> bool

  2. apply_ordering(self: bdsg.handlegraph.MutableHandleGraph, order: bdsg.std.vector_handlegraph_handle_t, compact_ids: bool) -> bool

Reorder the graph’s internal structure to match that given.

This sets the order that is used for iteration in functions like for_each_handle. If compact_ids is true, may (but will not necessarily) compact the id space of the graph to match the ordering, from 1->|ordering|. In other cases, node IDs will be preserved. This may be a no-op in the case of graph implementations that do not have any mechanism to maintain an ordering. This may invalidate outstanding handles. Returns true if node IDs actually were adjusted to match the given order, and false if they remain unchanged.

C++: handlegraph::MutableHandleGraph::apply_ordering(const class std::vector<handlegraph::handle_t> &, bool) –> bool

bdsg.handlegraph.MutableHandleGraph.set_id_increment(self: bdsg.handlegraph.MutableHandleGraph, min_id: int) None
Set a minimum id to increment the id space by, used as a hint during construction.

May have no effect on a backing implementation.

C++: handlegraph::MutableHandleGraph::set_id_increment(const long long &) –> void

bdsg.handlegraph.MutableHandleGraph.increment_node_ids(*args, **kwargs)

Overloaded function.

  1. increment_node_ids(self: bdsg.handlegraph.MutableHandleGraph, increment: int) -> None

Add the given value to all node IDs.

Has a default implementation in terms of reassign_node_ids, but can be implemented more efficiently in some graphs.

C++: handlegraph::MutableHandleGraph::increment_node_ids(long long) –> void

  1. increment_node_ids(self: bdsg.handlegraph.MutableHandleGraph, increment: int) -> None

This specialization for long appears to be needed to avoid confusion about nid_t

C++: handlegraph::MutableHandleGraph::increment_node_ids(long) –> void

bdsg.handlegraph.MutableHandleGraph.reassign_node_ids(self: bdsg.handlegraph.MutableHandleGraph, get_new_id: Callable[[int], int]) None
Renumber all node IDs using the given function, which, given an old ID, returns the new ID.

Modifies the graph in place. Invalidates all outstanding handles. If the graph supports paths, they also must be updated. The mapping function may return 0. In this case, the input ID will remain unchanged. The mapping function should not return any ID for which it would return 0.

C++: handlegraph::MutableHandleGraph::reassign_node_ids(const class std::function<long long (const long long &)> &) –> void

bdsg.handlegraph.DeletableHandleGraph

bdsg.handlegraph.DeletableHandleGraph.clear(self: bdsg.handlegraph.DeletableHandleGraph) None

Remove all nodes and edges. May also remove all paths, if applicable.

C++: handlegraph::DeletableHandleGraph::clear() –> void

bdsg.handlegraph.SerializableHandleGraph

bdsg.handlegraph.SerializableHandleGraph.deserialize(self: bdsg.handlegraph.Serializable, filename: str) None
Sets the contents of this object to the contents of a serialized object

from a file. The serialized object must be from the same implementation of this interface as is calling deserialize(). Can only be called on an empty object.

C++: handlegraph::Serializable::deserialize(const std::string &) –> void

Accessor Methods

The following lists breaks out methods from the various handle graph interfaces by what types of objects they return information about.

Node Accessors

bdsg.handlegraph.HandleGraph

bdsg.handlegraph.HandleGraph.get_handle(*args, **kwargs)

Overloaded function.

  1. get_handle(self: bdsg.handlegraph.HandleGraph, node_id: int) -> bdsg.handlegraph.handle_t

  2. get_handle(self: bdsg.handlegraph.HandleGraph, node_id: int, is_reverse: bool) -> bdsg.handlegraph.handle_t

Look up the handle for the node with the given ID in the given orientation

C++: handlegraph::HandleGraph::get_handle(const long long &, bool) const –> struct handlegraph::handle_t

bdsg.handlegraph.HandleGraph.get_id(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t) int

Get the ID from a handle

C++: handlegraph::HandleGraph::get_id(const struct handlegraph::handle_t &) const –> long long

bdsg.handlegraph.HandleGraph.get_is_reverse(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t) bool

Get the orientation of a handle

C++: handlegraph::HandleGraph::get_is_reverse(const struct handlegraph::handle_t &) const –> bool

bdsg.handlegraph.HandleGraph.get_length(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t) int

Get the length of a node

C++: handlegraph::HandleGraph::get_length(const struct handlegraph::handle_t &) const –> unsigned long

bdsg.handlegraph.HandleGraph.get_sequence(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t) str
Get the sequence of a node, presented in the handle’s local forward

orientation.

C++: handlegraph::HandleGraph::get_sequence(const struct handlegraph::handle_t &) const –> std::string

bdsg.handlegraph.HandleGraph.get_subsequence(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t, index: int, size: int) str
Returns a substring of a handle’s sequence, in the orientation of the

handle. If the indicated substring would extend beyond the end of the handle’s sequence, the return value is truncated to the sequence’s end. By default O(n) in the size of the handle’s sequence, but can be overriden.

C++: handlegraph::HandleGraph::get_subsequence(const struct handlegraph::handle_t &, unsigned long, unsigned long) const –> std::string

bdsg.handlegraph.HandleGraph.get_base(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t, index: int) str
Returns one base of a handle’s sequence, in the orientation of the

handle.

C++: handlegraph::HandleGraph::get_base(const struct handlegraph::handle_t &, unsigned long) const –> char

bdsg.handlegraph.HandleGraph.get_degree(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t, go_left: bool) int
Get the number of edges on the right (go_left = false) or left (go_left

= true) side of the given handle. The default implementation is O(n) in the number of edges returned, but graph implementations that track this information more efficiently can override this method.

C++: handlegraph::HandleGraph::get_degree(const struct handlegraph::handle_t &, bool) const –> unsigned long

bdsg.handlegraph.PathHandleGraph

bdsg.handlegraph.PathHandleGraph.get_step_count(*args, **kwargs)

Overloaded function.

  1. get_step_count(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) -> int

Returns the number of node steps in the path

C++: handlegraph::PathHandleGraph::get_step_count(const struct handlegraph::path_handle_t &) const –> unsigned long

  1. get_step_count(self: bdsg.handlegraph.PathHandleGraph, handle: bdsg.handlegraph.handle_t) -> int

Returns the number of node steps on a handle

C++: handlegraph::PathHandleGraph::get_step_count(const struct handlegraph::handle_t &) const –> unsigned long

bdsg.handlegraph.PathHandleGraph.steps_of_handle(*args, **kwargs)

Overloaded function.

  1. steps_of_handle(self: bdsg.handlegraph.PathHandleGraph, handle: bdsg.handlegraph.handle_t) -> std::vector<handlegraph::step_handle_t, std::allocator<handlegraph::step_handle_t> >

  2. steps_of_handle(self: bdsg.handlegraph.PathHandleGraph, handle: bdsg.handlegraph.handle_t, match_orientation: bool) -> std::vector<handlegraph::step_handle_t, std::allocator<handlegraph::step_handle_t> >

Returns a vector of all steps of a node on paths. Optionally restricts to

steps that match the handle in orientation.

C++: handlegraph::PathHandleGraph::steps_of_handle(const struct handlegraph::handle_t &, bool) const –> class std::vector<handlegraph::step_handle_t>

bdsg.handlegraph.VectorizableHandleGraph

bdsg.handlegraph.VectorizableHandleGraph.node_vector_offset(self: bdsg.handlegraph.VectorizableHandleGraph, node_id: int) int
Return the start position of the node in a (possibly implict) sorted array

constructed from the concatenation of the node sequences

C++: handlegraph::VectorizableHandleGraph::node_vector_offset(const long long &) const –> unsigned long

bdsg.handlegraph.VectorizableHandleGraph.node_at_vector_offset(self: bdsg.handlegraph.VectorizableHandleGraph, offset: int) int

Return the node overlapping the given offset in the implicit node vector

C++: handlegraph::VectorizableHandleGraph::node_at_vector_offset(const unsigned long &) const –> long long

Node Handle Accessors

bdsg.handlegraph.HandleGraph

bdsg.handlegraph.HandleGraph.flip(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t) bdsg.handlegraph.handle_t

Invert the orientation of a handle (potentially without getting its ID)

C++: handlegraph::HandleGraph::flip(const struct handlegraph::handle_t &) const –> struct handlegraph::handle_t

bdsg.handlegraph.HandleGraph.forward(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t) bdsg.handlegraph.handle_t

Get the locally forward version of a handle

C++: handlegraph::HandleGraph::forward(const struct handlegraph::handle_t &) const –> struct handlegraph::handle_t

bdsg.handlegraph.ExpandingOverlayGraph

bdsg.handlegraph.ExpandingOverlayGraph.get_underlying_handle(self: bdsg.handlegraph.ExpandingOverlayGraph, handle: bdsg.handlegraph.handle_t) bdsg.handlegraph.handle_t
Returns the handle in the underlying graph that corresponds to a handle in the

overlay

C++: handlegraph::ExpandingOverlayGraph::get_underlying_handle(const struct handlegraph::handle_t &) const –> struct handlegraph::handle_t

Edge Accessors

bdsg.handlegraph.HandleGraph

bdsg.handlegraph.HandleGraph.edge_handle(self: bdsg.handlegraph.HandleGraph, left: bdsg.handlegraph.handle_t, right: bdsg.handlegraph.handle_t) Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]
A pair of handles can be used as an edge. When so used, the handles have a

canonical order and orientation.

C++: handlegraph::HandleGraph::edge_handle(const struct handlegraph::handle_t &, const struct handlegraph::handle_t &) const –> struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t>

bdsg.handlegraph.HandleGraph.traverse_edge_handle(self: bdsg.handlegraph.HandleGraph, edge: Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t], left: bdsg.handlegraph.handle_t) bdsg.handlegraph.handle_t
Such a pair can be viewed from either inward end handle and produce the

outward handle you would arrive at.

C++: handlegraph::HandleGraph::traverse_edge_handle(const struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t> &, const struct handlegraph::handle_t &) const –> struct handlegraph::handle_t

bdsg.handlegraph.VectorizableHandleGraph

bdsg.handlegraph.VectorizableHandleGraph.edge_index(self: bdsg.handlegraph.VectorizableHandleGraph, edge: Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]) int

Return a unique index among edges in the graph

C++: handlegraph::VectorizableHandleGraph::edge_index(const struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t> &) const –> unsigned long

Path Accessors

bdsg.handlegraph.PathHandleGraph

bdsg.handlegraph.PathHandleGraph.get_path_handle(self: bdsg.handlegraph.PathHandleGraph, path_name: str) bdsg.handlegraph.path_handle_t
Look up the path handle for the given path name.

The path with that name must exist.

C++: handlegraph::PathHandleGraph::get_path_handle(const std::string &) const –> struct handlegraph::path_handle_t

bdsg.handlegraph.PathHandleGraph.get_path_name(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) str

Look up the name of a path from a handle to it

C++: handlegraph::PathHandleGraph::get_path_name(const struct handlegraph::path_handle_t &) const –> std::string

bdsg.handlegraph.PathHandleGraph.get_is_circular(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) bool

Look up whether a path is circular

C++: handlegraph::PathHandleGraph::get_is_circular(const struct handlegraph::path_handle_t &) const –> bool

bdsg.handlegraph.PathHandleGraph.get_step_count(*args, **kwargs)

Overloaded function.

  1. get_step_count(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) -> int

Returns the number of node steps in the path

C++: handlegraph::PathHandleGraph::get_step_count(const struct handlegraph::path_handle_t &) const –> unsigned long

  1. get_step_count(self: bdsg.handlegraph.PathHandleGraph, handle: bdsg.handlegraph.handle_t) -> int

Returns the number of node steps on a handle

C++: handlegraph::PathHandleGraph::get_step_count(const struct handlegraph::handle_t &) const –> unsigned long

bdsg.handlegraph.PathHandleGraph.is_empty(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) bool

Returns true if the given path is empty, and false otherwise

C++: handlegraph::PathHandleGraph::is_empty(const struct handlegraph::path_handle_t &) const –> bool

bdsg.handlegraph.PathHandleGraph.path_begin(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) bdsg.handlegraph.step_handle_t
Get a handle to the first step, which will be an arbitrary step in a circular path

that we consider “first” based on our construction of the path. If the path is empty, then the implementation must return the same value as path_end().

C++: handlegraph::PathHandleGraph::path_begin(const struct handlegraph::path_handle_t &) const –> struct handlegraph::step_handle_t

bdsg.handlegraph.PathHandleGraph.path_end(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) bdsg.handlegraph.step_handle_t
Get a handle to a fictitious position past the end of a path. This position is

returned by get_next_step for the final step in a path in a non-circular path. Note: get_next_step will NEVER return this value for a circular path.

C++: handlegraph::PathHandleGraph::path_end(const struct handlegraph::path_handle_t &) const –> struct handlegraph::step_handle_t

bdsg.handlegraph.PathHandleGraph.path_back(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) bdsg.handlegraph.step_handle_t
Get a handle to the last step, which will be an arbitrary step in a circular path that

we consider “last” based on our construction of the path. If the path is empty then the implementation must return the same value as path_front_end().

C++: handlegraph::PathHandleGraph::path_back(const struct handlegraph::path_handle_t &) const –> struct handlegraph::step_handle_t

bdsg.handlegraph.PathHandleGraph.path_front_end(self: bdsg.handlegraph.PathHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) bdsg.handlegraph.step_handle_t
Get a handle to a fictitious position before the beginning of a path. This position is

return by get_previous_step for the first step in a path in a non-circular path. Note: get_previous_step will NEVER return this value for a circular path.

C++: handlegraph::PathHandleGraph::path_front_end(const struct handlegraph::path_handle_t &) const –> struct handlegraph::step_handle_t

bdsg.handlegraph.PathPositionHandleGraph

bdsg.handlegraph.PathPositionHandleGraph.get_path_length(self: bdsg.handlegraph.PathPositionHandleGraph, path_handle: bdsg.handlegraph.path_handle_t) int

Returns the length of a path measured in bases of sequence.

C++: handlegraph::PathPositionHandleGraph::get_path_length(const struct handlegraph::path_handle_t &) const –> unsigned long

Path Step Accessors

bdsg.handlegraph.PathHandleGraph

bdsg.handlegraph.PathHandleGraph.get_path_handle_of_step(self: bdsg.handlegraph.PathHandleGraph, step_handle: bdsg.handlegraph.step_handle_t) bdsg.handlegraph.path_handle_t

Returns a handle to the path that an step is on

C++: handlegraph::PathHandleGraph::get_path_handle_of_step(const struct handlegraph::step_handle_t &) const –> struct handlegraph::path_handle_t

bdsg.handlegraph.PathHandleGraph.get_handle_of_step(self: bdsg.handlegraph.PathHandleGraph, step_handle: bdsg.handlegraph.step_handle_t) bdsg.handlegraph.handle_t

Get a node handle (node ID and orientation) from a handle to an step on a path

C++: handlegraph::PathHandleGraph::get_handle_of_step(const struct handlegraph::step_handle_t &) const –> struct handlegraph::handle_t

bdsg.handlegraph.PathHandleGraph.has_next_step(self: bdsg.handlegraph.PathHandleGraph, step_handle: bdsg.handlegraph.step_handle_t) bool

Returns true if the step is not the last step in a non-circular path.

C++: handlegraph::PathHandleGraph::has_next_step(const struct handlegraph::step_handle_t &) const –> bool

bdsg.handlegraph.PathHandleGraph.get_next_step(self: bdsg.handlegraph.PathHandleGraph, step_handle: bdsg.handlegraph.step_handle_t) bdsg.handlegraph.step_handle_t
Returns a handle to the next step on the path. If the given step is the final step

of a non-circular path, this method has undefined behavior. In a circular path, the “last” step will loop around to the “first” step.

C++: handlegraph::PathHandleGraph::get_next_step(const struct handlegraph::step_handle_t &) const –> struct handlegraph::step_handle_t

bdsg.handlegraph.PathHandleGraph.has_previous_step(self: bdsg.handlegraph.PathHandleGraph, step_handle: bdsg.handlegraph.step_handle_t) bool

Returns true if the step is not the first step in a non-circular path.

C++: handlegraph::PathHandleGraph::has_previous_step(const struct handlegraph::step_handle_t &) const –> bool

bdsg.handlegraph.PathHandleGraph.get_previous_step(self: bdsg.handlegraph.PathHandleGraph, step_handle: bdsg.handlegraph.step_handle_t) bdsg.handlegraph.step_handle_t
Returns a handle to the previous step on the path. If the given step is the first

step of a non-circular path, this method has undefined behavior. In a circular path, it will loop around from the “first” step (i.e. the one returned by path_begin) to the “last” step.

C++: handlegraph::PathHandleGraph::get_previous_step(const struct handlegraph::step_handle_t &) const –> struct handlegraph::step_handle_t

bdsg.handlegraph.PathPositionHandleGraph

bdsg.handlegraph.PathPositionHandleGraph.get_position_of_step(self: bdsg.handlegraph.PathPositionHandleGraph, step: bdsg.handlegraph.step_handle_t) int
Returns the position along the path of the beginning of this step measured in

bases of sequence. In a circular path, positions start at the step returned by path_begin().

C++: handlegraph::PathPositionHandleGraph::get_position_of_step(const struct handlegraph::step_handle_t &) const –> unsigned long

bdsg.handlegraph.PathPositionHandleGraph.get_step_at_position(self: bdsg.handlegraph.PathPositionHandleGraph, path: bdsg.handlegraph.path_handle_t, position: int) bdsg.handlegraph.step_handle_t
Returns the step at this position, measured in bases of sequence starting at

the step returned by path_begin(). If the position is past the end of the path, returns path_end().

C++: handlegraph::PathPositionHandleGraph::get_step_at_position(const struct handlegraph::path_handle_t &, const unsigned long &) const –> struct handlegraph::step_handle_t

Graph Accessors

bdsg.handlegraph.HandleGraph

bdsg.handlegraph.HandleGraph.has_node(self: bdsg.handlegraph.HandleGraph, node_id: int) bool

Method to check if a node exists by ID

C++: handlegraph::HandleGraph::has_node(long long) const –> bool

bdsg.handlegraph.HandleGraph.has_edge(*args, **kwargs)

Overloaded function.

  1. has_edge(self: bdsg.handlegraph.HandleGraph, left: bdsg.handlegraph.handle_t, right: bdsg.handlegraph.handle_t) -> bool

Returns true if there is an edge that allows traversal from the left

handle to the right handle. By default O(n) in the number of edges on left, but can be overridden with more efficient implementations.

C++: handlegraph::HandleGraph::has_edge(const struct handlegraph::handle_t &, const struct handlegraph::handle_t &) const –> bool

  1. has_edge(self: bdsg.handlegraph.HandleGraph, edge: Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]) -> bool

Convenient wrapper of has_edge for edge_t argument.

C++: handlegraph::HandleGraph::has_edge(const struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t> &) const –> bool

bdsg.handlegraph.HandleGraph.get_node_count(self: bdsg.handlegraph.HandleGraph) int

Return the number of nodes in the graph

C++: handlegraph::HandleGraph::get_node_count() const –> unsigned long

bdsg.handlegraph.HandleGraph.get_edge_count(self: bdsg.handlegraph.HandleGraph) int
Return the total number of edges in the graph. If not overridden,

counts them all in linear time.

C++: handlegraph::HandleGraph::get_edge_count() const –> unsigned long

bdsg.handlegraph.HandleGraph.get_total_length(self: bdsg.handlegraph.HandleGraph) int
Return the total length of all nodes in the graph, in bp. If not

overridden, loops over all nodes in linear time.

C++: handlegraph::HandleGraph::get_total_length() const –> unsigned long

bdsg.handlegraph.HandleGraph.min_node_id(self: bdsg.handlegraph.HandleGraph) int
Return the smallest ID in the graph, or some smaller number if the

smallest ID is unavailable. Return value is unspecified if the graph is empty.

C++: handlegraph::HandleGraph::min_node_id() const –> long long

bdsg.handlegraph.HandleGraph.max_node_id(self: bdsg.handlegraph.HandleGraph) int
Return the largest ID in the graph, or some larger number if the

largest ID is unavailable. Return value is unspecified if the graph is empty.

C++: handlegraph::HandleGraph::max_node_id() const –> long long

bdsg.handlegraph.PathHandleGraph

bdsg.handlegraph.PathHandleGraph.get_path_count(self: bdsg.handlegraph.PathHandleGraph) int

Returns the number of paths stored in the graph

C++: handlegraph::PathHandleGraph::get_path_count() const –> unsigned long

bdsg.handlegraph.SerializableHandleGraph

bdsg.handlegraph.SerializableHandleGraph.serialize(self: bdsg.handlegraph.Serializable, filename: str) None
Write the contents of this object to a named file. Makes sure to include

a leading magic number.

C++: handlegraph::Serializable::serialize(const std::string &) –> void

bdsg.handlegraph.SerializableHandleGraph.get_magic_number(self: bdsg.handlegraph.Serializable) int
Returns a number that is specific to the serialized implementation for type

checking. Does not depend on the contents of any particular instantiation (i.e. behaves as if static, but cannot be static and virtual).

C++: handlegraph::Serializable::get_magic_number() const –> unsigned int

Iteratator Methods

The following lists breaks out methods from the various handle graph interfaces by what types of objects they iterate over. Note that iteration is callback-based and not via traditional Python iterator semantics. Iteratee functions should return False to stop iteration, and must return True to continue. Not returning anything (i.e. returning None) will stop iteration early.

Node Iterators

bdsg.handlegraph.HandleGraph

bdsg.handlegraph.HandleGraph.for_each_handle(*args, **kwargs)

Overloaded function.

  1. for_each_handle(self: bdsg.handlegraph.HandleGraph, iteratee: Callable[[bdsg.handlegraph.handle_t], bool]) -> bool

  2. for_each_handle(self: bdsg.handlegraph.HandleGraph, iteratee: Callable[[bdsg.handlegraph.handle_t], bool], parallel: bool) -> bool

C++: handlegraph::HandleGraph::for_each_handle(const class std::function<bool (const struct handlegraph::handle_t &)> &, bool) const –> bool

Edge Iterators

bdsg.handlegraph.HandleGraph

bdsg.handlegraph.HandleGraph.follow_edges(self: bdsg.handlegraph.HandleGraph, handle: bdsg.handlegraph.handle_t, go_left: bool, iteratee: Callable[[bdsg.handlegraph.handle_t], bool]) bool

C++: handlegraph::HandleGraph::follow_edges(const struct handlegraph::handle_t &, bool, const class std::function<bool (const struct handlegraph::handle_t &)> &) const –> bool

bdsg.handlegraph.HandleGraph.for_each_edge(*args, **kwargs)

Overloaded function.

  1. for_each_edge(self: bdsg.handlegraph.HandleGraph, iteratee: Callable[[Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]], bool]) -> bool

  2. for_each_edge(self: bdsg.handlegraph.HandleGraph, iteratee: Callable[[Tuple[bdsg.handlegraph.handle_t, bdsg.handlegraph.handle_t]], bool], parallel: bool) -> bool

C++: handlegraph::HandleGraph::for_each_edge(const class std::function<bool (const struct std::pair<struct handlegraph::handle_t, struct handlegraph::handle_t> &)> &, bool) const –> bool

Path Iterators

bdsg.handlegraph.PathHandleGraph

bdsg.handlegraph.PathHandleGraph.for_each_path_handle(self: bdsg.handlegraph.PathHandleGraph, iteratee: Callable[[bdsg.handlegraph.path_handle_t], bool]) bool

C++: handlegraph::PathHandleGraph::for_each_path_handle(const class std::function<bool (const struct handlegraph::path_handle_t &)> &) const –> bool

Path Step Iterators

bdsg.handlegraph.PathHandleGraph

bdsg.handlegraph.PathHandleGraph.for_each_step_in_path(self: bdsg.handlegraph.PathHandleGraph, path: bdsg.handlegraph.path_handle_t, iteratee: Callable[[bdsg.handlegraph.step_handle_t], bool]) bool

C++: handlegraph::PathHandleGraph::for_each_step_in_path(const struct handlegraph::path_handle_t &, const class std::function<bool (const struct handlegraph::step_handle_t &)> &) const –> bool

bdsg.handlegraph.PathHandleGraph.for_each_step_on_handle(self: bdsg.handlegraph.PathHandleGraph, handle: bdsg.handlegraph.handle_t, iteratee: Callable[[bdsg.handlegraph.step_handle_t], bool]) bool

C++: handlegraph::PathHandleGraph::for_each_step_on_handle(const struct handlegraph::handle_t &, const class std::function<bool (const struct handlegraph::step_handle_t &)> &) const –> bool

bdsg.handlegraph.PathPositionHandleGraph

bdsg.handlegraph.PathPositionHandleGraph.for_each_step_position_on_handle(self: bdsg.handlegraph.PathPositionHandleGraph, handle: bdsg.handlegraph.handle_t, iteratee: Callable[[bdsg.handlegraph.step_handle_t, bool, int], bool]) bool
Execute an iteratee on each step on a path, along with its orientation relative to

the path (true if it is reverse the orientation of the handle on the path), and its position measured in bases of sequence along the path. Positions are always measured on the forward strand.

Iteration will stop early if the iteratee returns false. This method returns false if iteration was stopped early, else true

C++: handlegraph::PathPositionHandleGraph::for_each_step_position_on_handle(const struct handlegraph::handle_t &, const class std::function<bool (const struct handlegraph::step_handle_t &, const bool &, const unsigned long &)> &) const –> bool