pub struct Contig { /* private fields */ }Expand description
The contig data, such as identifiers and its length.
Implementations§
Source§impl Contig
impl Contig
Sourcepub fn builder() -> ContigBuilder<Uninit>
pub fn builder() -> ContigBuilder<Uninit>
Get a builder to build the Contig.
§Example
Build a contig from the minimal required attributes.
use dabuild::Contig;
let contig = Contig::builder().name("Y").length(57_227_415u32).build();
assert_eq!(contig.name(), "Y");
assert_eq!(contig.length(), 57_227_415)Build a contig with optional attributes, including GenBank, RefSeq, and UCSC accession identifiers.
use dabuild::Contig;
let contig = Contig::builder()
.length(57_227_415u32)
.name("Y")
.genbank_name("CM000686.2")
.refseq_name("NC_000024.10")
.ucsc_name("chrY")
.build();
assert_eq!(contig.name(), "Y");
assert_eq!(contig.length(), 57_227_415);
assert_eq!(contig.genbank_name().unwrap(), "CM000686.2");
assert_eq!(contig.refseq_name().unwrap(), "NC_000024.10");
assert_eq!(contig.ucsc_name().unwrap(), "chrY");Sourcepub fn alt_names(&self) -> impl Iterator<Item = &str>
pub fn alt_names(&self) -> impl Iterator<Item = &str>
Get the alternative contig identifiers.
For instance, CM000686.2, NC_000024.10, and chrY for chromosome Y.
§Example
use dabuild::Contig;
let contig = Contig::builder()
.length(57_227_415u32)
.name("Y")
.genbank_name("CM000686.2")
.refseq_name("NC_000024.10")
.ucsc_name("chrY")
.build();
let alt_names: Vec<_> = contig.alt_names().collect();
assert_eq!(&alt_names, &["CM000686.2", "NC_000024.10", "chrY"]);Sourcepub fn genbank_name(&self) -> Option<&str>
pub fn genbank_name(&self) -> Option<&str>
Get the GenBank contig identifier, if available.
For instance, CM000686.2 for chromosome Y of the GRCh38.p13 assembly.
§Example
use dabuild::Contig;
let contig = Contig::builder()
.name("Y")
.length(57_227_415u32)
.genbank_name("CM000686.2")
.build();
assert_eq!(contig.genbank_name(), Some("CM000686.2"));Sourcepub fn refseq_name(&self) -> Option<&str>
pub fn refseq_name(&self) -> Option<&str>
Get the RefSeq contig identifier, if available.
For instance, NC_000024.10 for chromosome Y of the GRCh38.p13 assembly.
§Example
use dabuild::Contig;
let contig = Contig::builder()
.name("Y")
.length(57_227_415u32)
.refseq_name("NC_000024.10")
.build();
assert_eq!(contig.refseq_name(), Some("NC_000024.10"));Sourcepub fn ucsc_name(&self) -> Option<&str>
pub fn ucsc_name(&self) -> Option<&str>
Get the UCSC contig identifier, if available.
For instance, chrY for chromosome Y of the GRCh38.p13 assembly.
§Example
use dabuild::Contig;
let contig = Contig::builder()
.name("Y")
.length(57_227_415u32)
.ucsc_name("chrY")
.build();
assert_eq!(contig.ucsc_name(), Some("chrY"));Sourcepub fn transpose_coordinate(&self, other: u32) -> Option<u32>
pub fn transpose_coordinate(&self, other: u32) -> Option<u32>
Transpose coordinate on a double-stranded sequence to the opposite strand.
Returns None if the operation would lead to an overflow.
Sourcepub fn new(
name: impl ToString,
alt_names: &[impl ToString],
length: u32,
) -> Option<Self>
👎Deprecated since 0.3.1: use Contig::builder() instead
pub fn new( name: impl ToString, alt_names: &[impl ToString], length: u32, ) -> Option<Self>
Contig::builder() insteadCreate a Contig from name, the alternative names, and its length.
§Example
Create a Contig with fields from the GRC assembly report:
use dabuild::Contig;
let contig = Contig::new("Y", &["CM000686.2", "NC_000024.10", "chrY"], 57_227_415);
assert!(contig.is_some());
let contig = contig.unwrap();
assert_eq!(contig.name(), "Y");
assert_eq!(contig.genbank_name(), Some("CM000686.2"));Create a Contig with sequence name and UCSC accession:
use dabuild::Contig;
let contig = Contig::new("Y", &["na", "", "chrY"], 57_227_415);
assert!(contig.is_some());
let contig = contig.unwrap();
assert_eq!(contig.name(), "Y");
assert!(contig.genbank_name().is_none());
assert!(contig.refseq_name().is_none());
assert_eq!(contig.ucsc_name(), Some("chrY"));The new expects alt_names with three items that correspond to:
- GenBank accession
- RefSeq accession
- UCSC accession
An accession equaling to an empty string or "na" is filtered out.