Skip to content

Commit 82a8c1e

Browse files
committed
finish the work I started
1 parent 1fee235 commit 82a8c1e

6 files changed

Lines changed: 36 additions & 154 deletions

File tree

Cargo.toml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "vartovcf"
33
version = "0.1.0"
44
authors = ["Clint Valentine <valentine.clint@gmail.com>"]
5-
edition = "2021"
5+
edition = "2024"
66
license = "MIT"
77
readme = "README.md"
88
repository = "https://github.com/clintval/vartovcf"
@@ -24,23 +24,26 @@ name = "vartovcf"
2424
path = "src/main.rs"
2525

2626
[dependencies]
27-
anyhow = "1.0.86"
28-
bio-types = "1.0.1"
27+
anyhow = "1.0.100"
28+
bio-types = "1.0.4"
2929
case = "1.0.0"
30-
chrono = "0.4.38"
31-
csv = "1.3.0"
32-
env_logger = "0.11.3"
33-
log = "0.4.22"
34-
rust-htslib = "0.47.0"
35-
serde = { version = "1.0.203", features = ["derive"] }
36-
serde_with = { version = "3.8.3" }
30+
csv = "1.4.0"
31+
env_logger = "0.11.8"
32+
log = "0.4.28"
33+
proglog = "0.4.0"
34+
rust-htslib = "0.51.0"
35+
serde = { version = "1.0.228", features = ["derive"] }
36+
serde_with = { version = "3.15.0" }
3737
structopt = "0.3.26"
38-
strum = { version = "0.26.3", features = ["derive"] }
38+
strum = { version = "0.27.2", features = ["derive"] }
3939

4040
[dev-dependencies]
41-
assert_cmd = "2.0.14"
42-
env_logger = "0.11.3"
41+
assert_cmd = "2.0.17"
42+
env_logger = "0.11.8"
4343
file_diff = "1.0.0"
44-
pretty_assertions = "1.4.0"
45-
rstest = "0.21.0"
46-
tempfile = "3.10.1"
44+
pretty_assertions = "1.4.1"
45+
rstest = "0.26.1"
46+
tempfile = "3.23.0"
47+
48+
[lints.rust]
49+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

src/lib/fai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
I: AsRef<Path> + Debug,
9393
{
9494
match fasta.as_ref().to_str() {
95-
Some(path) => header.push_record(format!("##reference={}", path).as_bytes()),
95+
Some(path) => header.push_record(format!("##reference={path}").as_bytes()),
9696
None => return Err("Could not create a string out of the FASTA path".into()),
9797
};
9898
Ok(())

src/lib/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@ use std::io::Read;
1313
use std::path::{Path, PathBuf};
1414
use strum::Display;
1515
use strum::{EnumString, VariantNames};
16+
use proglog::ProgLogBuilder;
1617

1718
use crate::fai::{fasta_contigs_to_vcf_header, fasta_path_to_vcf_header};
1819
use crate::io::has_gzip_ext;
19-
use crate::progress_logger::{ProgressLogger, RecordLogger, DEFAULT_LOG_EVERY};
2020
use crate::record::tumor_only_header;
2121
use crate::record::TumorOnlyVariant;
2222

2323
pub mod fai;
2424
pub mod io;
25-
pub mod progress_logger;
2625
pub mod record;
2726

28-
/// The default log level for the `vartovcf` tool.
29-
pub const DEFAULT_LOG_LEVEL: &str = "info";
30-
3127
/// The valid structural variation (SV) type values for the `SVTYPE` FORMAT field.
3228
pub const VALID_SV_TYPES: &[&str] = &["BND", "CNV", "DEL", "DUP", "INS", "INV"];
3329

@@ -99,7 +95,13 @@ where
9995
}
10096
.expect("Could not build a VCF writer!");
10197

102-
let mut progress = ProgressLogger::new("processed", "variant records", DEFAULT_LOG_EVERY);
98+
let progress = ProgLogBuilder::new()
99+
.name("main")
100+
.verb("Processed")
101+
.noun("variant records")
102+
.unit(10_000)
103+
.build();
104+
103105
let mut carry = csv::StringRecord::new();
104106
let mut variant = writer.empty_record();
105107
let mut seen: HashSet<String> = HashSet::new();
@@ -123,7 +125,6 @@ where
123125

124126
if var.sample != sample {
125127
let message = format!("Expected sample '{}' found '{}'!", sample, var.sample);
126-
progress.emit()?;
127128
return Err(message.into());
128129
};
129130

@@ -197,11 +198,9 @@ where
197198
variant.push_format_integer(b"VD", &[var.alt_depth])?;
198199

199200
writer.write(&variant)?;
200-
progress.observe()?;
201+
progress.record();
201202
}
202203

203-
progress.emit()?;
204-
205204
Ok(0)
206205
}
207206

src/lib/progress_logger.rs

Lines changed: 0 additions & 120 deletions
This file was deleted.

src/lib/record.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl error::Error for ParsePairBiasError {}
7979

8080
impl fmt::Display for ParsePairBiasError {
8181
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
82-
write!(f, "{:?}", self)
82+
write!(f, "{self:?}")
8383
}
8484
}
8585

@@ -91,7 +91,7 @@ impl error::Error for ParseSvInfoError {}
9191

9292
impl fmt::Display for ParseSvInfoError {
9393
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94-
write!(f, "{:?}", self)
94+
write!(f, "{self:?}")
9595
}
9696
}
9797

@@ -111,7 +111,7 @@ pub enum StrandBias {
111111

112112
impl fmt::Display for StrandBias {
113113
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
114-
write!(f, "{:?}", self)
114+
write!(f, "{self:?}")
115115
}
116116
}
117117

@@ -371,7 +371,7 @@ pub fn tumor_only_header(sample: &str) -> Header {
371371
let mut header = Header::default();
372372
header.push_sample(sample.as_bytes());
373373
header.remove_filter(b"PASS");
374-
header.push_record(format!("##source={}", source).as_bytes());
374+
header.push_record(format!("##source={source}").as_bytes());
375375
header.push_record(r#"##INFO=<ID=ADJAF,Number=1,Type=Float,Description="Adjusted allele frequency for indels due to local realignment. Lossy due to rounding.">"#.as_bytes());
376376
header.push_record(r#"##INFO=<ID=BIAS,Number=1,Type=String,Description="Strand bias flags (UnDetected, Detected, TooFewReads) in the format `reference`:`alternate`.">"#.as_bytes());
377377
header.push_record(r#"##INFO=<ID=BIASALT,Number=2,Type=Integer,Description="The number of variant call forward and reverse reads in the format `forward`:`reverse`.">"#.as_bytes());

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ struct Opt {
4444
/// Main binary entrypoint.
4545
#[cfg(not(tarpaulin_include))]
4646
fn main() -> Result<(), Error> {
47-
let env = Env::default().default_filter_or(vartovcflib::DEFAULT_LOG_LEVEL);
47+
let env = Env::default().default_filter_or("info");
4848
let opt = Opt::from_args();
4949

5050
env_logger::Builder::from_env(env).init();
5151

5252
let input: Box<dyn Read> = match &opt.input {
5353
Some(path) if path.to_str().unwrap() != "-" => {
54-
info!("Input file: {:?}", path);
54+
info!("Input file: {path:?}");
5555
Box::new(BufReader::new(File::open(path)?))
5656
}
5757
_ => {
@@ -61,7 +61,7 @@ fn main() -> Result<(), Error> {
6161
};
6262

6363
match &opt.output {
64-
Some(output) if output.to_str().unwrap() != "-" => info!("Output file: {:?}", output),
64+
Some(output) if output.to_str().unwrap() != "-" => info!("Output file: {output:?}"),
6565
_ => info!("Output stream: STDOUT"),
6666
}
6767

0 commit comments

Comments
 (0)