|
|
@@ -1,5 +1,7 @@
|
|
|
use super::{GenomeCoord, UniqueLen};
|
|
|
-use libsais::{SuffixArrayConstruction, ThreadCount};
|
|
|
+use libsais::SuffixArrayConstruction;
|
|
|
+#[cfg(not(target_os = "windows"))]
|
|
|
+use libsais::ThreadCount;
|
|
|
use log::info;
|
|
|
use std::time::Instant;
|
|
|
|
|
|
@@ -13,17 +15,34 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
|
|
|
return (Vec::new(), Vec::new());
|
|
|
}
|
|
|
|
|
|
+ #[cfg(not(target_os = "windows"))]
|
|
|
let thread_count = rayon::current_num_threads().min(u16::MAX as usize) as u16;
|
|
|
+
|
|
|
+ #[cfg(not(target_os = "windows"))]
|
|
|
info!(
|
|
|
"[uniqueness] building suffix array with libsais ({:.1} Mbp, {thread_count} thread(s))",
|
|
|
n as f64 / 1e6
|
|
|
);
|
|
|
+ #[cfg(target_os = "windows")]
|
|
|
+ info!(
|
|
|
+ "[uniqueness] building suffix array with libsais ({:.1} Mbp, single-threaded)",
|
|
|
+ n as f64 / 1e6
|
|
|
+ );
|
|
|
+
|
|
|
let started = Instant::now();
|
|
|
+
|
|
|
+ #[cfg(not(target_os = "windows"))]
|
|
|
let sa_result = SuffixArrayConstruction::for_text(genome)
|
|
|
.in_owned_buffer64()
|
|
|
.multi_threaded(ThreadCount::fixed(thread_count))
|
|
|
.run()
|
|
|
.expect("libsais failed to construct suffix array");
|
|
|
+ #[cfg(target_os = "windows")]
|
|
|
+ let sa_result = SuffixArrayConstruction::for_text(genome)
|
|
|
+ .in_owned_buffer64()
|
|
|
+ .run()
|
|
|
+ .expect("libsais failed to construct suffix array");
|
|
|
+
|
|
|
info!(
|
|
|
"[uniqueness] suffix array built in {:.1}s",
|
|
|
started.elapsed().as_secs_f64()
|
|
|
@@ -44,11 +63,19 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
|
|
|
|
|
|
info!("[uniqueness] building PLCP array with libsais");
|
|
|
let started = Instant::now();
|
|
|
+
|
|
|
+ #[cfg(not(target_os = "windows"))]
|
|
|
let sa_with_plcp = sa_result
|
|
|
.plcp_construction()
|
|
|
.multi_threaded(ThreadCount::fixed(thread_count))
|
|
|
.run()
|
|
|
.expect("libsais failed to construct PLCP array");
|
|
|
+ #[cfg(target_os = "windows")]
|
|
|
+ let sa_with_plcp = sa_result
|
|
|
+ .plcp_construction()
|
|
|
+ .run()
|
|
|
+ .expect("libsais failed to construct PLCP array");
|
|
|
+
|
|
|
info!(
|
|
|
"[uniqueness] PLCP array built in {:.1}s",
|
|
|
started.elapsed().as_secs_f64()
|
|
|
@@ -56,6 +83,8 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
|
|
|
|
|
|
info!("[uniqueness] building LCP array with libsais");
|
|
|
let started = Instant::now();
|
|
|
+
|
|
|
+ #[cfg(not(target_os = "windows"))]
|
|
|
let (lcp64, _plcp64) = sa_with_plcp
|
|
|
.lcp_construction()
|
|
|
.replace_suffix_array()
|
|
|
@@ -63,6 +92,13 @@ pub fn build_suffix_array_and_lcp(genome: &[u8]) -> (Vec<GenomeCoord>, Vec<Uniqu
|
|
|
.run()
|
|
|
.expect("libsais failed to construct LCP array")
|
|
|
.into_parts();
|
|
|
+ #[cfg(target_os = "windows")]
|
|
|
+ let (lcp64, _plcp64) = sa_with_plcp
|
|
|
+ .lcp_construction()
|
|
|
+ .replace_suffix_array()
|
|
|
+ .run()
|
|
|
+ .expect("libsais failed to construct LCP array")
|
|
|
+ .into_parts();
|
|
|
|
|
|
let lcp = lcp64
|
|
|
.into_iter()
|