Struct rust_htslib::bcf::header::HeaderView
source · [−]Fields
inner: *mut bcf_hdr_t
Implementations
sourceimpl HeaderView
impl HeaderView
pub fn new(inner: *mut bcf_hdr_t) -> Self
sourcepub fn sample_count(&self) -> u32
pub fn sample_count(&self) -> u32
Get the number of samples defined in the header.
sourcepub fn samples(&self) -> Vec<&[u8]>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn samples(&self) -> Vec<&[u8]>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get vector of sample names defined in the header.
sourcepub fn sample_id(&self, sample: &[u8]) -> Option<usize>
pub fn sample_id(&self, sample: &[u8]) -> Option<usize>
Obtain id (column index) of given sample.
Returns None
if sample is not present in header.
sourcepub fn contig_count(&self) -> u32
pub fn contig_count(&self) -> u32
Get the number of contigs defined in the header.
pub fn rid2name(&self, rid: u32) -> Result<&[u8]>
sourcepub fn name2rid(&self, name: &[u8]) -> Result<u32>
pub fn name2rid(&self, name: &[u8]) -> Result<u32>
Retrieve the (internal) chromosome identifier
Examples
use rust_htslib::bcf::header::Header;
use rust_htslib::bcf::{Format, Writer};
let mut header = Header::new();
let contig_field = br#"##contig=<ID=foo,length=10>"#;
header.push_record(contig_field);
let mut vcf = Writer::from_stdout(&header, true, Format::Vcf).unwrap();
let header_view = vcf.header();
let rid = header_view.name2rid(b"foo").unwrap();
assert_eq!(rid, 0);
// try and retrieve a contig not in the header
let result = header_view.name2rid(b"bar");
assert!(result.is_err())
Errors
If name
does not match a chromosome currently in the VCF header, returns Error::BcfUnknownContig
pub fn info_type(&self, tag: &[u8]) -> Result<(TagType, TagLength)>
pub fn format_type(&self, tag: &[u8]) -> Result<(TagType, TagLength)>
sourcepub fn name_to_id(&self, id: &[u8]) -> Result<Id>
pub fn name_to_id(&self, id: &[u8]) -> Result<Id>
Convert string ID (e.g., for a FILTER
value) to its numeric identifier.
sourcepub fn id_to_name(&self, id: Id) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn id_to_name(&self, id: Id) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Convert integer representing an identifier (e.g., a FILTER
value) to its string
name.bam.
sourcepub fn sample_to_id(&self, id: &[u8]) -> Result<Id>
pub fn sample_to_id(&self, id: &[u8]) -> Result<Id>
Convert string sample name to its numeric identifier.
sourcepub fn id_to_sample(&self, id: Id) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn id_to_sample(&self, id: Id) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Convert integer representing an contig to its name.
sourcepub fn header_records(&self) -> Vec<HeaderRecord>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn header_records(&self) -> Vec<HeaderRecord>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Return structured HeaderRecord
s.
Trait Implementations
sourceimpl Clone for HeaderView
impl Clone for HeaderView
sourceimpl Debug for HeaderView
impl Debug for HeaderView
Auto Trait Implementations
impl RefUnwindSafe for HeaderView
impl !Send for HeaderView
impl !Sync for HeaderView
impl Unpin for HeaderView
impl UnwindSafe for HeaderView
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more