Struct rust_htslib::bcf::header::HeaderView
source · 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.