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
Override the family id (fid) values found in the .fam file.
By default, if fid values are needed and haven’t already been found, they will be read from the .fam file. Providing them here avoids that file read and provides a way to give different 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
Override the individual id (iid) values found in the .fam file.
By default, if iid values are needed and haven’t already been found, they will be read from the .fam file. Providing them here avoids that file read and provides a way to give different values.
use ndarray as nd;
use bed_reader::{Bed, assert_eq_nan, sample_bed_file};
let file_name = sample_bed_file("small.bed")?;
let mut bed = Bed::builder(file_name)
.iid(["sample1", "sample2", "sample3"])
.build()?;
println!("{:?}", bed.iid()?); // Outputs ndarray ["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
Override the father values found in the .fam file. nd By default, if father values are needed and haven’t already been found, they will be read from the .fam file. Providing them here avoids that file read and provides a way to give different 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 found in the .fam file.
By default, if mother values are needed and haven’t already been found, they will be read from the .fam file. Providing them here avoids that file read and provides a way to give different 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 found in the .fam file.
By default, if sex values are needed and haven’t already been found, they will be read from the .fam file. Providing them here avoids that file read and provides a way to give different 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 found in the .fam file.
Note that the phenotype values in the .fam file are seldom used. By default, if phenotype values are needed and haven’t already been found, they will be read from the .fam file. Providing them here avoids that file read and provides a way to give different 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 found in the .bim file.
By default, if chromosome values are needed and haven’t already been found, they will be read from the .bim file. Providing them here avoids that file read and provides a way to give different 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 found in the .fam file.
By default, if sid values are needed and haven’t already been found, they will be read from the .bim file. Providing them here avoids that file read and provides a way to give different values.
use ndarray as nd;
use bed_reader::{Bed, assert_eq_nan, sample_bed_file};
let file_name = sample_bed_file("small.bed")?;
let mut bed = Bed::builder(file_name)
.sid(["SNP1", "SNP2", "SNP3", "SNP4"])
.build()?;
println!("{:?}", bed.sid()?); // Outputs ndarray ["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 found in the .bim file.
By default, if centimorgan position values are needed and haven’t already been found, they will be read from the .bim file. Providing them here avoids that file read and provides a way to give different 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 found in the .bim file.
By default, if base-pair position values are needed and haven’t already been found, they will be read from the .bim file. Providing them here avoids that file read and provides a way to give different 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 found in the .bim file.
By default, if allele 1 values are needed and haven’t already been found, they will be read from the .bim file. Providing them here avoids that file read and provides a way to give different 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 found in the .bim file.
By default, if allele 2 values are needed and haven’t already been found, they will be read from the .bim file. Providing them here avoids that file read and provides a way to give different 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.