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

A VCF header.

Implementations

Returns a builder to create a record from each of its fields.

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

Returns the file format (fileformat) of the VCF.

fileformat is a required meta record and is guaranteed to be set.

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

Returns a mutable reference to the file format (fileformat) of the VCF.

fileformat is a required meta record and is guaranteed to be set.

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

let mut header = vcf::Header::default();

let file_format = FileFormat::new(4, 2);
*header.file_format_mut() = file_format;

assert_eq!(header.file_format(), file_format);

Returns a map of information records (INFO).

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

let header = vcf::Header::builder()
    .add_info(Info::from(Key::SamplesWithDataCount))
    .build();

let infos = header.infos();
assert_eq!(infos.len(), 1);
assert_eq!(infos[0].id(), &Key::SamplesWithDataCount);

Returns a mutable reference to a map of information records (INFO).

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

let mut header = vcf::Header::default();

let info = Info::from(Key::SamplesWithDataCount);
header.infos_mut().insert(info.id().clone(), info);

let infos = header.infos();
assert_eq!(infos.len(), 1);
assert_eq!(infos[0].id(), &Key::SamplesWithDataCount);

Returns a map of filter records (FILTER).

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

let header = vcf::Header::builder()
    .add_filter(Filter::new("q10", "Quality below 10"))
    .build();

let filters = header.filters();
assert_eq!(filters.len(), 1);
assert_eq!(filters[0].id(), "q10");

Returns a mutable reference to a map of filter records (FILTER).

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

let mut header = vcf::Header::default();

let filter = Filter::new("q10", "Quality below 10");
header.filters_mut().insert(filter.id().into(), filter);

let filters = header.filters();
assert_eq!(filters.len(), 1);
assert_eq!(filters[0].id(), "q10");

Returns a list of genotype format records (FORMAT).

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

let header = vcf::Header::builder()
    .add_format(Format::from(Key::Genotype))
    .build();

let formats = header.formats();
assert_eq!(formats.len(), 1);
assert_eq!(formats[0].id(), &Key::Genotype);

Returns a mutable reference to a list of genotype format records (FORMAT).

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

let mut header = vcf::Header::default();

let format = Format::from(Key::Genotype);
header.formats_mut().insert(format.id().clone(), format);

let formats = header.formats();
assert_eq!(formats.len(), 1);
assert_eq!(formats[0].id(), &Key::Genotype);

Returns a map of symbolic alternate alleles (ALT).

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

let header = vcf::Header::builder()
    .add_alternative_allele(AlternativeAllele::new(
        Symbol::StructuralVariant(StructuralVariant::from(Type::Deletion)),
        "Deletion",
    ))
    .build();

let alternative_alleles = header.alternative_alleles();
assert_eq!(alternative_alleles.len(), 1);
assert_eq!(
    alternative_alleles[0].id(),
    &Symbol::StructuralVariant(StructuralVariant::from(Type::Deletion))
);

Returns a mutable reference to a map of symbolic alternate alleles (ALT).

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

let mut header = vcf::Header::default();

let alternative_allele = AlternativeAllele::new(
    Symbol::StructuralVariant(StructuralVariant::from(Type::Deletion)),
    "Deletion",
);
header
    .alternative_alleles_mut()
    .insert(alternative_allele.id().clone(), alternative_allele.clone());

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

Returns a URI to the breakpoint assemblies (assembly) referenced in records.

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

Returns a mutable reference to a URI to the breakpoint assemblies (assembly) referenced in records.

Examples
use noodles_vcf as vcf;
let mut header = vcf::Header::default();
*header.assembly_mut() = Some(String::from("file:///assemblies.fasta"));
assert_eq!(header.assembly(), Some("file:///assemblies.fasta"));

Returns a map of contig records (contig).

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

let header = vcf::Header::builder()
    .add_contig(Contig::new("sq0"))
    .build();

let contigs = header.contigs();
assert_eq!(contigs.len(), 1);
assert_eq!(contigs[0], Contig::new("sq0"));

Returns a mutable reference to a map of contig records (contig).

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

let mut header = vcf::Header::default();

let contig = Contig::new("sq0");
header.contigs_mut().insert(contig.id().into(), contig.clone());

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

Returns a map of meta records (META).

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

let meta = Meta::new(
    String::from("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);

Returns a mutable reference to a map of meta records (META).

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

let mut header = vcf::Header::default();

let meta = Meta::new(
    String::from("Assay"),
    vec![String::from("WholeGenome"), String::from("Exome")],
);
header.meta_mut().insert(meta.id().into(), meta.clone());

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

Returns a map of sample records (SAMPLE).

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

let sample = Sample::new(String::from("sample0"), Default::default());

let header = vcf::Header::builder()
    .add_sample(sample.clone())
    .build();

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

Returns a mutable reference to a map of sample records (SAMPLE).

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

let mut header = vcf::Header::default();

let sample = Sample::new(String::from("sample0"), Default::default());
header.samples_mut().insert(sample.id().into(), sample.clone());

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

Returns a map of pedigree records (PEDIGREE).

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

let pedigree = Pedigree::new(
    String::from("cid"),
    [
        (String::from("Father"), String::from("fid")),
        (String::from("Mother"), String::from("mid")),
    ]
    .into_iter()
    .collect(),
);

let header = vcf::Header::builder()
    .add_pedigree(pedigree.clone())
    .build();

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

Returns a mutable reference to a map of pedigree records (PEDIGREE).

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

let mut header = vcf::Header::default();

let pedigree = Pedigree::new(
    String::from("cid"),
    [
        (String::from("Father"), String::from("fid")),
        (String::from("Mother"), String::from("mid")),
    ]
    .into_iter()
    .collect(),
);
header.pedigrees_mut().insert(pedigree.id().into(), pedigree.clone());

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

Returns a URI to the relationships between genomes (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"));

Returns a mutable reference to a URI to the relationships between genomes (pedigreeDB).

Examples
use noodles_vcf as vcf;
let mut header = vcf::Header::default();
*header.pedigree_db_mut() = Some(String::from("file:///pedigree.db"));
assert_eq!(header.pedigree_db(), Some("file:///pedigree.db"));

Returns a list of sample names that come after the FORMAT column in the header record.

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

Returns a mutable reference to a list of sample names that come after the FORMAT column in the header record.

Examples
use indexmap::IndexSet;
use noodles_vcf as vcf;

let mut header = vcf::Header::builder().add_sample_name("sample0").build();
header.sample_names_mut().insert(String::from("sample1"));

let expected: IndexSet<_> = [String::from("sample0"), String::from("sample1")]
    .into_iter()
    .collect();

assert_eq!(header.sample_names(), &expected);

Returns a map of the unstructured header records.

This includes all records other than fileformat, INFO, FILTER, FORMAT, ALT, assembly, contig, META, SAMPLE, and pedigreeDB.

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

let record = Record::new(
    Key::Other(String::from("fileDate")),
    Value::String(String::from("20200709")),
);

let header = vcf::Header::builder().insert(record.clone()).build();

assert_eq!(
    header.records().first(),
    Some((&String::from("fileDate"), &vec![record])),
);

Returns a mutable reference to a map of the unstructured header records.

This includes all records other than fileformat, INFO, FILTER, FORMAT, ALT, assembly, contig, META, SAMPLE, and pedigreeDB.

To simply add an unstructured record, consider using Self::insert instead.

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

let mut header = vcf::Header::default();

let record = Record::new(
    Key::Other(String::from("fileDate")),
    Value::String(String::from("20200709")),
);

header.records_mut().insert(String::from("fileDate"), vec![record.clone()]);

assert_eq!(
    header.records().first(),
    Some((&String::from("fileDate"), &vec![record])),
);

Returns a header record with the given key.

This includes all records other than fileformat, INFO, FILTER, FORMAT, ALT, assembly, contig, META, SAMPLE, and pedigreeDB.

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

let record = Record::new(
    Key::Other(String::from("fileDate")),
    Value::String(String::from("20200709")),
);

let header = vcf::Header::builder().insert(record.clone()).build();

assert_eq!(header.get("fileDate"), Some(&[record][..]));
assert_eq!(header.get("reference"), None);

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

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

let record = Record::new(
    Key::Other(String::from("fileDate")),
    Value::String(String::from("20200709")),
);

let mut header = vcf::Header::default();

assert!(header.get("fileDate").is_none());

header.insert(record.clone());

assert_eq!(header.get("fileDate"), Some(&[record][..]));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Compare self to key and return true if they are equal.

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

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