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::genotypes::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"),
[
(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<_> = [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
Auto Trait Implementations
impl RefUnwindSafe for Header
impl UnwindSafe for Header
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.