Struct noodles_vcf::header::Header[][src]

pub struct Header { /* fields omitted */ }
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 reqiured 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 map of information records (INFO).

Examples

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

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 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 list of genotype format records (FORMAT).

Examples

use noodles_vcf::{self as vcf, header::Format, record::genotype::field::Key};

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 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 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 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 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 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 map of pedigree records (PEDIGREE).

Examples

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

let pedigree = Pedigree::new(
    String::from("cid"),
    vec![
        (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 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 list 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<_> = vec![String::from("sample0"), String::from("sample1")]
    .into_iter()
    .collect();

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

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

Converts self into T using Into<T>. Read more

Converts self into a target type. Read more

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

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. 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.