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

Builder for Metadata.

Implementations

Create Metadata from the builder.

See Metadata::builder()

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.

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

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.

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.

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.

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.

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.

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

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.

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.

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.

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.