pub struct Contig { /* private fields */ }Expand description
The contig data, such as identifiers and its length.
Implementations§
Source§impl Contig
impl Contig
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::new("Y", &["CM000686.2", "NC_000024.10", "chrY"], 57_227_415).expect("The contig data are valid");
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::new("Y", &["CM000686.2", "NC_000024.10", "chrY"], 57_227_415).expect("The contig data are valid");
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::new("Y", &["CM000686.2", "NC_000024.10", "chrY"], 57_227_415).expect("The contig data are valid");
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::new("Y", &["CM000686.2", "NC_000024.10", "chrY"], 57_227_415).expect("The contig data are valid");
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>
pub fn new( name: impl ToString, alt_names: &[impl ToString], length: u32, ) -> Option<Self>
Create 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.