pub struct Builder { /* private fields */ }
Expand description

A VCF header builder.

Implementations

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());

Adds an information record (INFO).

Examples
use noodles_vcf::{
    self as vcf,
    header::{info::Key, record::value::{map::Info, Map}},
};

let info = Map::<Info>::from(Key::SamplesWithDataCount);

let header = vcf::Header::builder()
    .add_info(info.clone())
    .build();

let infos = header.infos();
assert_eq!(infos.len(), 1);
assert_eq!(&infos[0], &info);

Adds a filter record (FILTER).

Examples
use noodles_vcf::{self as vcf, header::record::value::{map::Filter, Map}};

let filter = Map::<Filter>::new("q10", "Quality below 10");

let header = vcf::Header::builder()
    .add_filter(filter.clone())
    .build();

let filters = header.filters();
assert_eq!(filters.len(), 1);
assert_eq!(&filters[0], &filter);

Adds a genotype format record (FORMAT).

Examples
use noodles_vcf::{
    self as vcf,
    header::{format::Key, record::value::{map::Format, Map}},
};

let format = Map::<Format>::from(Key::Genotype);

let header = vcf::Header::builder()
    .add_format(format.clone())
    .build();

let formats = header.formats();
assert_eq!(formats.len(), 1);
assert_eq!(&formats[0], &format);

Adds an alternative allele record (ALT).

Examples
use noodles_vcf::{
    self as vcf,
    header::record::value::{map::AlternativeAllele, Map},
    record::alternate_bases::allele::{
        symbol::{structural_variant::Type, StructuralVariant},
        Symbol,
    },
};

let alt = Map::<AlternativeAllele>::new(
    Symbol::StructuralVariant(StructuralVariant::from(Type::Deletion)),
    "Deletion",
);

let header = vcf::Header::builder()
    .add_alternative_allele(alt.clone())
    .build();

let alternative_alleles = header.alternative_alleles();
assert_eq!(alternative_alleles.len(), 1);
assert_eq!(&alternative_alleles[0], &alt);

Sets an breakpoint assemblies record (assembly).

Examples
use noodles_vcf as vcf;

let header = vcf::Header::builder()
    .set_assembly("file:///assemblies.fasta")
    .build();

assert_eq!(header.assembly(), Some("file:///assemblies.fasta"));

Adds a contig record (contig).

Examples
use noodles_vcf::{self as vcf, header::record::value::{map::Contig, Map}};

let contig = Map::<Contig>::new("sq0".parse()?);

let header = vcf::Header::builder()
    .add_contig(contig.clone())
    .build();

let contigs = header.contigs();
assert_eq!(contigs.len(), 1);
assert_eq!(&contigs[0], &contig);

Adds a meta record (META).

Examples
use noodles_vcf::{self as vcf, header::record::value::{map::Meta, Map}};

let meta = Map::<Meta>::new(
    "Assay",
    vec![String::from("WholeGenome"), String::from("Exome")],
);

let header = vcf::Header::builder()
    .add_meta(meta.clone())
    .build();

let records = header.meta();
assert_eq!(records.len(), 1);
assert_eq!(&records[0], &meta);

Sets a pedigree database record (pedigreeDB).

Examples
use noodles_vcf as vcf;

let header = vcf::Header::builder()
    .set_pedigree_db("file:///pedigree.db")
    .build();

assert_eq!(header.pedigree_db(), Some("file:///pedigree.db"));

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);

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);

Inserts a key-value pair representing an unstructured record into the header.

Examples
use noodles_vcf::{self as vcf, header::{record::{self, Key}}};

let key = Key::from("fileDate");
let value = record::value::Other::from("20200709");

let header = vcf::Header::builder()
    .insert(key.clone(), value.clone())
    .build();

assert_eq!(header.get(&key), Some(&[value][..]));

Builds a VCF header.

Examples
use noodles_vcf as vcf;
let header = vcf::Header::builder().build();

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more