Struct GraphSection

Source
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

Source

pub fn builder() -> GraphSectionBuilder

Create an instance of GraphSection using the builder syntax

Source§

impl GraphSection

Source

pub fn new(id: BString) -> Self

Create a new empty GraphSection

Source

pub fn new_default_graph() -> Self

Source

pub fn node_indices_to_ids(&self) -> HashMap<NodeIndex, BString>

Source

pub fn edge_indices_to_ids(&self) -> HashMap<EdgeIndex, BString>

Source

pub fn node_weight(&self, node_idx: NodeIndex) -> Option<&NodeData>

Source

pub fn edge_weight(&self, edge_idx: EdgeIndex) -> Option<&EdgeData>

Source

pub fn in_degree(&self, node_idx: NodeIndex) -> usize

Source

pub fn out_degree(&self, node_idx: NodeIndex) -> usize

Source

pub fn add_node(&mut self, node_data: NodeData) -> Result<NodeIndex>

Add a node to the graph

Source

pub fn add_edge( &mut self, source_id: &BStr, sink_id: &BStr, edge_data: EdgeData, ) -> Result<EdgeIndex>

Add an edge to the graph

Source

pub fn node_by_idx(&self, node_idx: NodeIndex) -> Option<&NodeData>

Source

pub fn node_by_id(&self, id: &str) -> Option<&NodeData>

Source

pub fn edge_by_id(&self, id: &str) -> Option<&EdgeData>

Source

pub fn edge_by_idx(&self, edge_idx: EdgeIndex) -> Option<&EdgeData>

Source

pub fn nodes(&self) -> Vec<&NodeData>

Source

pub fn edges(&self) -> Vec<&EdgeData>

Source

pub fn find_node_id_by_idx(&self, node_idx: NodeIndex) -> Option<&BString>

Helper method to find a node’s ID by its index

Source

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:

  1. The node shares at least one read with previous nodes in the path
  2. 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)
Source

pub fn to_dot(&self, node_label: bool, edge_label: bool) -> Result<String>

Source

pub fn to_json(&self) -> Result<Value>

Source

pub fn annotate_node_with_sequence<P: AsRef<Path>>( &mut self, reference_genome_path: P, ) -> Result<()>

Trait Implementations§

Source§

impl Clone for GraphSection

Source§

fn clone(&self) -> GraphSection

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 Debug for GraphSection

Source§

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

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

impl Default for GraphSection

Source§

fn default() -> GraphSection

Returns the “default value” for a type. Read more
Source§

impl GraphAnalysis for GraphSection

Source§

fn is_connected(&self) -> Result<bool>

Determines whether the graph is connected. Read more
Source§

fn is_cyclic(&self) -> Result<bool>

Determines whether the graph contains any cycles. Read more
Source§

fn is_bubble(&self) -> Result<bool>

Determines whether the graph contains any bubbles. Read more
Source§

fn is_simple(&self) -> Result<bool>

Determines whether the graph is simple. Read more
Source§

fn topo(&self) -> Result<GraphTopology>

Source§

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>

Determines whether the directed graph is a fade-in structure. Read more
Source§

fn is_fade_out(&self) -> Result<bool>

Determines whether the directed graph is a fade-out structure. Read more
Source§

fn is_bipartite(&self) -> Result<bool>

Determines whether the graph is bipartite. Read more
Source§

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>

Determines whether the graph contains equi-paths. Read more
Source§

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>

Helper method to check if the graph matches a specific topology. Read more

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more