Struct noodles_vcf::variant::record_buf::RecordBuf
source · pub struct RecordBuf { /* private fields */ }
Expand description
A variant record buffer.
Implementations§
source§impl RecordBuf
impl RecordBuf
sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Returns a builder to create a record from each of its fields.
§Examples
use noodles_vcf as vcf;
let builder = vcf::variant::RecordBuf::builder();
sourcepub fn reference_sequence_name(&self) -> &str
pub fn reference_sequence_name(&self) -> &str
Returns the reference sequence name.
§Examples
use noodles_vcf as vcf;
let record = vcf::variant::RecordBuf::builder()
.set_reference_sequence_name("sq0")
.build();
assert_eq!(record.reference_sequence_name(), "sq0");
sourcepub fn reference_sequence_name_mut(&mut self) -> &mut String
pub fn reference_sequence_name_mut(&mut self) -> &mut String
Returns a mutable reference to the reference sequence name.
§Examples
use noodles_vcf as vcf;
let mut record = vcf::variant::RecordBuf::builder()
.set_reference_sequence_name("sq0")
.build();
*record.reference_sequence_name_mut() = String::from("sq1");
assert_eq!(record.reference_sequence_name(), "sq1");
sourcepub fn variant_start(&self) -> Option<Position>
pub fn variant_start(&self) -> Option<Position>
Returns the variant start position.
If the record represents the start of a telomeric breakend, this returns None
.
§Examples
use noodles_core::Position;
use noodles_vcf as vcf;
let record = vcf::variant::RecordBuf::builder()
.set_variant_start(Position::MIN)
.build();
assert_eq!(record.variant_start(), Some(Position::MIN));
sourcepub fn variant_start_mut(&mut self) -> &mut Option<Position>
pub fn variant_start_mut(&mut self) -> &mut Option<Position>
Returns a mutable reference to the variant start position.
If the record represents the start of a telomeric breakend, this returns None
.
§Examples
use noodles_core::Position;
use noodles_vcf as vcf;
let mut record = vcf::variant::RecordBuf::default();
*record.variant_start_mut() = Some(Position::MIN);
assert_eq!(record.variant_start(), Some(Position::MIN));
sourcepub fn ids(&self) -> &Ids
pub fn ids(&self) -> &Ids
Returns a list of IDs of the record.
§Examples
use noodles_vcf::{self as vcf, variant::record_buf::Ids};
let ids: Ids = [String::from("nd0")].into_iter().collect();
let record = vcf::variant::RecordBuf::builder()
.set_ids(ids.clone())
.build();
assert_eq!(record.ids(), &ids);
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_vcf::{self as vcf, variant::record_buf::Ids};
let mut record = vcf::variant::RecordBuf::default();
let ids: Ids = [String::from("nd0")].into_iter().collect();
*record.ids_mut() = ids.clone();
assert_eq!(record.ids(), &ids);
sourcepub fn reference_bases(&self) -> &str
pub fn reference_bases(&self) -> &str
Returns the reference bases of the record.
§Examples
use noodles_vcf as vcf;
let record = vcf::variant::RecordBuf::builder()
.set_reference_bases("A")
.build();
assert_eq!(record.reference_bases(), "A");
sourcepub fn reference_bases_mut(&mut self) -> &mut String
pub fn reference_bases_mut(&mut self) -> &mut String
Returns a mutable reference to the reference bases of the record.
§Examples
use noodles_vcf as vcf;
let mut record = vcf::variant::RecordBuf::builder()
.set_reference_bases("A")
.build();
*record.reference_bases_mut() = String::from("T");
assert_eq!(record.reference_bases(), "T");
sourcepub fn alternate_bases(&self) -> &AlternateBases
pub fn alternate_bases(&self) -> &AlternateBases
Returns the alternate bases of the record.
§Examples
use noodles_vcf::{self as vcf, variant::record_buf::AlternateBases};
let alternate_bases = AlternateBases::from(vec![String::from("C")]);
let record = vcf::variant::RecordBuf::builder()
.set_alternate_bases(alternate_bases.clone())
.build();
assert_eq!(record.alternate_bases(), &alternate_bases);
sourcepub fn alternate_bases_mut(&mut self) -> &mut AlternateBases
pub fn alternate_bases_mut(&mut self) -> &mut AlternateBases
Returns a mutable reference to the alternate bases of the record.
§Examples
use noodles_vcf::{self as vcf, variant::record_buf::AlternateBases};
let mut record = vcf::variant::RecordBuf::builder()
.set_reference_bases("A")
.build();
let alternate_bases = AlternateBases::from(vec![String::from("C")]);
*record.alternate_bases_mut() = alternate_bases.clone();
assert_eq!(record.alternate_bases(), &alternate_bases);
sourcepub fn quality_score(&self) -> Option<f32>
pub fn quality_score(&self) -> Option<f32>
Returns the quality score of the record.
§Examples
use noodles_vcf as vcf;
let record = vcf::variant::RecordBuf::builder()
.set_quality_score(13.0)
.build();
assert_eq!(record.quality_score(), Some(13.0));
sourcepub fn quality_score_mut(&mut self) -> &mut Option<f32>
pub fn quality_score_mut(&mut self) -> &mut Option<f32>
Returns a mutable reference to the quality score.
§Examples
use noodles_vcf as vcf;
let mut record = vcf::variant::RecordBuf::default();
*record.quality_score_mut() = Some(13.0);
assert_eq!(record.quality_score(), Some(13.0));
sourcepub fn filters(&self) -> &Filters
pub fn filters(&self) -> &Filters
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, variant::record_buf::Filters};
let record = vcf::variant::RecordBuf::builder()
.set_filters(Filters::pass())
.build();
assert!(record.filters().is_pass());
sourcepub fn filters_mut(&mut self) -> &mut Filters
pub fn filters_mut(&mut self) -> &mut Filters
Returns a mutable reference to the filters.
§Examples
use noodles_vcf::{self as vcf, variant::record_buf::Filters};
let mut record = vcf::variant::RecordBuf::default();
*record.filters_mut() = Filters::pass();
assert!(record.filters().is_pass());
sourcepub fn info(&self) -> &Info
pub fn info(&self) -> &Info
Returns the addition information of the record.
§Examples
use noodles_vcf::{
self as vcf,
variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
},
};
let info: Info = [
(String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::from(3))),
(String::from(key::ALLELE_FREQUENCIES), Some(Value::from(vec![Some(0.5)]))),
]
.into_iter()
.collect();
let record = vcf::variant::RecordBuf::builder()
.set_info(info.clone())
.build();
assert_eq!(record.info(), &info);
sourcepub fn info_mut(&mut self) -> &mut Info
pub fn info_mut(&mut self) -> &mut Info
Returns a mutable reference to the additional info fields.
§Examples
use noodles_vcf::{
self as vcf,
variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
}
};
let info: Info = [
(String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::from(3))),
(String::from(key::ALLELE_FREQUENCIES), Some(Value::from(vec![Some(0.5)]))),
]
.into_iter()
.collect();
let mut record = vcf::variant::RecordBuf::builder()
.set_info(info)
.build();
record.info_mut().insert(String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let expected = [
(String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(3))),
(String::from(key::ALLELE_FREQUENCIES), Some(Value::from(vec![Some(0.5)]))),
(String::from(key::TOTAL_DEPTH), Some(Value::Integer(13))),
]
.into_iter()
.collect();
assert_eq!(record.info(), &expected);
sourcepub fn format(&self) -> &Keys
pub fn format(&self) -> &Keys
Returns the format of the genotypes of the record.
§Examples
use noodles_vcf::{
self as vcf,
variant::{
record::samples::keys::key,
record_buf::{samples::{sample::Value, Keys}, Samples},
},
};
let keys: Keys = [
String::from(key::GENOTYPE),
String::from(key::CONDITIONAL_GENOTYPE_QUALITY),
].into_iter().collect();
let samples = Samples::new(
keys.clone(),
vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);
let record = vcf::variant::RecordBuf::builder()
.set_samples(samples)
.build();
assert_eq!(record.format(), &keys);
sourcepub fn samples(&self) -> &Samples
pub fn samples(&self) -> &Samples
Returns the genotypes of the record.
§Examples
use noodles_vcf::{
self as vcf,
variant::{
record::samples::keys::key,
record_buf::{samples::sample::Value, Samples},
},
};
let keys = [
String::from(key::GENOTYPE),
String::from(key::CONDITIONAL_GENOTYPE_QUALITY),
].into_iter().collect();
let samples = Samples::new(
keys,
vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);
let record = vcf::variant::RecordBuf::builder()
.set_samples(samples.clone())
.build();
assert_eq!(record.samples(), &samples);
sourcepub fn samples_mut(&mut self) -> &mut Samples
pub fn samples_mut(&mut self) -> &mut Samples
Returns a mutable reference to the genotypes of the record.
§Examples
use noodles_vcf::{
self as vcf,
variant::{
record::samples::keys::key,
record_buf::{samples::sample::Value, Samples},
},
};
let mut record = vcf::variant::RecordBuf::default();
let keys = [
String::from(key::GENOTYPE),
String::from(key::CONDITIONAL_GENOTYPE_QUALITY),
].into_iter().collect();
let samples = Samples::new(
keys,
vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);
*record.samples_mut() = samples.clone();
assert_eq!(record.samples(), &samples);