Struct noodles_bcf::record::Record
source · [−]pub struct Record { /* private fields */ }
Expand description
A BCF record.
Implementations
sourceimpl Record
impl Record
sourcepub fn try_into_vcf_record(
&self,
header: &Header,
string_maps: &StringMaps
) -> Result<Record>
pub fn try_into_vcf_record(
&self,
header: &Header,
string_maps: &StringMaps
) -> Result<Record>
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);
sourceimpl Record
impl Record
sourcepub fn chromosome_id(&self) -> ChromosomeId
pub fn chromosome_id(&self) -> ChromosomeId
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);
sourcepub fn position(&self) -> Position
pub fn position(&self) -> Position
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);
sourcepub fn position_mut(&mut self) -> &mut Position
pub fn position_mut(&mut self) -> &mut Position
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);
sourcepub fn end(&self) -> Result<Position>
pub fn end(&self) -> Result<Position>
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);
sourcepub fn quality_score(&self) -> Option<QualityScore>
pub fn quality_score(&self) -> Option<QualityScore>
Returns the quality score.
Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.quality_score().is_none());
sourcepub fn quality_score_mut(&mut self) -> &mut Option<QualityScore>
pub fn quality_score_mut(&mut self) -> &mut Option<QualityScore>
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));
sourcepub fn ids(&self) -> &Ids
pub fn ids(&self) -> &Ids
Returns the IDs.
Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.ids().is_empty());
sourcepub fn ids_mut(&mut self) -> &mut Ids
pub fn ids_mut(&mut self) -> &mut Ids
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);
sourcepub fn filters(&self) -> &Filters
pub fn filters(&self) -> &Filters
Returns the filters.
Examples
use noodles_bcf as bcf;
let record = bcf::Record::default();
assert!(record.filters().is_empty());
Trait Implementations
impl StructuralPartialEq for Record
Auto Trait Implementations
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnwindSafe for Record
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> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more