diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 493bb9d0..4995e781 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,21 +29,21 @@ jobs: # env: # # support for lionux aarch64 - see here: https://github.com/apache/opendal/issues/3673 # CFLAGS_aarch64_unknown_linux_gnu: "-D__ARM_ARCH=8" - with: - before-script-linux: | - # Check for yum and use it if available, otherwise use apt-get - if command -v yum &> /dev/null; then - echo "Detected yum package manager" - yum -y install openssl-devel perl-IPC-Cmd perl-core # <--- new package added - elif command -v apt-get &> /dev/null; then - echo "Detected apt-get package manager" - apt-get update - echo "Installing libssl-dev pkg-config openssl musl-dev" - apt-get install -y libssl-dev pkg-config openssl musl-dev perl # <--- new package added - else - echo "No supported package manager found (yum or apt-get)" - exit 1 - fi + # with: + # before-script-linux: | + # # Check for yum and use it if available, otherwise use apt-get + # if command -v yum &> /dev/null; then + # echo "Detected yum package manager" + # yum -y install openssl-devel perl-IPC-Cmd perl-core # <--- new package added + # elif command -v apt-get &> /dev/null; then + # echo "Detected apt-get package manager" + # apt-get update + # echo "Installing libssl-dev pkg-config openssl musl-dev" + # apt-get install -y libssl-dev pkg-config openssl musl-dev perl # <--- new package added + # else + # echo "No supported package manager found (yum or apt-get)" + # exit 1 + # fi working-directory: ./bindings target: ${{ matrix.target }} args: --release --out dist --find-interpreter diff --git a/genimtools/src/bbclient/mod.rs b/genimtools/src/bbclient/mod.rs deleted file mode 100644 index 84b03c23..00000000 --- a/genimtools/src/bbclient/mod.rs +++ /dev/null @@ -1,82 +0,0 @@ -use std::path::PathBuf; - -use anyhow::Result; -use reqwest::blocking::Client; - -mod consts { - pub const CACHE_FOLDER: &str = ".bbcache"; - pub const BEDFILE_CACHE_SUBFOLDER: &str = "bedfiles"; - // pub const BEDSET_CACHE_SUBFOLDER: &str = "bedsets"; -} - -pub struct Bbclient { - bedbase_api: String, -} - -impl Bbclient { - pub fn new(bedbase_api: &str) -> Self { - Bbclient { - bedbase_api: bedbase_api.to_string(), - } - } - - pub fn get_bedbase_api(&self) -> &str { - &self.bedbase_api - } - - fn get_bed_file_download_link(&self, id: &str) -> Result { - Ok(format!( - "{}/v1/objects/bed.{}.bed_file/access/http/bytes", - self.bedbase_api, id - )) - } - - fn get_cache_path_for_bed_file(&self, id: &str) -> Result { - let cache_folder = dirs::home_dir().unwrap().join(consts::CACHE_FOLDER); - let bedfile_cache_folder = cache_folder.join(consts::BEDFILE_CACHE_SUBFOLDER); - let bedfile_cache_path = bedfile_cache_folder.join(format!("{}.bed", id)); - - Ok(bedfile_cache_path) - } -} - -impl Default for Bbclient { - fn default() -> Self { - Bbclient { - bedbase_api: "https://api.bedbase.org/v1".to_string(), - } - } -} - -pub trait BedbaseFileCache { - /// - /// Get the path to a bed file from the cache or download it if it does not exist. - /// - /// # Arguments - /// - `id` - the id of the file to download - fn get_bed_file(&self, id: &str) -> Result; -} - -impl BedbaseFileCache for Bbclient { - fn get_bed_file(&self, id: &str) -> Result { - let cache_path = self.get_cache_path_for_bed_file(id)?; - - // path exists? - if cache_path.exists() { - // read file - Ok(cache_path) - } else { - // download file - let download_link = self.get_bed_file_download_link(id)?; - let client = Client::new(); - let response = client.get(download_link).send()?; - let content = response.bytes()?; - - // write file - std::fs::create_dir_all(cache_path.parent().unwrap())?; - std::fs::write(&cache_path, content)?; - - Ok(cache_path) - } - } -} diff --git a/genimtools/src/lib.rs b/genimtools/src/lib.rs index 6c999956..7c249dd8 100644 --- a/genimtools/src/lib.rs +++ b/genimtools/src/lib.rs @@ -5,7 +5,6 @@ //! However, it can be used as a standalone library for working with genomic intervals as well. //! pub mod ailist; -pub mod bbclient; pub mod common; pub mod io; pub mod tokenizers; diff --git a/genimtools/src/tokenizers/tree_tokenizer.rs b/genimtools/src/tokenizers/tree_tokenizer.rs index ff6fe444..f88db145 100644 --- a/genimtools/src/tokenizers/tree_tokenizer.rs +++ b/genimtools/src/tokenizers/tree_tokenizer.rs @@ -4,7 +4,6 @@ use std::path::Path; use anyhow::Result; use rust_lapper::{Interval, Lapper}; -use crate::bbclient::{Bbclient, BedbaseFileCache}; use crate::common::consts::special_tokens::*; use crate::common::models::{Region, RegionSet, TokenizedRegionSet, Universe}; use crate::common::utils::extract_regions_from_bed_file; @@ -275,13 +274,6 @@ impl TreeTokenizer { Ok(self.tokenize_region_set(&rs)) } - - pub fn from_bedbase(id: &str) -> Result { - let bedbase = Bbclient::default(); - let bed_file = bedbase.get_bed_file(id)?; - - TreeTokenizer::try_from(bed_file.as_path()) - } } // use default implementation