Struct noodles_vcf::header::Builder
source · pub struct Builder { /* private fields */ }
Expand description
A VCF header builder.
Implementations§
source§impl Builder
impl Builder
sourcepub fn set_file_format(self, file_format: FileFormat) -> Self
pub fn set_file_format(self, file_format: FileFormat) -> Self
Sets the fileformat record (fileformat
).
§Examples
use noodles_vcf::{self as vcf, header::FileFormat};
let header = vcf::Header::builder()
.set_file_format(FileFormat::default())
.build();
assert_eq!(header.file_format(), FileFormat::default());
sourcepub fn add_info<I>(self, id: I, info: Map<Info>) -> Self
pub fn add_info<I>(self, id: I, info: Map<Info>) -> Self
Adds an information record (INFO
).
§Examples
use noodles_vcf::{
self as vcf,
header::record::value::{map::Info, Map},
variant::record::info::field::key,
};
let id = key::SAMPLES_WITH_DATA_COUNT;
let info = Map::<Info>::from(id);
let header = vcf::Header::builder()
.add_info(id, info.clone())
.build();
let infos = header.infos();
assert_eq!(infos.len(), 1);
assert_eq!(&infos[0], &info);
sourcepub fn add_filter<I>(self, id: I, filter: Map<Filter>) -> Self
pub fn add_filter<I>(self, id: I, filter: Map<Filter>) -> Self
Adds a filter record (FILTER
).
§Examples
use noodles_vcf::{self as vcf, header::record::value::{map::Filter, Map}};
let filter = Map::<Filter>::new("Quality below 10");
let header = vcf::Header::builder()
.add_filter("q10", filter.clone())
.build();
let filters = header.filters();
assert_eq!(filters.len(), 1);
assert_eq!(&filters[0], &filter);
sourcepub fn add_format<I>(self, id: I, format: Map<Format>) -> Self
pub fn add_format<I>(self, id: I, format: Map<Format>) -> Self
Adds a genotype format record (FORMAT
).
§Examples
use noodles_vcf::{
self as vcf,
header::record::value::{map::Format, Map},
variant::record::samples::keys::key,
};
let id = key::GENOTYPE;
let format = Map::<Format>::from(id);
let header = vcf::Header::builder()
.add_format(id, format.clone())
.build();
let formats = header.formats();
assert_eq!(formats.len(), 1);
assert_eq!(&formats[0], &format);
sourcepub fn add_alternative_allele<I>(
self,
id: I,
alternative_allele: Map<AlternativeAllele>,
) -> Self
pub fn add_alternative_allele<I>( self, id: I, alternative_allele: Map<AlternativeAllele>, ) -> Self
Adds an alternative allele record (ALT
).
§Examples
use noodles_vcf::{
self as vcf,
header::record::value::{map::AlternativeAllele, Map},
};
let alt = Map::<AlternativeAllele>::new("Deletion");
let header = vcf::Header::builder()
.add_alternative_allele("DEL", alt.clone())
.build();
let alternative_alleles = header.alternative_alleles();
assert_eq!(alternative_alleles.len(), 1);
assert_eq!(&alternative_alleles[0], &alt);
sourcepub fn add_contig<I>(self, id: I, contig: Map<Contig>) -> Self
pub fn add_contig<I>(self, id: I, contig: Map<Contig>) -> Self
Adds a contig record (contig
).
§Examples
use noodles_vcf::{self as vcf, header::record::value::{map::Contig, Map}};
let contig = Map::<Contig>::new();
let header = vcf::Header::builder()
.add_contig("sq0", contig.clone())
.build();
let contigs = header.contigs();
assert_eq!(contigs.len(), 1);
assert_eq!(&contigs[0], &contig);
sourcepub fn set_sample_names(self, sample_names: SampleNames) -> Self
pub fn set_sample_names(self, sample_names: SampleNames) -> Self
Sets sample names.
§Examples
use indexmap::IndexSet;
use noodles_vcf as vcf;
let sample_names: IndexSet<_> = [String::from("sample0")]
.into_iter()
.collect();
let header = vcf::Header::builder()
.set_sample_names(sample_names.clone())
.build();
assert_eq!(header.sample_names(), &sample_names);
sourcepub fn add_sample_name<I>(self, sample_name: I) -> Self
pub fn add_sample_name<I>(self, sample_name: I) -> Self
Adds a sample name.
Duplicate names are discarded.
§Examples
use indexmap::IndexSet;
use noodles_vcf as vcf;
let header = vcf::Header::builder()
.add_sample_name("sample0")
.add_sample_name("sample1")
.build();
let expected: IndexSet<_> = [String::from("sample0"), String::from("sample1")]
.into_iter()
.collect();
assert_eq!(header.sample_names(), &expected);
sourcepub fn insert(self, key: Other, value: Value) -> Result<Self, AddError>
pub fn insert(self, key: Other, value: Value) -> Result<Self, AddError>
Inserts a key-value pair representing an unstructured record into the header.
§Examples
use noodles_vcf::{
self as vcf,
header::record::{value::Collection, Value},
};
let header = vcf::Header::builder()
.insert("fileDate".parse()?, Value::from("20200709"))?
.build();
assert_eq!(
header.get("fileDate"),
Some(&Collection::Unstructured(vec![String::from("20200709")]))
);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
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