vg
tools for working with variation graphs
Public Member Functions | Protected Attributes | List of all members
vg::GraphSynchronizer::Lock Class Reference

#include <graph_synchronizer.hpp>

Public Member Functions

 Lock (GraphSynchronizer &synchronizer, const string &path_name, size_t path_offset, size_t context_bases, bool reflect)
 
 Lock (GraphSynchronizer &synchronizer, const string &path_name, size_t start, size_t past_end)
 
void lock ()
 
void unlock ()
 
VGget_subgraph ()
 
pair< NodeSide, NodeSideget_endpoints () const
 
set< NodeSideget_peripheral_attachments (NodeSide graph_side)
 
vector< Translationapply_edit (const Path &path, set< NodeSide > &dangling, size_t max_node_size=1024)
 
vector< Translationapply_edit (const Path &path, size_t max_node_size=1024)
 
vector< Translationapply_full_length_edit (const Path &path, size_t max_node_size=1024)
 

Protected Attributes

GraphSynchronizersynchronizer
 This points back to the synchronizer we synchronize with when we get locked. More...
 
string path_name
 
size_t path_offset = 0
 
size_t context_bases = 0
 
bool reflect = false
 
size_t start = 0
 
size_t past_end = 0
 
VG subgraph
 This is the subgraph that got extracted during the locking procedure. More...
 
pair< NodeSide, NodeSideendpoints
 
set< id_tperiphery
 
map< NodeSide, set< NodeSide > > peripheral_attachments
 
set< id_tlocked_nodes
 This is the set of nodes that this lock has currently locked. More...
 

Detailed Description

This represents a request to lock a particular context on a particular GraphSynchronizer. It fulfils the BasicLockable concept requirements, so you can wait on it with std::unique_lock.

Constructor & Destructor Documentation

◆ Lock() [1/2]

vg::GraphSynchronizer::Lock::Lock ( GraphSynchronizer synchronizer,
const string &  path_name,
size_t  path_offset,
size_t  context_bases,
bool  reflect 
)

Create a request to lock a certain radius around a certain position along a certain path in the graph controlled by the given synchronizer.

◆ Lock() [2/2]

vg::GraphSynchronizer::Lock::Lock ( GraphSynchronizer synchronizer,
const string &  path_name,
size_t  start,
size_t  past_end 
)

Create a request to lock a certain range of a certain path, from start to end. The start and end positions must line up with the boundaries of nodes in the graph. Also locks attached things that can be reached by paths of the same length or shorter. Note that the range must be nonempty.

Member Function Documentation

◆ apply_edit() [1/2]

vector< Translation > vg::GraphSynchronizer::Lock::apply_edit ( const Path path,
set< NodeSide > &  dangling,
size_t  max_node_size = 1024 
)

May only be called when locked. Apply an edit against the base graph and return the resulting translation. Note that this updates only the underlying VG graph, not the copy of the locked subgraph stored in the lock. Also note that the edit may only edit locked nodes.

Edit operations will create new nodes, and cannot delete nodes or apply changes (other than dividing and connecting) to existing nodes.

Any new nodes created are created already locked.

Any new nodes created on the left of the alignment (and any existing nodes visited) will be attached to the given "dangling" NodeSides. The set will be populated with the NodeSides for the ends of nodes created/visited at the end of the alignment.

◆ apply_edit() [2/2]

vector< Translation > vg::GraphSynchronizer::Lock::apply_edit ( const Path path,
size_t  max_node_size = 1024 
)

May only be called when locked. Apply a path as an edit to the base graph, leaving new nodes at the ends of the path unattached on their outer sides.

◆ apply_full_length_edit()

vector< Translation > vg::GraphSynchronizer::Lock::apply_full_length_edit ( const Path path,
size_t  max_node_size = 1024 
)

May only be called when locked. Apply a path as an edit to the base graph, attaching the outer sides of any newly created nodes to the sides in the periphery attached to the extraction start and end sides, respectively. The lock must have been obtained on a range, rather than a radius.

The alignment must be in the local forward orientation of the graph for this to make sense.

◆ get_endpoints()

pair< NodeSide, NodeSide > vg::GraphSynchronizer::Lock::get_endpoints ( ) const

May only be called when locked. Returns the pair of NodeSides corresponding to the start and end positions used when the lock was created.

May only be called on locks that lock a start to end range.

◆ get_peripheral_attachments()

set< NodeSide > vg::GraphSynchronizer::Lock::get_peripheral_attachments ( NodeSide  graph_side)

Get the NodeSides for nodes not in the extracted subgraph but in its periphery that are attached to the given NodeSide in the subgraph.

◆ get_subgraph()

VG & vg::GraphSynchronizer::Lock::get_subgraph ( )

May only be called when locked. Grab the subgraph that was extracted when the lock was obtained. Does not contain any path information.

◆ lock()

void vg::GraphSynchronizer::Lock::lock ( )

Block until a lock is obtained.

◆ unlock()

void vg::GraphSynchronizer::Lock::unlock ( )

If a lock is held, unlock it.

Member Data Documentation

◆ context_bases

size_t vg::GraphSynchronizer::Lock::context_bases = 0
protected

◆ endpoints

pair<NodeSide, NodeSide> vg::GraphSynchronizer::Lock::endpoints
protected

These are the endpoints that the subgraph was extracted between, if applicable.

◆ locked_nodes

set<id_t> vg::GraphSynchronizer::Lock::locked_nodes
protected

This is the set of nodes that this lock has currently locked.

◆ past_end

size_t vg::GraphSynchronizer::Lock::past_end = 0
protected

◆ path_name

string vg::GraphSynchronizer::Lock::path_name
protected

◆ path_offset

size_t vg::GraphSynchronizer::Lock::path_offset = 0
protected

◆ peripheral_attachments

map<NodeSide, set<NodeSide> > vg::GraphSynchronizer::Lock::peripheral_attachments
protected

This connects internal NodeSides to NodeSides of nodes on the periphery.

◆ periphery

set<id_t> vg::GraphSynchronizer::Lock::periphery
protected

These are the nodes connected to the subgraph but not actually available for editing. We just need no one else to edit them.

◆ reflect

bool vg::GraphSynchronizer::Lock::reflect = false
protected

◆ start

size_t vg::GraphSynchronizer::Lock::start = 0
protected

◆ subgraph

VG vg::GraphSynchronizer::Lock::subgraph
protected

This is the subgraph that got extracted during the locking procedure.

◆ synchronizer

GraphSynchronizer& vg::GraphSynchronizer::Lock::synchronizer
protected

This points back to the synchronizer we synchronize with when we get locked.


The documentation for this class was generated from the following files: