|
@@ -7,7 +7,7 @@ use std::{
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
use anyhow::Context;
|
|
use anyhow::Context;
|
|
|
-use bgzip::{BGZFReader, BGZFWriter};
|
|
|
|
|
|
|
+// use bgzip::{BGZFReader, BGZFWriter};
|
|
|
use bitcode::{Decode, Encode};
|
|
use bitcode::{Decode, Encode};
|
|
|
use csv::ReaderBuilder;
|
|
use csv::ReaderBuilder;
|
|
|
use dashmap::DashMap;
|
|
use dashmap::DashMap;
|
|
@@ -22,30 +22,24 @@ use super::vcf_variant::{
|
|
|
};
|
|
};
|
|
|
use crate::{
|
|
use crate::{
|
|
|
annotation::{
|
|
annotation::{
|
|
|
- cosmic::Cosmic,
|
|
|
|
|
- echtvar::{parse_echtvar_val, run_echtvar},
|
|
|
|
|
- gnomad::GnomAD,
|
|
|
|
|
- parse_trinuc,
|
|
|
|
|
- vep::{get_best_vep, VepJob, VepLine, VEP},
|
|
|
|
|
- Annotation, Annotations,
|
|
|
|
|
|
|
+ Annotation, Annotations, cosmic::Cosmic, echtvar::{parse_echtvar_val, run_echtvar}, gnomad::GnomAD, parse_trinuc, vep::{VEP, VepJob, VepLine, get_best_vep}
|
|
|
},
|
|
},
|
|
|
collection::{
|
|
collection::{
|
|
|
- bam::{counts_at, PileBase},
|
|
|
|
|
|
|
+ bam::{PileBase, counts_at},
|
|
|
vcf::Vcf,
|
|
vcf::Vcf,
|
|
|
},
|
|
},
|
|
|
config::Config,
|
|
config::Config,
|
|
|
helpers::{
|
|
helpers::{
|
|
|
- app_storage_dir, detect_repetition, estimate_shannon_entropy, mean, Hash128, Repeat,
|
|
|
|
|
- TempFileGuard,
|
|
|
|
|
|
|
+ Hash128, Repeat, TempFileGuard, app_storage_dir, detect_repetition, estimate_shannon_entropy, mean
|
|
|
},
|
|
},
|
|
|
io::{
|
|
io::{
|
|
|
fasta::{open_indexed_fasta, sequence_at},
|
|
fasta::{open_indexed_fasta, sequence_at},
|
|
|
liftover::build_machine_from_chain,
|
|
liftover::build_machine_from_chain,
|
|
|
- readers::get_reader,
|
|
|
|
|
|
|
+ readers::{get_gz_reader, get_reader},
|
|
|
vcf::vcf_header,
|
|
vcf::vcf_header,
|
|
|
- writers::get_gz_writer,
|
|
|
|
|
|
|
+ writers::{finalize_bgzf_file, get_gz_writer},
|
|
|
},
|
|
},
|
|
|
- positions::{overlaps_par, GenomePosition, GenomeRange, GetGenomePosition},
|
|
|
|
|
|
|
+ positions::{GenomePosition, GenomeRange, GetGenomePosition, overlaps_par},
|
|
|
run,
|
|
run,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -1418,15 +1412,13 @@ impl Variants {
|
|
|
/// This method uses BGZF compression, which is compatible with standard gzip decompression.
|
|
/// This method uses BGZF compression, which is compatible with standard gzip decompression.
|
|
|
/// The resulting file can be read using standard gzip-aware tools.
|
|
/// The resulting file can be read using standard gzip-aware tools.
|
|
|
pub fn save_to_json(&self, filename: &str) -> anyhow::Result<()> {
|
|
pub fn save_to_json(&self, filename: &str) -> anyhow::Result<()> {
|
|
|
- let file = File::create(filename)
|
|
|
|
|
- .with_context(|| format!("Failed to create file: {}", filename))?;
|
|
|
|
|
- let mut writer = BGZFWriter::new(file, bgzip::Compression::default());
|
|
|
|
|
|
|
+ let mut writer = get_gz_writer(filename, true)
|
|
|
|
|
+ .with_context(|| format!("Failed to open writer to file: {}", filename))?;
|
|
|
|
|
|
|
|
serde_json::to_writer(&mut writer, self)
|
|
serde_json::to_writer(&mut writer, self)
|
|
|
.with_context(|| format!("Failed to serialize JSON to file: {}", filename))?;
|
|
.with_context(|| format!("Failed to serialize JSON to file: {}", filename))?;
|
|
|
|
|
|
|
|
- writer
|
|
|
|
|
- .close()
|
|
|
|
|
|
|
+ finalize_bgzf_file(writer, filename)
|
|
|
.with_context(|| format!("Failed to close BGZF writer for file: {}", filename))?;
|
|
.with_context(|| format!("Failed to close BGZF writer for file: {}", filename))?;
|
|
|
|
|
|
|
|
debug!("Successfully saved variants to {}", filename);
|
|
debug!("Successfully saved variants to {}", filename);
|
|
@@ -1467,9 +1459,7 @@ impl Variants {
|
|
|
/// This method expects the input file to be in BGZF-compressed JSON format,
|
|
/// This method expects the input file to be in BGZF-compressed JSON format,
|
|
|
/// typically created by the `save_to_json` method of this struct.
|
|
/// typically created by the `save_to_json` method of this struct.
|
|
|
pub fn load_from_json(filename: &str) -> anyhow::Result<Self> {
|
|
pub fn load_from_json(filename: &str) -> anyhow::Result<Self> {
|
|
|
- let file =
|
|
|
|
|
- File::open(filename).with_context(|| format!("Failed to open file: {}", filename))?;
|
|
|
|
|
- let mut reader = BGZFReader::new(file)
|
|
|
|
|
|
|
+ let mut reader = get_gz_reader(filename)
|
|
|
.with_context(|| format!("Failed to create BGZF reader for file: {}", filename))?;
|
|
.with_context(|| format!("Failed to create BGZF reader for file: {}", filename))?;
|
|
|
|
|
|
|
|
let variants: Self = serde_json::from_reader(&mut reader)
|
|
let variants: Self = serde_json::from_reader(&mut reader)
|