|
@@ -16,6 +16,11 @@ use crate::{
|
|
|
}; // ton module existant
|
|
}; // ton module existant
|
|
|
|
|
|
|
|
const CONTIG_SEPARATOR: u8 = 0;
|
|
const CONTIG_SEPARATOR: u8 = 0;
|
|
|
|
|
+const BASE_A: u8 = 1;
|
|
|
|
|
+const BASE_C: u8 = 2;
|
|
|
|
|
+const BASE_G: u8 = 3;
|
|
|
|
|
+const BASE_T: u8 = 4;
|
|
|
|
|
+const BASE_N: u8 = 5;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
pub struct GenomicPos {
|
|
pub struct GenomicPos {
|
|
@@ -114,6 +119,17 @@ impl GenomeIndex {
|
|
|
"contig {} contains reserved separator byte",
|
|
"contig {} contains reserved separator byte",
|
|
|
entry.name
|
|
entry.name
|
|
|
);
|
|
);
|
|
|
|
|
+ let seq: Vec<u8> = seq
|
|
|
|
|
+ .into_iter()
|
|
|
|
|
+ .map(|base| match base {
|
|
|
|
|
+ b'A' => BASE_A,
|
|
|
|
|
+ b'C' => BASE_C,
|
|
|
|
|
+ b'G' => BASE_G,
|
|
|
|
|
+ b'T' => BASE_T,
|
|
|
|
|
+ b'N' => BASE_N,
|
|
|
|
|
+ _ => BASE_N,
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect();
|
|
|
anyhow::ensure!(
|
|
anyhow::ensure!(
|
|
|
genome.len() + seq.len() <= u32::MAX as usize,
|
|
genome.len() + seq.len() <= u32::MAX as usize,
|
|
|
"concatenated genome exceeds u32::MAX bases"
|
|
"concatenated genome exceeds u32::MAX bases"
|