BaseGraph

Struct BaseGraph 

Source
pub struct BaseGraph<V: BaseVertex + Hash, E: BaseEdge> {
    pub graph: StableDiGraph<V, E>,
    /* private fields */
}
Expand description

Common code for graphs used for local assembly.

Fields§

§graph: StableDiGraph<V, E>

Implementations§

Source§

impl<V: BaseVertex + Hash, E: BaseEdge> BaseGraph<V, E>

Source

pub fn new(kmer_size: usize) -> BaseGraph<V, E>

Source

pub fn to_sequence_graph(&self) -> SeqGraph<BaseEdgeStruct>

Convert this kmer graph to a simple sequence graph.

Each kmer suffix shows up as a distinct SeqVertex, attached in the same structure as in the kmer graph. Nodes that are sources are mapped to SeqVertex nodes that contain all of their sequence

@return a newly allocated SequenceGraph

Source

pub fn vertex_set(&self) -> HashSet<&V>

Source

pub fn edge_set(&self) -> HashSet<&E>

Source

pub fn edges_directed( &self, node: NodeIndex, direction: Direction, ) -> Vec<EdgeIndex>

Source

pub fn contains_all_vertices<'a, I: IntoIterator<Item = &'a NodeIndex>>( &self, nodes: I, ) -> bool

Checks whether the graph contains all the vertices in a collection.

@param vertices the vertices to check. Must not be null and must not contain a null.

@throws IllegalArgumentException if {@code vertices} is {@code null}.

@return {@code true} if all the vertices in the input collection are present in this graph. Also if the input collection is empty. Otherwise it returns {@code false}.

Source

pub fn contains_edge(&self, edge: EdgeIndex) -> bool

Source

pub fn get_kmer_size(&self) -> usize

Source

pub fn is_reference_node(&self, vertex_index: NodeIndex) -> bool

@param v the vertex to test @return true if this vertex is a reference node (meaning that it appears on the reference path in the graph)

Source

pub fn is_source(&self, vertex_index: NodeIndex) -> bool

@param v the vertex to test @return true if this vertex is a source node (in degree == 0)

Source

pub fn is_sink(&self, veretex_index: NodeIndex) -> bool

@param v the vertex to test @return true if this vertex is a sink node (out degree == 0)

Source

pub fn in_degree_of(&self, vertex_index: NodeIndex) -> usize

@param v the vertex to test @return number of incoming edges

Source

pub fn out_degree_of(&self, vertex_index: NodeIndex) -> usize

@param v the vertex to test @return number of outgoing edges

Source

pub fn get_sources(&self) -> VecDeque<NodeIndex>

Get the set of source vertices of this graph NOTE: We return a BTreeSet here in order to preserve the determinism in the output order of VertexSet(), which is deterministic in output due to the underlying sets all being BTreeSet @return a non-null set

Source

pub fn get_sources_generic(&self) -> Externals<'_, V, Directed, u32>

Source

pub fn get_sinks(&self) -> BinaryHeap<NodeIndex>

Get the set of sink vertices of this graph NOTE: We return a BTreeSet here in order to preserve the determinism in the output order of VertexSet(), which is deterministic in output due to the underlying sets all being BTreeSet @return a non-null set

Source

pub fn get_sinks_generic(&self) -> Externals<'_, V, Directed, u32>

Source

pub fn compare_paths(&self, first_path: &Path, second_path: &Path) -> Ordering

Source

pub fn incoming_vertices_of(&self, v: NodeIndex) -> LinkedHashSet<NodeIndex>

Get the set of vertices connected to v by incoming edges NOTE: We return a HashSet here in order to preserve the determinism in the output order of VertexSet(), which is deterministic in output due to the underlying sets all being HashSets. @param v a non-null vertex @return a set of vertices {X} connected X -> v

Source

pub fn outgoing_vertices_of(&self, v: NodeIndex) -> LinkedHashSet<NodeIndex>

Get the set of vertices connected to v by outgoing edges NOTE: We return a HashSet here in order to preserve the determinism in the output order of VertexSet(), which is deterministic in output due to the underlying sets all being HashSets. @param v a non-null vertex @return a set of vertices {X} connected X -> v

Source

pub fn incoming_edge_of(&self, v: NodeIndex) -> Option<EdgeIndex>

Get the incoming edge of v. Requires that there be only one such edge or throws an error @param v our vertex @return the single incoming edge to v, or null if none exists

Source

pub fn outgoing_edge_of(&self, v: NodeIndex) -> Option<EdgeIndex>

Get the incoming edge of v. Requires that there be only one such edge or throws an error @param v our vertex @return the single incoming edge to v, or null if none exists

Source

pub fn get_edge_target(&self, edge: EdgeIndex) -> NodeIndex

Source

pub fn get_edge_source(&self, edge: EdgeIndex) -> NodeIndex

Source

pub fn edge_is_ref(&self, edge: EdgeIndex) -> bool

Source

pub fn remove_all_vertices<'a, I>(&'a mut self, vertices: I)
where I: IntoIterator<Item = &'a NodeIndex>,

Removes all provided vertices from the graph

Source

pub fn remove_all_edges<'a, I>(&'a mut self, edges: I)
where I: IntoIterator<Item = &'a EdgeIndex>,

Removes all provided edges from the graph

Source

pub fn is_ref_source(&self, v: NodeIndex) -> bool

@param v the vertex to test @return true if this vertex is a reference source

Source

pub fn is_ref_sink(&self, v: NodeIndex) -> bool

@param v the vertex to test @return true if this vertex is a reference source

Source

pub fn remove_singleton_orphan_vertices(&mut self)

Remove all vertices in the graph that have in and out degree of 0

Source

pub fn get_reference_source_vertex(&self) -> Option<NodeIndex>

@return the reference source vertex pulled from the graph, can be None if it doesn’t exist in the graph

Source

pub fn get_reference_sink_vertex(&self) -> Option<NodeIndex>

@return the reference sink vertex pulled from the graph, can be None if it doesn’t exist in the graph

Source

pub fn get_next_reference_vertex( &self, v: Option<NodeIndex>, allow_non_ref_paths: bool, blacklisted_edge: Option<EdgeIndex>, ) -> Option<NodeIndex>

Traverse the graph and get the next reference vertex if it exists @param v the current vertex, can be null @param allowNonRefPaths if true, allow sub-paths that are non-reference if there is only a single outgoing edge @param blacklistedEdge optional edge to ignore in the traversal down; useful to exclude the non-reference dangling paths @return the next vertex (but not necessarily on the reference path if allowNonRefPaths is true) if it exists, otherwise null

Source

pub fn get_prev_reference_vertex( &self, v: Option<NodeIndex>, ) -> Option<NodeIndex>

Traverse the graph and get the previous reference vertex if it exists @param v the current vertex, can be null @return the previous reference vertex if it exists or null otherwise.

Source

pub fn print_graph( &self, destination: &str, write_header: bool, prune_factor: usize, )

Print out the graph in the dot language for visualization @param destination File to write to

Source

pub fn get_additional_sequence<'a>( &self, index: NodeIndex, v: &'a V, ) -> &'a [u8]

Pull out the additional sequence implied by traversing this node in the graph @param v the vertex from which to pull out the additional base sequence @return non-null byte array

Source

pub fn get_sequence_from_index<'a>(&'a self, index: NodeIndex) -> &'a [u8]

Source

pub fn subset_to_neighbours( &self, target: NodeIndex, distance: usize, ) -> BaseGraph<V, E>

Get a graph containing only the vertices within distance edges of target @param target a vertex in graph @param distance the max distance @return a non-null graph

Source

pub fn has_cycles(&self) -> bool

Checks for the presence of directed cycles in the graph.

@return {@code true} if the graph has cycles, {@code false} otherwise.

Source

pub fn remove_paths_not_connected_to_ref(&mut self)

Remove all vertices in the graph that aren’t on a path from the reference source vertex to the reference sink vertex

More aggressive reference pruning algorithm than removeVerticesNotConnectedToRefRegardlessOfEdgeDirection, as it requires vertices to not only be connected by a series of directed edges but also prunes away paths that do not also meet eventually with the reference sink vertex

Source

pub fn clean_non_ref_paths(&mut self)

Remove edges that are connected before the reference source and after the reference sink

Also removes all vertices that are orphaned by this process

Source

pub fn remove_vertices_not_connected_to_ref_regardless_of_edge_direction( &mut self, )

Remove all vertices on the graph that cannot be accessed by following any edge, regardless of its direction, from the reference source vertex

Source

pub fn get_reference_bytes( &self, from_vertex: NodeIndex, to_vertex: Option<NodeIndex>, include_start: bool, include_stop: bool, ) -> Vec<u8>

Walk along the reference path in the graph and pull out the corresponding bases @param fromVertex starting vertex @param toVertex ending vertex @param includeStart should the starting vertex be included in the path @param includeStop should the ending vertex be included in the path @return byte[] array holding the reference bases, this can be null if there are no nodes between the starting and ending vertex (insertions for example)

Source

pub fn add_vertices<'a, I>(&mut self, vertices: I) -> Vec<NodeIndex>
where V: BaseVertex + 'a, I: IntoIterator<Item = &'a V>,

Source

pub fn add_edges( &mut self, start: NodeIndex, remaining: Vec<NodeIndex>, template: E, )

Source

pub fn get_node_weights(&self, node_indices: &Vec<NodeIndex>) -> Vec<Option<&V>>

Gets all node weights in vector of node indices. Returns a vector of Options pointing to references

Source

pub fn graph_equals(&self, other: &Self) -> bool

Semi-lenient comparison of two graphs, truing true if g1 and g2 have similar structure

By similar this means that both graphs have the same number of vertices, where each vertex can find a vertex in the other graph that’s seqEqual to it. A similar constraint applies to the edges, where all edges in g1 must have a corresponding edge in g2 where both source and target vertices are seqEqual

@param g1 the first graph to compare @param g2 the second graph to compare @param the type of the nodes in those graphs @return true if g1 and g2 are equals

Source

pub fn add_node(&mut self, v: &V) -> NodeIndex

Add nodes to the graph, if the node is already present in the graph then retrieve and return its current index. Use this instead of petgraph’s usual add_node as we do not want to be able have identical nodes especially when dealing with k-mers Returns the NodeIndex of the provided vertex/node

Source

pub fn add_or_update_edge(&mut self, source: NodeIndex, target: NodeIndex, e: E)

Add edge between source -> target if none exists, or add e to an already existing one if present

@param source source vertex @param target vertex @param e edge to add

Source

pub fn index_from_vertex(&self, v: &V) -> Option<NodeIndex>

Returns the index of a given node if it is found in the graph. None if not found.

Trait Implementations§

Source§

impl<V: Clone + BaseVertex + Hash, E: Clone + BaseEdge> Clone for BaseGraph<V, E>

Source§

fn clone(&self) -> BaseGraph<V, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug + BaseVertex + Hash, E: Debug + BaseEdge> Debug for BaseGraph<V, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: BaseVertex + Hash, E: BaseEdge> PartialEq for BaseGraph<V, E>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: BaseVertex + Hash, E: BaseEdge> Eq for BaseGraph<V, E>

Auto Trait Implementations§

§

impl<V, E> Freeze for BaseGraph<V, E>

§

impl<V, E> RefUnwindSafe for BaseGraph<V, E>

§

impl<V, E> Send for BaseGraph<V, E>

§

impl<V, E> Sync for BaseGraph<V, E>

§

impl<V, E> Unpin for BaseGraph<V, E>
where V: Unpin, E: Unpin,

§

impl<V, E> UnwindSafe for BaseGraph<V, E>
where V: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<T> Ungil for T
where T: Send,