pub struct Record { /* private fields */ }
Expand description

A BCF record.

Implementations

Converts a VCF record to a BCF record.

Examples
use noodles_bcf as bcf;
use noodles_vcf::{self as vcf, record::Position};

let raw_header = "##fileformat=VCFv4.3\n##contig=<ID=sq0>\n#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n";
let header: vcf::Header = raw_header.parse()?;
let string_maps = raw_header.parse()?;

let record = bcf::Record::default();

let actual = record.try_into_vcf_record(&header, &string_maps)?;
let expected = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(actual, expected);

Returns the chromosome ID of the record.

The chromosome ID represents an index in the contig string map, which associates an ID (by position) with a contig record in the VCF header (by name). That is, to get the associated contig record in the VCF header, the contig string map must first be queried by position to find the chromosome name, and then the contigs in the VCF header can be queried by name.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert_eq!(record.chromosome_id(), 0);

Returns the start position of this record.

Despite the BCF format using 0-based positions, this normalizes the value as a 1-based position.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert_eq!(i32::from(record.position()), 1);

Returns a mutable reference to the start position.

Examples
use noodles_bcf as bcf;
use noodles_vcf::record::Position;

let mut record = bcf::Record::default();
*record.position_mut() = Position::try_from(8)?;

assert_eq!(i32::from(record.position()), 8);

Returns the end position of this record.

This value is 1-based.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert_eq!(record.end().map(i32::from)?, 1);

Returns the quality score.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.quality_score().is_none());

Return a mutable reference to the quality score.

Examples
use noodles_bcf as bcf;
use noodles_vcf::record::QualityScore;

let mut record = bcf::Record::default();
*record.quality_score_mut() = QualityScore::try_from(13.0).map(Some)?;

assert_eq!(record.quality_score().map(f32::from), Some(13.0));

Returns the IDs.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.ids().is_empty());

Returns a mutable reference to the IDs.

Examples
use noodles_bcf as bcf;
use noodles_vcf::record::Ids;

let mut record = bcf::Record::default();
let ids: Ids = "nd0".parse()?;
*record.ids_mut() = ids.clone();

assert_eq!(record.ids(), &ids);

Returns the filters.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.filters().is_empty());

Returns the info.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.info().is_empty());

Returns the genotypes.

Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.genotypes().is_empty());

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

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

Returns the argument unchanged.

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

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

Uses borrowed data to replace owned data, usually by cloning. 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.