Struct noodles_vcf::header::Header

source ·
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, 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);

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

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

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

let info = Map::<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::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);

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

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

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

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

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

Returns a list of genotype format records (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);

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

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

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

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

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

Returns a map of symbolic alternate alleles (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);

Returns a mutable reference to a map of symbolic alternate alleles (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 mut header = vcf::Header::default();

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

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

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

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

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

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

let contig = Map::<Contig>::new("sq0".parse()?);
header.contigs_mut().insert(contig.id().clone(), 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::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);

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

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

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

let meta = Map::<Meta>::new(
    "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 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);
👎Deprecated since 0.18.0: Use Header::other_records instead.

Returns a map of records with nonstandard keys.

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::{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.records().first(),
    Some((&key, &vec![value])),
);

Returns a map of records with nonstandard keys.

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::{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.other_records().first(),
    Some((&key, &vec![value])),
);
👎Deprecated since 0.18.0: Use Header::other_records_mut instead.

Returns a mutable reference to a map of records with nonstandard keys.

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::{self, Key}}};

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

let mut header = vcf::Header::default();
header.records_mut().insert(key.clone(), vec![value.clone()]);

assert_eq!(
    header.records().first(),
    Some((&key, &vec![value])),
);

Returns a mutable reference to a map of records with nonstandard keys.

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::{self, Key}}};

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

let mut header = vcf::Header::default();
header.other_records_mut().insert(key.clone(), vec![value.clone()]);

assert_eq!(
    header.other_records().first(),
    Some((&key, &vec![value])),
);

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::{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][..]));
assert!(header.get(&Key::from("reference")).is_none());

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 mut header = vcf::Header::default();
assert!(header.get(&key).is_none());

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

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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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
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