Struct noodles_bcf::record::Record[][src]

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

A BCF record.

The fields of a bcf::Record are immutable. They can be read, but to make changes, it must first be converted to a vcf::Record (see Self::try_into_vcf_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_map = raw_header.parse()?;

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

let actual = record.try_into_vcf_record(&header, &string_map)?;
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 is the index of the associated contig in the VCF header.

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

Performs the conversion.

Performs the conversion.

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.