pub struct MetadataBuilder { /* private fields */ }Expand description
Builder for Metadata.
Implementations§
Source§impl MetadataBuilder
impl MetadataBuilder
Sourcepub fn fid<AnyString0, AnyIter1>(&mut self, fid: AnyIter1) -> &mut Self
pub fn fid<AnyString0, AnyIter1>(&mut self, fid: AnyIter1) -> &mut Self
Set the family id (fid) values.
Sourcepub fn iid<AnyString0, AnyIter1>(&mut self, iid: AnyIter1) -> &mut Self
pub fn iid<AnyString0, AnyIter1>(&mut self, iid: AnyIter1) -> &mut Self
Set the individual id (iid) values.
use ndarray as nd;
use bed_reader::{Metadata, assert_eq_nan};
let metadata = Metadata::builder()
.iid(["sample1", "sample2", "sample3"])
.build()?;
println!("{:?}", metadata.iid()); // Outputs ndarray Some(["sample1", "sample2", "sample3"])Sourcepub fn father<AnyString0, AnyIter1>(&mut self, father: AnyIter1) -> &mut Self
pub fn father<AnyString0, AnyIter1>(&mut self, father: AnyIter1) -> &mut Self
Set the father values.
Sourcepub fn mother<AnyString0, AnyIter1>(&mut self, mother: AnyIter1) -> &mut Self
pub fn mother<AnyString0, AnyIter1>(&mut self, mother: AnyIter1) -> &mut Self
Override the mother values.
Sourcepub fn sex<AnyIter0>(&mut self, sex: AnyIter0) -> &mut Selfwhere
AnyIter0: IntoIterator<Item = i32>,
pub fn sex<AnyIter0>(&mut self, sex: AnyIter0) -> &mut Selfwhere
AnyIter0: IntoIterator<Item = i32>,
Override the sex values.
Sourcepub fn pheno<AnyString0, AnyIter1>(&mut self, pheno: AnyIter1) -> &mut Self
pub fn pheno<AnyString0, AnyIter1>(&mut self, pheno: AnyIter1) -> &mut Self
Override the phenotype values.
Sourcepub fn chromosome<AnyString0, AnyIter1>(
&mut self,
chromosome: AnyIter1,
) -> &mut Self
pub fn chromosome<AnyString0, AnyIter1>( &mut self, chromosome: AnyIter1, ) -> &mut Self
Override the chromosome values.
Sourcepub fn sid<AnyString0, AnyIter1>(&mut self, sid: AnyIter1) -> &mut Self
pub fn sid<AnyString0, AnyIter1>(&mut self, sid: AnyIter1) -> &mut Self
Override the SNP id (sid) values.
use ndarray as nd;
use bed_reader::{Metadata, assert_eq_nan};
let metadata = Metadata::builder()
.sid(["SNP1", "SNP2", "SNP3", "SNP4"])
.build()?;
println!("{:?}", metadata.sid()); // Outputs ndarray Some(["SNP1", "SNP2", "SNP3", "SNP4"])Sourcepub fn cm_position<AnyIter0>(&mut self, cm_position: AnyIter0) -> &mut Selfwhere
AnyIter0: IntoIterator<Item = f32>,
pub fn cm_position<AnyIter0>(&mut self, cm_position: AnyIter0) -> &mut Selfwhere
AnyIter0: IntoIterator<Item = f32>,
Override the centimorgan position values.
Sourcepub fn bp_position<AnyIter0>(&mut self, bp_position: AnyIter0) -> &mut Selfwhere
AnyIter0: IntoIterator<Item = i32>,
pub fn bp_position<AnyIter0>(&mut self, bp_position: AnyIter0) -> &mut Selfwhere
AnyIter0: IntoIterator<Item = i32>,
Override the base-pair position values.
Sourcepub fn allele_1<AnyString0, AnyIter1>(
&mut self,
allele_1: AnyIter1,
) -> &mut Self
pub fn allele_1<AnyString0, AnyIter1>( &mut self, allele_1: AnyIter1, ) -> &mut Self
Override the allele 1 values.
Sourcepub fn allele_2<AnyString0, AnyIter1>(
&mut self,
allele_2: AnyIter1,
) -> &mut Self
pub fn allele_2<AnyString0, AnyIter1>( &mut self, allele_2: AnyIter1, ) -> &mut Self
Override the allele 2 values.
Sourcepub fn metadata(&mut self, metadata: &Metadata) -> &mut Self
pub fn metadata(&mut self, metadata: &Metadata) -> &mut Self
Merge metadata from a Metadata.
§Example
In the example, we create a Metadata with iid
and sid arrays. Next, we use another MetadataBuilder to set an fid array
and an iid array. Then, we add the first Metadata
to the MetadataBuilder,
overwriting iid and setting sid. Finally, we print these
three arrays and chromosome. Chromosome is None.
use ndarray as nd;
use bed_reader::Metadata;
let metadata1 = Metadata::builder()
.iid(["i1", "i2", "i3"])
.sid(["s1", "s2", "s3", "s4"])
.build()?;
let metadata2 = Metadata::builder()
.fid(["f1", "f2", "f3"])
.iid(["x1", "x2", "x3"])
.metadata(&metadata1)
.build()?;
println!("{0:?}", metadata2.fid()); // Outputs optional ndarray Some(["f1", "f2", "f3"]...)
println!("{0:?}", metadata2.iid()); // Outputs optional ndarray Some(["i1", "i2", "i3"]...)
println!("{0:?}", metadata2.sid()); // Outputs optional ndarray Some(["s1", "s2", "s3", "s4"]...)
println!("{0:?}", metadata2.chromosome()); // Outputs NoneTrait Implementations§
Source§impl Clone for MetadataBuilder
impl Clone for MetadataBuilder
Source§fn clone(&self) -> MetadataBuilder
fn clone(&self) -> MetadataBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MetadataBuilder
impl RefUnwindSafe for MetadataBuilder
impl !Send for MetadataBuilder
impl !Sync for MetadataBuilder
impl Unpin for MetadataBuilder
impl UnwindSafe for MetadataBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.