Struct noodles_vcf::header::Builder
source · [−]pub struct Builder { /* private fields */ }
Expand description
A VCF header builder.
Implementations
sourceimpl Builder
impl Builder
sourcepub fn set_file_format(self, file_format: FileFormat) -> Self
pub fn set_file_format(self, file_format: FileFormat) -> Self
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());
sourcepub fn add_info(self, info: Info) -> Self
pub fn add_info(self, info: Info) -> Self
Adds an information record (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);
sourcepub fn add_filter(self, filter: Filter) -> Self
pub fn add_filter(self, filter: Filter) -> Self
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");
sourcepub fn add_format(self, format: Format) -> Self
pub fn add_format(self, format: Format) -> Self
Adds a genotype format record (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);
sourcepub fn add_alternative_allele(
self,
alternative_allele: AlternativeAllele
) -> Self
pub fn add_alternative_allele(
self,
alternative_allele: AlternativeAllele
) -> Self
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)),
"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))
);
sourcepub fn set_assembly<I>(self, assembly: I) -> Self where
I: Into<String>,
pub fn set_assembly<I>(self, assembly: I) -> Self where
I: Into<String>,
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"));
sourcepub fn add_contig(self, contig: Contig) -> Self
pub fn add_contig(self, contig: Contig) -> Self
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")));
sourcepub fn add_meta(self, meta: Meta) -> Self
pub fn add_meta(self, meta: Meta) -> Self
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);
sourcepub fn add_sample(self, sample: Sample) -> Self
pub fn add_sample(self, sample: Sample) -> Self
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);
sourcepub fn add_pedigree(self, pedigree: Pedigree) -> Self
pub fn add_pedigree(self, pedigree: Pedigree) -> Self
Adds a pedigree record (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);
sourcepub fn set_pedigree_db<I>(self, pedigree_db: I) -> Self where
I: Into<String>,
pub fn set_pedigree_db<I>(self, pedigree_db: I) -> Self where
I: Into<String>,
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"));
sourcepub fn set_sample_names(self, sample_names: SampleNames) -> Self
pub fn set_sample_names(self, sample_names: SampleNames) -> Self
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);
sourcepub fn add_sample_name<I>(self, sample_name: I) -> Self where
I: Into<String>,
pub fn add_sample_name<I>(self, sample_name: I) -> Self where
I: Into<String>,
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);
sourcepub fn insert(self, record: Record) -> Self
pub fn insert(self, record: Record) -> Self
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][..]));
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more