pub struct GraphSection {
pub id: BString,
pub attributes: HashMap<BString, Attribute>,
pub node_indices: HashMap<BString, NodeIndex>,
pub edge_indices: HashMap<BString, EdgeIndex>,
pub groups: HashMap<BString, Group>,
pub chains: HashMap<BString, Group>,
/* private fields */
}
Expand description
Represents a graph section within the TSG file
Fields§
§id: BString
§attributes: HashMap<BString, Attribute>
§node_indices: HashMap<BString, NodeIndex>
§edge_indices: HashMap<BString, EdgeIndex>
§groups: HashMap<BString, Group>
§chains: HashMap<BString, Group>
Implementations§
Source§impl GraphSection
impl GraphSection
Sourcepub fn builder() -> GraphSectionBuilder
pub fn builder() -> GraphSectionBuilder
Create an instance of GraphSection
using the builder syntax
Source§impl GraphSection
impl GraphSection
pub fn new_default_graph() -> Self
pub fn node_indices_to_ids(&self) -> HashMap<NodeIndex, BString>
pub fn edge_indices_to_ids(&self) -> HashMap<EdgeIndex, BString>
pub fn node_weight(&self, node_idx: NodeIndex) -> Option<&NodeData>
pub fn edge_weight(&self, edge_idx: EdgeIndex) -> Option<&EdgeData>
pub fn in_degree(&self, node_idx: NodeIndex) -> usize
pub fn out_degree(&self, node_idx: NodeIndex) -> usize
Sourcepub fn add_edge(
&mut self,
source_id: &BStr,
sink_id: &BStr,
edge_data: EdgeData,
) -> Result<EdgeIndex>
pub fn add_edge( &mut self, source_id: &BStr, sink_id: &BStr, edge_data: EdgeData, ) -> Result<EdgeIndex>
Add an edge to the graph
pub fn node_by_idx(&self, node_idx: NodeIndex) -> Option<&NodeData>
pub fn node_by_id(&self, id: &str) -> Option<&NodeData>
pub fn edge_by_id(&self, id: &str) -> Option<&EdgeData>
pub fn edge_by_idx(&self, edge_idx: EdgeIndex) -> Option<&EdgeData>
pub fn nodes(&self) -> Vec<&NodeData>
pub fn edges(&self) -> Vec<&EdgeData>
Sourcepub fn find_node_id_by_idx(&self, node_idx: NodeIndex) -> Option<&BString>
pub fn find_node_id_by_idx(&self, node_idx: NodeIndex) -> Option<&BString>
Helper method to find a node’s ID by its index
Sourcepub fn traverse(&self) -> Result<Vec<TSGPath<'_>>>
pub fn traverse(&self) -> Result<Vec<TSGPath<'_>>>
Traverse the graph and return all valid paths from source nodes to sink nodes.
A valid path must respect read continuity, especially for nodes with Intermediary (IN) reads. For nodes with IN reads, we ensure that:
- The node shares at least one read with previous nodes in the path
- The node can connect to at least one subsequent node that shares a read with it
Example: n1 (r1) -> n3 (r1,r2) -> n4 (r1) n2 (r2) -> n3 (r1,r2) -> n5 (r2)
If n3 has IN reads, then only these paths are valid:
- n1 -> n3 -> n4 (valid because they all share read r1)
- n2 -> n3 -> n5 (valid because they all share read r2)
These paths would be invalid:
- n1 -> n3 -> n5 (invalid because n1 and n5 don’t share a common read)
- n2 -> n3 -> n4 (invalid because n2 and n4 don’t share a common read)
pub fn to_dot(&self, node_label: bool, edge_label: bool) -> Result<String>
pub fn to_json(&self) -> Result<Value>
pub fn annotate_node_with_sequence<P: AsRef<Path>>( &mut self, reference_genome_path: P, ) -> Result<()>
Trait Implementations§
Source§impl Clone for GraphSection
impl Clone for GraphSection
Source§fn clone(&self) -> GraphSection
fn clone(&self) -> GraphSection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for GraphSection
impl Debug for GraphSection
Source§impl Default for GraphSection
impl Default for GraphSection
Source§fn default() -> GraphSection
fn default() -> GraphSection
Returns the “default value” for a type. Read more
Source§impl GraphAnalysis for GraphSection
impl GraphAnalysis for GraphSection
Source§fn is_cyclic(&self) -> Result<bool>
fn is_cyclic(&self) -> Result<bool>
Determines whether the graph contains any cycles. Read more
Source§fn is_bubble(&self) -> Result<bool>
fn is_bubble(&self) -> Result<bool>
Determines whether the graph contains any bubbles. Read more
fn topo(&self) -> Result<GraphTopology>
Source§fn is_directed_acyclic_graph(&self) -> Result<bool>
fn is_directed_acyclic_graph(&self) -> Result<bool>
Determines whether the graph is a directed acyclic graph (DAG). Read more
Source§fn is_fade_in(&self) -> Result<bool>
fn is_fade_in(&self) -> Result<bool>
Determines whether the directed graph is a fade-in structure. Read more
Source§fn is_fade_out(&self) -> Result<bool>
fn is_fade_out(&self) -> Result<bool>
Determines whether the directed graph is a fade-out structure. Read more
Source§fn is_unique_path(&self) -> Result<bool>
fn is_unique_path(&self) -> Result<bool>
Determines whether the graph contains a unique path. Read more
Source§fn is_equi_path(&self) -> Result<bool>
fn is_equi_path(&self) -> Result<bool>
Determines whether the graph contains equi-paths. Read more
Source§fn is_hetero_path(&self) -> Result<bool>
fn is_hetero_path(&self) -> Result<bool>
Determines whether the graph contains hetero-paths. Read more
Source§fn matches_topology(&self, topology: GraphTopology) -> Result<bool>
fn matches_topology(&self, topology: GraphTopology) -> Result<bool>
Helper method to check if the graph matches a specific topology. Read more
Auto Trait Implementations§
impl Freeze for GraphSection
impl RefUnwindSafe for GraphSection
impl Send for GraphSection
impl Sync for GraphSection
impl Unpin for GraphSection
impl UnwindSafe for GraphSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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