pub struct MetadataBuilder { /* private fields */ }
Expand description

Builder for Metadata.

Implementations§

source§

impl MetadataBuilder

source

pub fn build(&self) -> Result<Metadata, Box<BedErrorPlus>>

Create Metadata from the builder.

See Metadata::builder()

source

pub fn fid<AnyString0, AnyIter1>(&mut self, fid: AnyIter1) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Set the family id (fid) values.

source

pub fn iid<AnyString0, AnyIter1>(&mut self, iid: AnyIter1) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

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"])
source

pub fn father<AnyString0, AnyIter1>(&mut self, father: AnyIter1) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Set the father values.

source

pub fn mother<AnyString0, AnyIter1>(&mut self, mother: AnyIter1) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Override the mother values.

source

pub fn sex<AnyIter0>(&mut self, sex: AnyIter0) -> &mut Selfwhere AnyIter0: IntoIterator<Item = i32>,

Override the sex values.

source

pub fn pheno<AnyString0, AnyIter1>(&mut self, pheno: AnyIter1) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Override the phenotype values.

source

pub fn chromosome<AnyString0, AnyIter1>( &mut self, chromosome: AnyIter1 ) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Override the chromosome values.

source

pub fn sid<AnyString0, AnyIter1>(&mut self, sid: AnyIter1) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

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"])
source

pub fn cm_position<AnyIter0>(&mut self, cm_position: AnyIter0) -> &mut Selfwhere AnyIter0: IntoIterator<Item = f32>,

Override the centimorgan position values.

source

pub fn bp_position<AnyIter0>(&mut self, bp_position: AnyIter0) -> &mut Selfwhere AnyIter0: IntoIterator<Item = i32>,

Override the base-pair position values.

source

pub fn allele_1<AnyString0, AnyIter1>( &mut self, allele_1: AnyIter1 ) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Override the allele 1 values.

source

pub fn allele_2<AnyString0, AnyIter1>( &mut self, allele_2: AnyIter1 ) -> &mut Selfwhere AnyString0: AsRef<str>, AnyIter1: IntoIterator<Item = AnyString0>,

Override the allele 2 values.

source

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 None

Trait Implementations§

source§

impl Clone for MetadataBuilder

source§

fn clone(&self) -> MetadataBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for MetadataBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V