Skip to content

Commit 94335fc

Browse files
committed
Remove default test
1 parent 32e2508 commit 94335fc

File tree

3 files changed

+67
-82
lines changed

3 files changed

+67
-82
lines changed

minimappers2/Cargo.lock

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

minimappers2/src/lib.rs

Lines changed: 66 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::num::NonZeroI32;
2-
use std::sync::{Mutex, Arc};
2+
use std::sync::{Arc, Mutex};
33

44
// use mimalloc::MiMalloc;
5+
use crossbeam::queue::ArrayQueue;
6+
use fffx::{Fasta, Fastq};
57
use minimap2::*;
68
use minimap2_sys::{mm_set_opt, MM_F_CIGAR};
9+
use polars::{df, prelude::*};
710
use pyo3::prelude::*;
811
use pyo3_polars::{error::PyPolarsErr, PyDataFrame};
9-
use polars::{prelude::*, df};
10-
use crossbeam::queue::ArrayQueue;
11-
use fffx::{Fasta, Fastq};
1212

1313
// #[global_allocator]
1414
// static GLOBAL: MiMalloc = MiMalloc;
@@ -47,13 +47,15 @@ unsafe impl Send for Aligner {}
4747

4848
#[pymethods]
4949
impl Aligner {
50-
5150
// Mapping functions
5251
/// Map a single sequence
5352
fn map1(&self, seq: &Sequence) -> PyResult<PyDataFrame> {
5453
let mut mappings = Mappings::default();
5554

56-
let results = self.aligner.map(&seq.sequence, true, true, None, None).unwrap();
55+
let results = self
56+
.aligner
57+
.map(&seq.sequence, true, true, None, None)
58+
.unwrap();
5759
results.into_iter().for_each(|mut r| {
5860
r.query_name = Some(seq.id.clone());
5961
mappings.push(r)
@@ -73,7 +75,10 @@ impl Aligner {
7375
let mut mappings = Mappings::default();
7476

7577
for seq in seqs {
76-
let results = self.aligner.map(&seq.sequence, true, true, None, None).unwrap();
78+
let results = self
79+
.aligner
80+
.map(&seq.sequence, true, true, None, None)
81+
.unwrap();
7782
results.into_iter().for_each(|mut r| {
7883
r.query_name = Some(seq.id.clone());
7984
mappings.push(r)
@@ -86,7 +91,7 @@ impl Aligner {
8691
let work_queue = Arc::new(Mutex::new(seqs));
8792
let results_queue = Arc::new(ArrayQueue::<WorkQueue<Vec<Mapping>>>::new(128));
8893
let mut thread_handles = Vec::new();
89-
for i in 0..(self.aligner.threads-1) {
94+
for i in 0..(self.aligner.threads - 1) {
9095
let work_queue = Arc::clone(&work_queue);
9196
let results_queue = Arc::clone(&results_queue);
9297

@@ -127,13 +132,13 @@ impl Aligner {
127132
match result {
128133
Some(WorkQueue::Work(result)) => {
129134
result.into_iter().for_each(|r| mappings.push(r));
130-
},
135+
}
131136
Some(WorkQueue::Done) => {
132137
finished_count += 1;
133138
if finished_count == (self.aligner.threads - 1) {
134139
break;
135140
}
136-
},
141+
}
137142
None => {
138143
// Probably should be backoff, but let's try this for now...
139144
std::thread::sleep(std::time::Duration::from_millis(100));
@@ -203,7 +208,7 @@ impl Aligner {
203208
self.preset(Preset::AvaPb);
204209
}
205210

206-
/// Configure aligner for Asm
211+
/// Configure aligner for Asm
207212
fn asm(&mut self) {
208213
self.preset(Preset::Asm);
209214
}
@@ -245,26 +250,26 @@ impl Aligner {
245250
}
246251

247252
impl Aligner {
248-
/// Create an aligner using a preset.
249-
fn preset(&mut self, preset: Preset) {
250-
let mut idxopt = IdxOpt::default();
251-
let mut mapopt = MapOpt::default();
252-
253-
unsafe {
254-
// Set preset
255-
mm_set_opt(preset.into(), &mut idxopt, &mut mapopt)
256-
};
257-
258-
self.aligner.idxopt = idxopt;
259-
self.aligner.mapopt = mapopt;
260-
}
253+
/// Create an aligner using a preset.
254+
fn preset(&mut self, preset: Preset) {
255+
let mut idxopt = IdxOpt::default();
256+
let mut mapopt = MapOpt::default();
257+
258+
unsafe {
259+
// Set preset
260+
mm_set_opt(preset.into(), &mut idxopt, &mut mapopt)
261+
};
262+
263+
self.aligner.idxopt = idxopt;
264+
self.aligner.mapopt = mapopt;
265+
}
261266
}
262267

263268
/*
264269
TODO - Destroy index when aligner is dropped or when new index is created
265270
impl Drop for Aligner {
266271
fn drop(&mut self) {
267-
272+
268273
}
269274
} */
270275

@@ -431,66 +436,77 @@ impl Mappings {
431436
}
432437

433438
pub fn to_df(self) -> Result<DataFrame, PolarsError> {
434-
435439
// Convert strand to string + or -
436440
let strand: Vec<String> = self.strand.iter().map(|x| x.to_string()).collect();
437441

438442
// Convert query len to Option<u32>
439443
// let query_len: Vec<Option<u32>> = self.query_len.iter().map(|x| x.map(|y| y as u32.into())).collect();
440-
let query_len: Vec<Option<u32>> = self.query_len.iter().map(|x|
441-
match x {
444+
let query_len: Vec<Option<u32>> = self
445+
.query_len
446+
.iter()
447+
.map(|x| match x {
442448
Some(y) => Some(y.get() as u32),
443449
None => None,
444-
}
445-
).collect();
450+
})
451+
.collect();
446452

447-
let nm: Vec<Option<i32>> = self.alignment.iter().map(|x|
448-
match x {
453+
let nm: Vec<Option<i32>> = self
454+
.alignment
455+
.iter()
456+
.map(|x| match x {
449457
// These are ugly but it's early in the morning...
450458
Some(y) => Some(y.nm),
451459
None => None,
452-
}
453-
).collect();
460+
})
461+
.collect();
454462

455-
let cigar: Vec<Option<Vec<(u32, u8)>>> = self.alignment.iter().map(|x|
456-
match x {
463+
let cigar: Vec<Option<Vec<(u32, u8)>>> = self
464+
.alignment
465+
.iter()
466+
.map(|x| match x {
457467
Some(y) => match &y.cigar {
458468
Some(z) => Some(z.clone()),
459469
None => None,
460470
},
461471
None => None,
462-
}
463-
).collect();
472+
})
473+
.collect();
464474

465-
let cigar_str: Vec<Option<String>> = self.alignment.iter().map(|x|
466-
match x {
475+
let cigar_str: Vec<Option<String>> = self
476+
.alignment
477+
.iter()
478+
.map(|x| match x {
467479
Some(y) => match &y.cigar_str {
468480
Some(z) => Some(z.clone()),
469481
None => None,
470482
},
471483
None => None,
472-
}
473-
).collect();
484+
})
485+
.collect();
474486

475-
let md: Vec<Option<String>> = self.alignment.iter().map(|x|
476-
match x {
487+
let md: Vec<Option<String>> = self
488+
.alignment
489+
.iter()
490+
.map(|x| match x {
477491
Some(y) => match &y.md {
478492
Some(z) => Some(z.clone()),
479493
None => None,
480494
},
481495
None => None,
482-
}
483-
).collect();
496+
})
497+
.collect();
484498

485-
let cs: Vec<Option<String>> = self.alignment.iter().map(|x|
486-
match x {
499+
let cs: Vec<Option<String>> = self
500+
.alignment
501+
.iter()
502+
.map(|x| match x {
487503
Some(y) => match &y.cs {
488504
Some(z) => Some(z.clone()),
489505
None => None,
490506
},
491507
None => None,
492-
}
493-
).collect();
508+
})
509+
.collect();
494510

495511
let query_name = Series::new("query_name", self.query_name);
496512
let query_len = Series::new("query_len", query_len);
@@ -533,14 +549,3 @@ impl Mappings {
533549
])
534550
}
535551
}
536-
537-
#[cfg(test)]
538-
mod tests {
539-
use super::*;
540-
541-
#[test]
542-
fn it_works() {
543-
let result = add(2, 2);
544-
assert_eq!(result, 4);
545-
}
546-
}

minimappers2/src/multithreading.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
pub enum WorkQueue<T> {
44
Work(T),
55
Done,
6-
}
6+
}

0 commit comments

Comments
 (0)