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
impl SubgraphQuery
Sourcepub const DEFAULT_CONTEXT: usize = 100
pub const DEFAULT_CONTEXT: usize = 100
Default value for context length (in bp).
Sourcepub const DEFAULT_SNARLS: bool = false
pub const DEFAULT_SNARLS: bool = false
Default value for the snarl extraction flag.
Sourcepub const DEFAULT_OUTPUT: HaplotypeOutput = HaplotypeOutput::All
pub const DEFAULT_OUTPUT: HaplotypeOutput = HaplotypeOutput::All
Default value for the haplotype output option.
Sourcepub fn path_offset(path_name: &FullPathName, offset: usize) -> Self
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.
Sourcepub fn path_interval(path_name: &FullPathName, interval: Range<usize>) -> Self
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.
Sourcepub fn nodes(nodes: impl IntoIterator<Item = usize>) -> Self
pub fn nodes(nodes: impl IntoIterator<Item = usize>) -> Self
Creates a query that retrieves a subgraph around a set of nodes.
Sourcepub fn between(start: usize, end: usize, limit: Option<usize>) -> Self
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.
Sourcepub fn with_context(self, context: usize) -> Self
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.
Sourcepub fn with_snarls(self, snarls: bool) -> Self
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.
Sourcepub fn with_output(self, output: HaplotypeOutput) -> Self
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.
Sourcepub fn snarls(&self) -> bool
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.
Sourcepub fn output(&self) -> HaplotypeOutput
pub fn output(&self) -> HaplotypeOutput
Returns the output format for the query.
Trait Implementations§
Source§impl Clone for SubgraphQuery
impl Clone for SubgraphQuery
Source§fn clone(&self) -> SubgraphQuery
fn clone(&self) -> SubgraphQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more