pub struct BedCloudBuilder { /* private fields */ }Expand description
Builder for BedCloud.
Implementations§
Source§impl BedCloudBuilder
impl BedCloudBuilder
Sourcepub fn fam<I, K, V>(
self,
url: impl AsRef<str>,
options: I,
) -> Result<Self, Box<BedErrorPlus>>
pub fn fam<I, K, V>( self, url: impl AsRef<str>, options: I, ) -> Result<Self, Box<BedErrorPlus>>
Set the cloud location of the .fam file. Specify the file with a URL string.
If not set, the .fam file will be assumed to have the same location as the .bed file, but with the extension .fam.
See
BedCloudBuilder::fam_cloud_fileto specify the file with anCloudFileinstead of a URL string.
§Example:
Read .bed, .fam, and .bim files with non-standard names.
use bed_reader::{BedCloud, ReadOptions, sample_urls, EMPTY_OPTIONS};
let deb_maf_mib = sample_urls(["small.deb", "small.maf", "small.mib"])?;
let mut bed_cloud = BedCloud::builder(&deb_maf_mib[0])?
.fam(&deb_maf_mib[1], EMPTY_OPTIONS)?
.bim(&deb_maf_mib[2], EMPTY_OPTIONS)?
.build().await?;
println!("{:?}", bed_cloud.iid().await?); // Outputs ndarray ["iid1", "iid2", "iid3"]
println!("{:?}", bed_cloud.sid().await?); // Outputs ndarray ["sid1", "sid2", "sid3", "sid4"]Sourcepub fn bim<I, K, V>(
self,
url: impl AsRef<str>,
options: I,
) -> Result<Self, Box<BedErrorPlus>>
pub fn bim<I, K, V>( self, url: impl AsRef<str>, options: I, ) -> Result<Self, Box<BedErrorPlus>>
Set the cloud location of the .bim file. Specify the file with a URL string.
If not set, the .bim file will be assumed to have the same location as the .bed file, but with the extension .bim.
See
BedCloudBuilder::fam_cloud_fileto specify the file with anCloudFileinstead of a URL string.
§Example:
Read .bed, .fam, and .bim files with non-standard names.
use bed_reader::{BedCloud, ReadOptions, sample_urls, EMPTY_OPTIONS};
let deb_maf_mib = sample_urls(["small.deb", "small.maf", "small.mib"])?;
let mut bed_cloud = BedCloud::builder(&deb_maf_mib[0])?
.fam(&deb_maf_mib[1], EMPTY_OPTIONS)?
.bim(&deb_maf_mib[2], EMPTY_OPTIONS)?
.build().await?;
println!("{:?}", bed_cloud.iid().await?); // Outputs ndarray ["iid1", "iid2", "iid3"]
println!("{:?}", bed_cloud.sid().await?); // Outputs ndarray ["sid1", "sid2", "sid3", "sid4"]Source§impl BedCloudBuilder
impl BedCloudBuilder
Sourcepub async fn build(&self) -> Result<BedCloud, Box<BedErrorPlus>>
pub async fn build(&self) -> Result<BedCloud, Box<BedErrorPlus>>
Create a BedCloud from the builder.
See
BedCloud::builderfor more details and examples.
Sourcepub fn fid<AnyString0, AnyIter1>(self, fid: AnyIter1) -> Self
pub fn fid<AnyString0, AnyIter1>(self, fid: AnyIter1) -> 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<AnyString0, AnyIter1>(self, iid: AnyIter1) -> Self
pub fn iid<AnyString0, AnyIter1>(self, iid: AnyIter1) -> 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::{BedCloud, assert_eq_nan};
let url = "https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/small.bed";
use bed_reader::ReadOptions;
let mut bed_cloud = BedCloud::builder(url)?
.iid(["sample1", "sample2", "sample3"])
.build().await?;
println!("{:?}", bed_cloud.iid().await?); // Outputs ndarray ["sample1", "sample2", "sample3"]Sourcepub fn father<AnyString0, AnyIter1>(self, father: AnyIter1) -> Self
pub fn father<AnyString0, AnyIter1>(self, father: AnyIter1) -> Self
Override the father values found in the .fam file.
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 gi&ve different values.
Sourcepub fn mother<AnyString0, AnyIter1>(self, mother: AnyIter1) -> Self
pub fn mother<AnyString0, AnyIter1>(self, mother: AnyIter1) -> 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<AnyIter0>(self, sex: AnyIter0) -> Selfwhere
AnyIter0: IntoIterator<Item = i32>,
pub fn sex<AnyIter0>(self, sex: AnyIter0) -> Selfwhere
AnyIter0: IntoIterator<Item = i32>,
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<AnyString0, AnyIter1>(self, pheno: AnyIter1) -> Self
pub fn pheno<AnyString0, AnyIter1>(self, pheno: AnyIter1) -> 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<AnyString0, AnyIter1>(self, chromosome: AnyIter1) -> Self
pub fn chromosome<AnyString0, AnyIter1>(self, chromosome: AnyIter1) -> 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<AnyString0, AnyIter1>(self, sid: AnyIter1) -> Self
pub fn sid<AnyString0, AnyIter1>(self, sid: AnyIter1) -> 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::{BedCloud, ReadOptions, assert_eq_nan};
let url = "https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/small.bed";
let mut bed_cloud = BedCloud::builder(url)?
.sid(["SNP1", "SNP2", "SNP3", "SNP4"])
.build().await?;
println!("{:?}", bed_cloud.sid().await?); // Outputs ndarray ["SNP1", "SNP2", "SNP3", "SNP4"]Sourcepub fn cm_position<AnyIter0>(self, cm_position: AnyIter0) -> Selfwhere
AnyIter0: IntoIterator<Item = f32>,
pub fn cm_position<AnyIter0>(self, cm_position: AnyIter0) -> Selfwhere
AnyIter0: IntoIterator<Item = f32>,
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<AnyIter0>(self, bp_position: AnyIter0) -> Selfwhere
AnyIter0: IntoIterator<Item = i32>,
pub fn bp_position<AnyIter0>(self, bp_position: AnyIter0) -> Selfwhere
AnyIter0: IntoIterator<Item = i32>,
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<AnyString0, AnyIter1>(self, allele_1: AnyIter1) -> Self
pub fn allele_1<AnyString0, AnyIter1>(self, allele_1: AnyIter1) -> 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<AnyString0, AnyIter1>(self, allele_2: AnyIter1) -> Self
pub fn allele_2<AnyString0, AnyIter1>(self, allele_2: AnyIter1) -> 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 iid_count(self, count: usize) -> Self
pub fn iid_count(self, count: usize) -> Self
Set the number of individuals (samples) in the data.
By default, if this number is needed, it will be found and remembered by opening the .fam file and quickly counting the number of lines. Providing the number thus avoids a file read.
Sourcepub fn sid_count(self, count: usize) -> Self
pub fn sid_count(self, count: usize) -> Self
Set the number of SNPs in the data.
By default, if this number is needed, it will be found and remembered by opening the .bim file and quickly counting the number of lines. Providing the number thus avoids a file read.
Sourcepub fn skip_early_check(self) -> Self
pub fn skip_early_check(self) -> Self
Don’t check the header of the .bed file until and unless the file is actually read.
By default, when a BedCloud struct is created, the .bed
file header is checked. This stops that early check.
let mut bed_cloud = BedCloud::builder(url)?.skip_early_check().build().await?;
let val = bed_cloud.read::<f64>().await?;
assert_eq_nan(
&val,
&nd::array![
[1.0, 0.0, f64::NAN, 0.0],
[2.0, 0.0, f64::NAN, 2.0],
[0.0, 1.0, 2.0, 0.0]
],
);Sourcepub fn fam_cloud_file(self, cloud_file: &CloudFile) -> Self
pub fn fam_cloud_file(self, cloud_file: &CloudFile) -> Self
Set the cloud location of the .fam file.
If not set, the .fam file will be assumed to have the same location as the .bed file, but with the extension .fam.
§Example:
Read .bed, .fam, and .bim files with non-standard names.
use bed_reader::{BedCloud, ReadOptions, sample_urls, EMPTY_OPTIONS};
let deb_maf_mib = sample_urls(["small.deb", "small.maf", "small.mib"])?;
let mut bed_cloud = BedCloud::builder(&deb_maf_mib[0])?
.fam(&deb_maf_mib[1], EMPTY_OPTIONS)?
.bim(&deb_maf_mib[2], EMPTY_OPTIONS)?
.build().await?;
println!("{:?}", bed_cloud.iid().await?); // Outputs ndarray ["iid1", "iid2", "iid3"]
println!("{:?}", bed_cloud.sid().await?); // Outputs ndarray ["sid1", "sid2", "sid3", "sid4"]Sourcepub fn bim_cloud_file(self, cloud_file: &CloudFile) -> Self
pub fn bim_cloud_file(self, cloud_file: &CloudFile) -> Self
Set the cloud location of the .bim file.
If not set, the .bim file will be assumed to have the same location as the .bed file, but with the extension .bim.
§Example:
Read .bed, .fam, and .bim files with non-standard names.
use bed_reader::{BedCloud, ReadOptions, sample_urls, CloudFile};
let deb_maf_mib = sample_urls(["small.deb", "small.maf", "small.mib"])?
.iter()
.map(|url| CloudFile::new(url))
.collect::<Result<Vec<CloudFile>, _>>()?;
let mut bed_cloud = BedCloud::builder_from_cloud_file(&deb_maf_mib[0])
.fam_cloud_file(&deb_maf_mib[1])
.bim_cloud_file(&deb_maf_mib[2])
.build().await?;
println!("{:?}", bed_cloud.iid().await?); // Outputs ndarray ["iid1", "iid2", "iid3"]
println!("{:?}", bed_cloud.sid().await?); // Outputs ndarray ["sid1", "sid2", "sid3", "sid4"]Sourcepub fn skip_fid(self) -> Self
pub fn skip_fid(self) -> Self
Don’t read the fid information from the .fam file.
By default, when the .fam is read, the fid (the family id) is recorded. This stops that recording. This is useful if the fid is not needed. Asking for the fid after skipping it results in an error.
Sourcepub fn skip_iid(self) -> Self
pub fn skip_iid(self) -> Self
Don’t read the iid information from the .fam file.
By default, when the .fam is read, the iid (the individual id) is recorded. This stops that recording. This is useful if the iid is not needed. Asking for the iid after skipping it results in an error.
Sourcepub fn skip_father(self) -> Self
pub fn skip_father(self) -> Self
Don’t read the father information from the .fam file.
By default, when the .fam is read, the father id is recorded. This stops that recording. This is useful if the father id is not needed. Asking for the father id after skipping it results in an error.
Sourcepub fn skip_mother(self) -> Self
pub fn skip_mother(self) -> Self
Don’t read the mother information from the .fam file.
By default, when the .fam is read, the mother id is recorded. This stops that recording. This is useful if the mother id is not needed. Asking for the mother id after skipping it results in an error.
Sourcepub fn skip_sex(self) -> Self
pub fn skip_sex(self) -> Self
Don’t read the sex information from the .fam file.
By default, when the .fam is read, the sex is recorded. This stops that recording. This is useful if sex is not needed. Asking for sex after skipping it results in an error.
Sourcepub fn skip_pheno(self) -> Self
pub fn skip_pheno(self) -> Self
Don’t read the phenotype information from the .fam file.
Note that the phenotype information in the .fam file is seldom used.
By default, when the .fam is read, the phenotype is recorded. This stops that recording. This is useful if this phenotype information is not needed. Asking for the phenotype after skipping it results in an error.
Sourcepub fn skip_chromosome(self) -> Self
pub fn skip_chromosome(self) -> Self
Don’t read the chromosome information from the .bim file.
By default, when the .bim is read, the chromosome is recorded. This stops that recording. This is useful if the chromosome is not needed. Asking for the chromosome after skipping it results in an error.
Sourcepub fn skip_sid(self) -> Self
pub fn skip_sid(self) -> Self
Don’t read the SNP id information from the .bim file.
By default, when the .bim is read, the sid (SNP id) is recorded. This stops that recording. This is useful if the sid is not needed. Asking for the sid after skipping it results in an error.
Sourcepub fn skip_cm_position(self) -> Self
pub fn skip_cm_position(self) -> Self
Don’t read the centimorgan position information from the .bim file.
By default, when the .bim is read, the cm position is recorded. This stops that recording. This is useful if the cm position is not needed. Asking for the cm position after skipping it results in an error.
Sourcepub fn skip_bp_position(self) -> Self
pub fn skip_bp_position(self) -> Self
Don’t read the base-pair position information from the .bim file.
By default, when the .bim is read, the bp position is recorded. This stops that recording. This is useful if the bp position is not needed. Asking for the cp position after skipping it results in an error.
Sourcepub fn skip_allele_1(self) -> Self
pub fn skip_allele_1(self) -> Self
Don’t read the allele 1 information from the .bim file.
By default, when the .bim is read, allele 1 is recorded. This stops that recording. This is useful if allele 1 is not needed. Asking for allele 1 after skipping it results in an error.
Sourcepub fn skip_allele_2(self) -> Self
pub fn skip_allele_2(self) -> Self
Don’t read the allele 2 information from the .bim file.
By default, when the .bim is read, allele 2 is recorded. This stops that recording. This is useful if allele 2 is not needed. Asking for allele 2 after skipping it results in an error.
Sourcepub fn metadata(self, metadata: &Metadata) -> Self
pub fn metadata(self, metadata: &Metadata) -> Self
Override the metadata in the .fam and .bim files with info merged in from a Metadata.
§Example
In the example, we create a Metadata with iid
and sid arrays. Next, we use BedCloudBuilder to override the fid array
and an iid array. Then, we add the metadata to the BedCloudBuilder,
overwriting iid (again) and overriding sid. Finally, we print these
three arrays and chromosome. Chromosome was never overridden so
it is read from the *.bim file.
use ndarray as nd;
use bed_reader::{BedCloud, Metadata};
let url = "https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/small.bed";
let metadata = Metadata::builder()
.iid(["i1", "i2", "i3"])
.sid(["s1", "s2", "s3", "s4"])
.build()?;
let mut bed_cloud = BedCloud::builder(url)?
.fid(["f1", "f2", "f3"])
.iid(["x1", "x2", "x3"])
.metadata(&metadata)
.build().await?;
println!("{0:?}", bed_cloud.fid().await?); // Outputs ndarray ["f1", "f2", "f3"]
println!("{0:?}", bed_cloud.iid().await?); // Outputs ndarray ["i1", "i2", "i3"]
println!("{0:?}", bed_cloud.sid().await?); // Outputs ndarray ["s1", "s2", "s3", "s4"]
println!("{0:?}", bed_cloud.chromosome().await?); // Outputs ndarray ["1", "1", "5", "Y"]Trait Implementations§
Source§impl Clone for BedCloudBuilder
impl Clone for BedCloudBuilder
Source§fn clone(&self) -> BedCloudBuilder
fn clone(&self) -> BedCloudBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for BedCloudBuilder
impl Default for BedCloudBuilder
Source§impl From<&CloudFile> for BedCloudBuilder
impl From<&CloudFile> for BedCloudBuilder
Auto Trait Implementations§
impl Freeze for BedCloudBuilder
impl !RefUnwindSafe for BedCloudBuilder
impl !Send for BedCloudBuilder
impl !Sync for BedCloudBuilder
impl Unpin for BedCloudBuilder
impl !UnwindSafe for BedCloudBuilder
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
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>
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>
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.