Skip to content

Commit

Permalink
remove cloud feature
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlKCarlK committed Feb 1, 2024
1 parent 5f520bc commit d146e90
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 169 deletions.
112 changes: 2 additions & 110 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 10 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository = "https://github.com/fastlmm/bed-reader"
readme = "README-rust.md"
documentation = "https://docs.rs/bed-reader/latest/bed_reader/"
authors = ["FaST-LMM Team <fastlmm-dev@python.org>"]
license = "Apache-2.0" # toml-ignore
license = "Apache-2.0" # toml-ignore
keywords = ["bioinformatics", "plink", "genomics", "genotype", "snps"]
categories = ["science"]
edition = "2021"
Expand All @@ -26,19 +26,8 @@ crate-type = ["cdylib", "rlib"]
# https://github.com/PyO3/pyo3/discussions/2271
# https://pyo3.rs/latest/faq.html#i-cant-run-cargo-test-or-i-cant-build-in-a-cargo-workspace-im-having-linker-issues-like-symbol-not-found-or-undefined-reference-to-_pyexc_systemerror
[features]
extension-module = ["pyo3/extension-module", "pyo3-asyncio", "cloud", "tokio/full"]
cloud = [
"cloud-file",
"object_store",
"itertools",
"futures-util",
"bytes",
# "pyo3-asyncio",
# "tokio/full",
# "bytecount",
# "url"
]
default = ["cloud", "extension-module"] # remove extension-module from default
extension-module = ["pyo3/extension-module", "tokio/full"]
default = [ "extension-module"] # cmk remove extension-module from default

[dependencies]
thiserror = "1.0.40"
Expand All @@ -49,36 +38,24 @@ numpy = "0.20.0"
ndarray = { version = "0.15.6", features = ["approx", "rayon"] }
statrs = "0.16.0"
byteorder = { version = "1.4.3", default-features = false }
pyo3 = { version = "0.20.0", features = ["extension-module"], optional = true }
dpc-pariter = "0.4.0" # // pariter = "0.5.1"
derive_builder = "0.13.0"
anyinput = { version = "0.1.6", features = ["ndarray"] }
fetch-data = "0.1.6"

# Dependencies for cloud feature
pyo3-asyncio = { version = "0.20.0", features = ["tokio-runtime"], optional = true }
# when object_store goes to 0.9.1 check if can remove http cloud options work around code.
object_store = { version = "0.9.0", optional = true }
tokio = { version = "1.35.0", features = ["full"], optional = true }
futures-util = { version = "0.3.29", optional = true }
bytecount = { version = "0.6.7", optional = true }
itertools = { version = "0.12.0", optional = true }
bytes = { version = "1.5.0", optional = true }
url = { version = "2.5.0", optional = true }
futures-util = { version = "0.3.29"}
bytecount = { version = "0.6.7"}
itertools = { version = "0.12.0"}
bytes = { version = "1.5.0"}
# cmk cloud-file = { version = "0.1.0-beta.2", optional = true }
cloud-file = {path="../cloud-file", optional = true}
cloud-file = {path="../cloud-file"}
pyo3 = { version = "0.20.0", features = ["extension-module"], optional = true }
tokio = { version = "1.35.0", features = ["full"], optional = true }

[dev-dependencies]
ndarray-rand = "0.14.0"
anyhow = "1.0.75"
rusoto_credential = "0.48.0"
pyo3-asyncio = { version = "0.20.0", features = [
"tokio-runtime",
"attributes",
"testing",
] }
temp_testdir = "0.2.3"
object_store = { version = "0.9.0", features = ["aws","http"]}
thousands = "0.2.0"


Expand Down
3 changes: 1 addition & 2 deletions README-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ at index position 2. (See ["Cloud URLs and `CloudFile` Examples"](supplemental_d
for details specifying a file in the cloud.)

```rust
# #[cfg(feature = "cloud")] // '#' needed for doctest
# { use {bed_reader::BedErrorPlus, tokio::runtime::Runtime};
# { use {bed_reader::BedErrorPlus, tokio::runtime::Runtime}; // '#' needed for doctest
use ndarray as nd;
use bed_reader::{assert_eq_nan, BedCloud, ReadOptions};
# Runtime::new().unwrap().block_on(async {
Expand Down
25 changes: 25 additions & 0 deletions examples/cloud.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use bed_reader::{BedCloud, BedErrorPlus, ReadOptions};
use ndarray::s;
use std::collections::HashSet;

#[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")];

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(())
}
19 changes: 19 additions & 0 deletions examples/no_cloud.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use bed_reader::{sample_bed_file, Bed, BedErrorPlus, ReadOptions};
use ndarray::s;
use std::collections::HashSet;

fn main() -> Result<(), Box<BedErrorPlus>> {
let file_name = sample_bed_file("some_missing.bed")?;

let mut bed = Bed::new(file_name)?;
println!("{:?}", bed.iid()?.slice(s![..5])); // Outputs ndarray: ["iid_0", "iid_1", "iid_2", "iid_3", "iid_4"]
println!("{:?}", bed.sid()?.slice(s![..5])); // Outputs ndarray: ["sid_0", "sid_1", "sid_2", "sid_3", "sid_4"]
println!("{:?}", bed.chromosome()?.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.chromosome()?.map(|elem| elem == "5"))
.f64()
.read(&mut bed)?;

Ok(())
}
Loading

0 comments on commit d146e90

Please sign in to comment.