Crates.io | ebiotic |
lib.rs | ebiotic |
version | 0.0.26 |
source | src |
created_at | 2023-11-07 20:33:20.528556 |
updated_at | 2024-05-03 10:46:09.819549 |
description | A Rust crate for interacting with common bioinformatics web services. |
homepage | |
repository | https://github.com/hallsopp/ebiotic |
max_upload_size | |
id | 1028420 |
size | 447,251 |
Ebiotic provides a light-weight asynchronous interface for some popular Bioinformatics web services. It is designed to
enable access to the rich data and tools provided by institutes like the European Bioinformatics
Institute (EBI) and the National Center for Biotechnology
Information (NCBI). It's built to serialize
and deserialze data using common formats like JSON and specialised bioinformatics formats like FASTA, using the Record
data structure from the rust-bio library.
Disclaimer: The library does not safeguard against misuse of the endpoints (beyond hard-coded polling frequencies) and so it is important to read and understand the terms of use for each API before using this library. The library is not affiliated with any of the institutes or services it interacts with.
The library is currently in the early stages of development and is therefore not stable, but remains available
on crates.io. To install, add
the following to your Cargo.toml
file:
[dependencies]
ebiotic = "0.0.25"
The library is designed to be simple to use and to provide a consistent interface to the various APIs. The following example demonstrates how to use the library to search the European Nucleotide Archive (ENA) for a selection of entries.
use ebiotic::data::*;
#[tokio::main]
async fn main_fasta() {
let dbfetch = Dbfetch::default();
let ids = DbfetchIds::new(vec!["M10051".to_string(), "M10052".to_string()]);
let result = dbfetch.run(ids).await.unwrap().into_records();
}
The Dbfetch
struct is used to create a new instance of the Dbfetch
API. The DbfetchIds
struct is used to create a
new instance of the DbfetchIds
request. The run
method is then called on the Dbfetch
instance with
the DbfetchIds
instance as an argument. The run
method returns a Result
which is then unwrapped and converted into
a Vec<Record>
using the into_records
method.
In order to perform HTTP requests, a system client is required. The EbioticClient
struct is used to create a new
client for this purpose. By default, the EbioticClient
uses an asynchronous reqwest
client under the hood. This
means it can be customised for platform specific requirements, such as using a proxy or customising the user agent. More
information on the reqwest
client can be found in the reqwest documentation.
use ebiotic::data::*;
use std::time::Duration;
use reqwest;
#[tokio::main]
async fn main_blast() {
let client = EbioticClient::new(
reqwest::Client::builder()
.timeout(Duration::from_secs(10))
.proxy(reqwest::Proxy::all("http://my-proxy:8080").unwrap())
.build()
.unwrap()
);
let dbfetch = Dbfetch::new(client, DbfetchDbs::EnaSequence, DataReturnFormats::Fasta, DbfetchStyle::Raw);
let ids = DbfetchIds::new(vec!["M10051".to_string(), "M10052".to_string()]);
let result = dbfetch.run(ids).await.unwrap().into_records();
}
More examples can be found in the documentation. Including how to run in synchronous code-bases using thread blocking.
Job Dispatcher:
Knowledge & Data:
Contributions are more than welcome. To implement a new endpoint follow the structure of the current modules and utilise
the functionality provided by the ebiotic::core
module. Alternatively, pick something from the TODO list and try to
implement or find something in the code that you can improve!
If you have any questions or need help, feel free to open an issue or reach out to me on via email.