-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af9b55a
commit 5068231
Showing
3 changed files
with
35 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,35 @@ | ||
use bed_reader::{BedCloud, BedErrorPlus, ReadOptions}; | ||
use ndarray::s; | ||
use std::collections::HashSet; | ||
#[cfg(feature = "tokio/full")] | ||
mod cloud_example { | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<BedErrorPlus>> { | ||
let url = "https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/some_missing.bed"; | ||
let cloud_options = [("timeout", "10s")]; | ||
use bed_reader::{BedCloud, BedErrorPlus, ReadOptions}; | ||
use ndarray::s; | ||
use std::collections::HashSet; | ||
|
||
let mut bed_cloud = BedCloud::new_with_options(url, cloud_options).await?; | ||
println!("{:?}", bed_cloud.iid().await?.slice(s![..5])); // Outputs ndarray: ["iid_0", "iid_1", "iid_2", "iid_3", "iid_4"] | ||
println!("{:?}", bed_cloud.sid().await?.slice(s![..5])); // Outputs ndarray: ["sid_0", "sid_1", "sid_2", "sid_3", "sid_4"] | ||
println!( | ||
"{:?}", | ||
bed_cloud.chromosome().await?.iter().collect::<HashSet<_>>() | ||
); | ||
// Outputs: {"12", "10", "4", "8", "19", "21", "9", "15", "6", "16", "13", "7", "17", "18", "1", "22", "11", "2", "20", "3", "5", "14"} | ||
let _ = ReadOptions::builder() | ||
.sid_index(bed_cloud.chromosome().await?.map(|elem| elem == "5")) | ||
.f64() | ||
.read_cloud(&mut bed_cloud) | ||
.await?; | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<BedErrorPlus>> { | ||
let url = | ||
"https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/some_missing.bed"; | ||
let cloud_options = [("timeout", "10s")]; | ||
|
||
Ok(()) | ||
let mut bed_cloud = BedCloud::new_with_options(url, cloud_options).await?; | ||
println!("{:?}", bed_cloud.iid().await?.slice(s![..5])); // Outputs ndarray: ["iid_0", "iid_1", "iid_2", "iid_3", "iid_4"] | ||
println!("{:?}", bed_cloud.sid().await?.slice(s![..5])); // Outputs ndarray: ["sid_0", "sid_1", "sid_2", "sid_3", "sid_4"] | ||
println!( | ||
"{:?}", | ||
bed_cloud.chromosome().await?.iter().collect::<HashSet<_>>() | ||
); | ||
// Outputs: {"12", "10", "4", "8", "19", "21", "9", "15", "6", "16", "13", "7", "17", "18", "1", "22", "11", "2", "20", "3", "5", "14"} | ||
let _ = ReadOptions::builder() | ||
.sid_index(bed_cloud.chromosome().await?.map(|elem| elem == "5")) | ||
.f64() | ||
.read_cloud(&mut bed_cloud) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "tokio/full"))] | ||
pub fn main() { | ||
println!("This example requires the 'tokio/full' feature to be enabled"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters