|
|
@@ -23,7 +23,7 @@ use crate::{
|
|
|
bam::{counts_at, counts_ins_at},
|
|
|
vcf::Vcf,
|
|
|
},
|
|
|
- helpers::{app_storage_dir, estimate_shannon_entropy, temp_file_path},
|
|
|
+ helpers::{app_storage_dir, estimate_shannon_entropy, temp_file_path, Hash128},
|
|
|
io::{readers::get_reader, vcf::vcf_header},
|
|
|
pipes::somatic::sequence_at,
|
|
|
};
|
|
|
@@ -37,18 +37,18 @@ pub struct VariantCollection {
|
|
|
}
|
|
|
|
|
|
impl VariantCollection {
|
|
|
- pub fn keys(&self) -> Vec<u128> {
|
|
|
- self.variants.iter().map(|v| v.hash_variant()).collect()
|
|
|
+ pub fn keys(&self) -> Vec<Hash128> {
|
|
|
+ self.variants.iter().map(|v| v.hash()).collect()
|
|
|
}
|
|
|
|
|
|
- pub fn retain_keys(&mut self, keys_to_keep: &HashSet<u128>) {
|
|
|
+ pub fn retain_keys(&mut self, keys_to_keep: &HashSet<Hash128>) {
|
|
|
self.variants
|
|
|
- .retain(|v| keys_to_keep.contains(&v.hash_variant()));
|
|
|
+ .retain(|v| keys_to_keep.contains(&v.hash()));
|
|
|
}
|
|
|
|
|
|
- pub fn remove_keys(&mut self, keys_to_remove: &HashSet<u128>) {
|
|
|
+ pub fn remove_keys(&mut self, keys_to_remove: &HashSet<Hash128>) {
|
|
|
self.variants
|
|
|
- .retain(|v| !keys_to_remove.contains(&v.hash_variant()));
|
|
|
+ .retain(|v| !keys_to_remove.contains(&v.hash()));
|
|
|
}
|
|
|
|
|
|
pub fn partition<F>(self, predicate: F) -> (Self, Self)
|
|
|
@@ -102,7 +102,7 @@ impl VariantCollection {
|
|
|
.unwrap();
|
|
|
|
|
|
for c in chunk {
|
|
|
- let key = c.hash_variant();
|
|
|
+ let key = c.hash();
|
|
|
let mut anns = annotations.store.entry(key).or_default();
|
|
|
|
|
|
if !anns
|
|
|
@@ -136,7 +136,7 @@ impl VariantCollection {
|
|
|
.map_err(|e| anyhow::anyhow!("Failed to open BAM file: {e}"))?;
|
|
|
|
|
|
for var in chunk {
|
|
|
- let key = var.hash_variant();
|
|
|
+ let key = var.hash();
|
|
|
let mut anns = annotations.store.entry(key).or_default();
|
|
|
|
|
|
if anns
|
|
|
@@ -233,7 +233,7 @@ impl ExternalAnnotation {
|
|
|
let mut unfound = Vec::new();
|
|
|
|
|
|
for variant in variants {
|
|
|
- let hash: u128 = variant.hash_variant();
|
|
|
+ let hash = variant.hash();
|
|
|
let mut has_pushed = false;
|
|
|
|
|
|
// Check COSMIC
|
|
|
@@ -277,12 +277,12 @@ impl ExternalAnnotation {
|
|
|
|
|
|
fn get_annotation<T: serde::de::DeserializeOwned>(
|
|
|
&self,
|
|
|
- hash: u128,
|
|
|
+ hash: Hash128,
|
|
|
source: &str,
|
|
|
) -> anyhow::Result<Option<T>> {
|
|
|
let result: SqliteResult<Vec<u8>> = self.conn.query_row(
|
|
|
"SELECT data FROM annotations WHERE hash = ? AND source = ?",
|
|
|
- params![hash.to_le_bytes().to_vec(), source],
|
|
|
+ params![hash.to_bytes(), source],
|
|
|
|row| row.get(0),
|
|
|
);
|
|
|
|
|
|
@@ -354,7 +354,7 @@ impl ExternalAnnotation {
|
|
|
|
|
|
let (cosmic, gnomad) = parse_echtvar_val(&row.info)?;
|
|
|
|
|
|
- let hash = chunk[i].hash_variant();
|
|
|
+ let hash = chunk[i].hash();
|
|
|
|
|
|
chunk_results.push((hash, cosmic, gnomad));
|
|
|
}
|
|
|
@@ -416,7 +416,7 @@ impl ExternalAnnotation {
|
|
|
let mut unfound = Vec::new();
|
|
|
|
|
|
for variant in variants {
|
|
|
- let hash: u128 = variant.hash_variant();
|
|
|
+ let hash = variant.hash();
|
|
|
|
|
|
// Check VEP
|
|
|
match self.get_annotation(hash, "VEP")? {
|
|
|
@@ -495,14 +495,14 @@ impl ExternalAnnotation {
|
|
|
fs::remove_file(out_vep)?;
|
|
|
|
|
|
let mut n_not_vep = 0;
|
|
|
- let mut chunk_results: Vec<(u128, Vec<VEP>)> = Vec::new();
|
|
|
+ let mut chunk_results: Vec<(Hash128, Vec<VEP>)> = Vec::new();
|
|
|
|
|
|
chunk.iter().enumerate().for_each(|(i, entry)| {
|
|
|
let k = (i + 1) as u64;
|
|
|
|
|
|
if let Some(vep_lines) = lines.get(&k) {
|
|
|
if let Ok(veps) = vep_lines.iter().map(VEP::try_from).collect() {
|
|
|
- chunk_results.push((entry.hash_variant(), veps));
|
|
|
+ chunk_results.push((entry.hash(), veps));
|
|
|
}
|
|
|
} else {
|
|
|
n_not_vep += 1;
|
|
|
@@ -530,12 +530,12 @@ impl ExternalAnnotation {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
- pub fn update_database(&self, hash: u128, source: &str, data: &[u8]) -> anyhow::Result<()> {
|
|
|
+ pub fn update_database(&self, hash: Hash128, source: &str, data: &[u8]) -> anyhow::Result<()> {
|
|
|
let modified = chrono::Utc::now().to_rfc3339();
|
|
|
|
|
|
self.conn.execute(
|
|
|
"INSERT OR REPLACE INTO annotations (hash, source, data, modified) VALUES (?, ?, ?, ?)",
|
|
|
- params![hash.to_le_bytes().to_vec(), source, data, modified],
|
|
|
+ params![hash.to_bytes(), source, data, modified],
|
|
|
)?;
|
|
|
Ok(())
|
|
|
}
|