pub struct HeaderView {
pub inner: *mut bcf_hdr_t,
}
Fields§
§inner: *mut bcf_hdr_t
Implementations§
Source§impl 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 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> ⓘ
pub fn id_to_name(&self, id: Id) -> Vec<u8> ⓘ
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> ⓘ
pub fn id_to_sample(&self, id: Id) -> Vec<u8> ⓘ
Convert integer representing an contig to its name.
Sourcepub fn header_records(&self) -> Vec<HeaderRecord>
pub fn header_records(&self) -> Vec<HeaderRecord>
Return structured HeaderRecord
s.
Sourcepub fn empty_record(&self) -> Record
pub fn empty_record(&self) -> Record
Create an empty record using this header view.
The record can be reused multiple times.
Trait Implementations§
Source§impl Clone for HeaderView
impl Clone for HeaderView
Source§impl Debug for HeaderView
impl Debug for HeaderView
Auto Trait Implementations§
impl Freeze for HeaderView
impl RefUnwindSafe for HeaderView
impl !Send for HeaderView
impl !Sync for HeaderView
impl Unpin for HeaderView
impl UnwindSafe for HeaderView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more