|
|
@@ -1,14 +1,11 @@
|
|
|
+use anyhow::Result;
|
|
|
use minimap2::{Alignment, Mapping, Strand};
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
use serde_nested_with::serde_nested;
|
|
|
use std::num::NonZeroI32;
|
|
|
use tokio::runtime::Builder;
|
|
|
-use anyhow::Result;
|
|
|
|
|
|
-pub fn get_mappings(
|
|
|
- url: &str,
|
|
|
- sequence: String,
|
|
|
-) -> Result<Vec<Mapping>> {
|
|
|
+pub fn get_mappings(url: &str, sequence: String) -> Result<Vec<Mapping>> {
|
|
|
let runtime = Builder::new_multi_thread()
|
|
|
.worker_threads(1)
|
|
|
.enable_all()
|
|
|
@@ -20,10 +17,7 @@ pub fn get_mappings(
|
|
|
Ok(res)
|
|
|
}
|
|
|
|
|
|
-pub async fn get_mappings_async(
|
|
|
- url: String,
|
|
|
- sequence: String,
|
|
|
-) -> Result<Vec<Mapping>> {
|
|
|
+pub async fn get_mappings_async(url: String, sequence: String) -> Result<Vec<Mapping>> {
|
|
|
let client = reqwest::Client::new();
|
|
|
let url = reqwest::Url::parse(&url).unwrap();
|
|
|
|
|
|
@@ -87,17 +81,20 @@ pub struct Mappings {
|
|
|
pub inner: Vec<Mapping>,
|
|
|
}
|
|
|
|
|
|
+pub fn dist_align(url: String) -> impl Fn(String) -> Result<Vec<Mapping>> {
|
|
|
+ move |sequence: String| -> Result<Vec<Mapping>> { get_mappings(url.as_str(), sequence) }
|
|
|
+}
|
|
|
+
|
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
|
use super::*;
|
|
|
|
|
|
#[test]
|
|
|
fn it_works() {
|
|
|
- let mut mappings = get_mappings(
|
|
|
- "http://localhost:4444/align",
|
|
|
- "ACCAAAACACATATTCACGGCAGCCACTCCACCCAGCACCTCaca".to_string(),
|
|
|
- )
|
|
|
- .unwrap();
|
|
|
+ let url = "http://localhost:4444/align".to_string();
|
|
|
+ let aligner = dist_align(url);
|
|
|
+ let mut mappings =
|
|
|
+ aligner("CCAAAACACATATTCACGGCAGCCACTCCACCCAGCACCTCaca".to_string()).unwrap();
|
|
|
let mapping = mappings.pop().unwrap();
|
|
|
assert_eq!(mapping.target_name.unwrap(), "chr6".to_string());
|
|
|
}
|