Struct noodles_vcf::header::Builder[][src]

pub struct Builder { /* fields omitted */ }
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, 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);

Adds a filter record (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");

Adds a genotype format record (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);

Adds an alternative allele record (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)),
        String::from("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))
);

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::Contig};

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

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

Adds a meta record (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);

Adds a sample record (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);

Adds a pedigree record (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);

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<_> = vec![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<_> = vec![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::{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][..]));

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

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

Converts self into a target type. Read more

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

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.