Skip to main content

SubgraphQuery

Struct SubgraphQuery 

Source
pub struct SubgraphQuery { /* private fields */ }
Expand description

Arguments for extracting a subgraph.

§Examples

use gbz_base::SubgraphQuery;
use gbz::FullPathName;

let path_name = FullPathName::generic("path");
let query = SubgraphQuery::path_offset(&path_name, 123);
assert_eq!(query.context(), SubgraphQuery::DEFAULT_CONTEXT);
assert_eq!(query.snarls(), SubgraphQuery::DEFAULT_SNARLS);
assert_eq!(query.output(), SubgraphQuery::DEFAULT_OUTPUT);

let query = query.with_context(1000);
assert_eq!(query.context(), 1000);

let query = query.with_snarls(true);
assert!(query.snarls());

Implementations§

Source§

impl SubgraphQuery

Source

pub const DEFAULT_CONTEXT: usize = 100

Default value for context length (in bp).

Source

pub const DEFAULT_SNARLS: bool = false

Default value for the snarl extraction flag.

Source

pub const DEFAULT_OUTPUT: HaplotypeOutput = HaplotypeOutput::All

Default value for the haplotype output option.

Source

pub fn path_offset(path_name: &FullPathName, offset: usize) -> Self

Creates a query that retrieves a subgraph around a path offset.

The reference path should be specified by using a sample name, a contig name, and optionally a haplotype number. The fragment field should not be used. If the reference haplotype is fragmented, the query will try to find the right fragment.

Source

pub fn path_interval(path_name: &FullPathName, interval: Range<usize>) -> Self

Cretes a query that retrieves a subgraph around a path interval.

The reference path should be specified by using a sample name, a contig name, and optionally a haplotype number. The fragment field should not be used. If the reference haplotype is fragmented, the query will try to find the right fragment.

Source

pub fn nodes(nodes: impl IntoIterator<Item = usize>) -> Self

Creates a query that retrieves a subgraph around a set of nodes.

Source

pub fn between(start: usize, end: usize, limit: Option<usize>) -> Self

Creates a query that extracts a subgraph between two handles in the same chain.

This query ignores context length and the snarl extraction flag. An optional safety limit for the size of the subgraph in nodes can be provided. If the nodes are not in the same chain in the given order, the subgraph can otherwise be arbitrarily large.

Source

pub fn with_context(self, context: usize) -> Self

Returns an updated query with the given context length.

See Self::DEFAULT_CONTEXT for the default value.

Source

pub fn with_snarls(self, snarls: bool) -> Self

Returns an updated query with the given snarl extraction flag.

See Self::DEFAULT_SNARLS for the default value.

Source

pub fn with_output(self, output: HaplotypeOutput) -> Self

Returns an updated query with the given haplotype output option.

See Self::DEFAULT_OUTPUT for the default value.

§Panics

Panics if this is a node-based query and the output would be HaplotypeOutput::ReferenceOnly.

Source

pub fn context(&self) -> usize

Returns the context length (in bp) for the query.

Source

pub fn snarls(&self) -> bool

Returns true if the query also extracts nodes coverered top-level snarls.

A snarl is covered, if both of its boundary nodes are contained in the query interval or in the context.

Source

pub fn output(&self) -> HaplotypeOutput

Returns the output format for the query.

Trait Implementations§

Source§

impl Clone for SubgraphQuery

Source§

fn clone(&self) -> SubgraphQuery

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 SubgraphQuery

Source§

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

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

impl Display for SubgraphQuery

Source§

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

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

impl PartialEq for SubgraphQuery

Source§

fn eq(&self, other: &SubgraphQuery) -> 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 Eq for SubgraphQuery

Source§

impl StructuralPartialEq for SubgraphQuery

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<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<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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.