Struct bed_reader::MetadataBuilder
source · [−]pub struct MetadataBuilder { /* private fields */ }Expand description
Builder for Metadata.
Implementations
sourceimpl MetadataBuilder
impl MetadataBuilder
sourcepub fn fid<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
fid: I
) -> &mut Self
pub fn fid<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
fid: I
) -> &mut Self
Set the family id (fid) values.
sourcepub fn iid<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
iid: I
) -> &mut Self
pub fn iid<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
iid: I
) -> &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<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
father: I
) -> &mut Self
pub fn father<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
father: I
) -> &mut Self
Set the father values.
sourcepub fn mother<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
mother: I
) -> &mut Self
pub fn mother<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
mother: I
) -> &mut Self
Override the mother values.
sourcepub fn sex<I: IntoIterator<Item = i32>>(&mut self, sex: I) -> &mut Self
pub fn sex<I: IntoIterator<Item = i32>>(&mut self, sex: I) -> &mut Self
Override the sex values.
sourcepub fn pheno<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
pheno: I
) -> &mut Self
pub fn pheno<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
pheno: I
) -> &mut Self
Override the phenotype values.
sourcepub fn chromosome<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
chromosome: I
) -> &mut Self
pub fn chromosome<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
chromosome: I
) -> &mut Self
Override the chromosome values.
sourcepub fn sid<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
sid: I
) -> &mut Self
pub fn sid<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
sid: I
) -> &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<I: IntoIterator<Item = f32>>(
&mut self,
cm_position: I
) -> &mut Self
pub fn cm_position<I: IntoIterator<Item = f32>>(
&mut self,
cm_position: I
) -> &mut Self
Override the centimorgan position values.
sourcepub fn bp_position<I: IntoIterator<Item = i32>>(
&mut self,
bp_position: I
) -> &mut Self
pub fn bp_position<I: IntoIterator<Item = i32>>(
&mut self,
bp_position: I
) -> &mut Self
Override the base-pair position values.
sourcepub fn allele_1<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
allele_1: I
) -> &mut Self
pub fn allele_1<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
allele_1: I
) -> &mut Self
Override the allele 1 values.
sourcepub fn allele_2<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
allele_2: I
) -> &mut Self
pub fn allele_2<I: IntoIterator<Item = T>, T: AsRef<str>>(
&mut self,
allele_2: I
) -> &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
sourceimpl Clone for MetadataBuilder
impl Clone for MetadataBuilder
sourcefn clone(&self) -> MetadataBuilder
fn clone(&self) -> MetadataBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl RefUnwindSafe for MetadataBuilder
impl !Send for MetadataBuilder
impl !Sync for MetadataBuilder
impl Unpin for MetadataBuilder
impl UnwindSafe for MetadataBuilder
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
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
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 more
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).
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.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self to the equivalent element of its superset.