Struct noodles_vcf::record::Record[][src]

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

A VCF record.

A VCF record has 8 required fields: chromosome (CHROM), position (POS), IDs (ID), reference bases (REF), alternate bases (ALT), quality score (QUAL), filters (FILTER), and information (INFO).

Additionally, each record can have genotype information. This adds the extra FORMAT field and a number of genotype fields.

Implementations

Returns a builder to create a record from each of its fields.

Examples

use noodles_vcf as vcf;
let builder = vcf::Record::builder();

Returns the chromosome of the record.

The chromosome is either a reference sequence name or a symbol (<identifier>).

This is a required field and guaranteed to be set.

Examples

use noodles_vcf::{self as vcf, record::{Chromosome, Position}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(record.chromosome(), &Chromosome::Name(String::from("sq0")));

Returns the start position of the reference bases or indicates a telomeric breakend.

This field is overloaded. If the record represents a telomere, the telomeric breakends are set to 0 and n + 1, where n is the length of the chromosome. Otherwise, it is a 1-based start position of the reference bases.

This is a required field. It is guaranteed to be set and >= 0.

Examples

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

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(8)?)
    .set_reference_bases("A".parse()?)
    .build()?;

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

Returns a list of IDs of the record.

Examples

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

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_ids("nd0".parse()?)
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(*record.ids(), "nd0".parse()?);

Returns the reference bases of the record.

This is a required field and guaranteed to be nonempty.

Examples

use noodles_vcf::{
    self as vcf,
    record::{reference_bases::Base, Position, ReferenceBases},
};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(
    record.reference_bases(),
    &ReferenceBases::try_from(vec![Base::A])?,
);

Returns the alternate bases of the record.

Examples

use noodles_vcf::{
    self as vcf,
    record::{alternate_bases::Allele, reference_bases::Base, AlternateBases, Position},
};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .set_alternate_bases("C".parse()?)
    .build()?;

assert_eq!(
    record.alternate_bases(),
    &AlternateBases::from(vec![Allele::Bases(vec![Base::C])]),
);

Returns the quality score of the record.

The quality score is a Phred quality score.

Examples

use std::convert::TryFrom;
use noodles_vcf::{self as vcf, record::{Position, QualityScore}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .set_quality_score(QualityScore::try_from(13.0)?)
    .build()?;

assert_eq!(*record.quality_score(), Some(13.0));

Returns the filters of the record.

The filters can either be pass (PASS), a list of filter names that caused the record to fail, (e.g., q10), or missing (.).

Examples

use noodles_vcf::{self as vcf, record::{Filters, Position}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .set_filters(Filters::Pass)
    .build()?;

assert_eq!(record.filters(), &Filters::Pass);

Returns the addition information of the record.

Examples

use noodles_vcf::{
    self as vcf,
    record::{info::{field::{Key, Value}, Field}, Info, Position},
};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .set_alternate_bases("C".parse()?)
    .set_info("NS=3;AF=0.5".parse()?)
    .build()?;

let expected = Info::try_from(vec![
    Field::new(Key::SamplesWithDataCount, Value::Integer(3)),
    Field::new(Key::AlleleFrequencies, Value::FloatArray(vec![0.5])),
])?;

assert_eq!(record.info(), &expected);

Returns the format of the genotypes of the record.

Examples

use noodles_vcf::{
    self as vcf,
    record::{genotype::field::Key, Format, Genotype, Position},
};

let format: Format = "GT:GQ".parse()?;

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .set_format(format.clone())
    .add_genotype(Genotype::from_str_format("0|0:13", &format)?)
    .build()?;

assert_eq!(record.format(), Some(&Format::try_from(vec![
    Key::Genotype,
    Key::ConditionalGenotypeQuality,
])?));

Returns the genotypes of the record.

Examples

use noodles_vcf::{
    self as vcf,
    record::{genotype::{field::{Key, Value}, Field}, Format, Genotype, Position},
};

let format: Format = "GT:GQ".parse()?;

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("A".parse()?)
    .set_format(format.clone())
    .add_genotype(Genotype::from_str_format("0|0:13", &format)?)
    .build()?;

assert_eq!(record.genotypes(), [
    Genotype::try_from(vec![
        Field::new(Key::Genotype, Some(Value::String(String::from("0|0")))),
        Field::new(Key::ConditionalGenotypeQuality, Some(Value::Integer(13))),
    ])?,
]);

Returns or calculates the end position on the reference sequence.

If available, this returns the value of the END INFO field. Otherwise, it is calculated using the start position and reference bases length.

The end position is 1-based, inclusive.

Examples

From the END INFO field value

use noodles_vcf::{self as vcf, record::{Chromosome, Position}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("ACGT".parse()?)
    .set_info("END=8".parse()?)
    .build()?;

assert_eq!(record.end(), Ok(Position::try_from(8)?));

Calculated using the start position and reference bases length

use noodles_vcf::{self as vcf, record::{Chromosome, Position}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::try_from(1)?)
    .set_reference_bases("ACGT".parse()?)
    .build()?;

assert_eq!(record.end(), Ok(Position::try_from(4)?));

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

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this 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

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

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)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. 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.