From 0335681b13c027f2055e9b5ca17e15788b861f57 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:43:19 -0400 Subject: [PATCH] Actually update clap and make cli a default feature --- Cargo.toml | 2 +- src/bin/bedgraphtobigwig.rs | 48 +++++++++++---------------------- src/bin/bedtobigbed.rs | 44 ++++++++++-------------------- src/bin/bigbedtobed.rs | 20 +++++--------- src/bin/bigtools.rs | 28 +++++++++---------- src/bin/bigwigaverageoverbed.rs | 23 +++++----------- src/bin/bigwiginfo.rs | 6 ++--- src/bin/bigwigmerge.rs | 30 ++++++++------------- src/bin/bigwigtobedgraph.rs | 20 +++++--------- src/bin/bigwigvaluesoverbed.rs | 19 +++++++------ src/bin/test.rs | 6 ++--- src/bin/verify.rs | 10 +++---- 12 files changed, 96 insertions(+), 160 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a9f8b91..a77abd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ name = "verify" required-features = ["cli"] [features] -default = ["remote", "read", "write"] +default = ["remote", "read", "write", "cli"] remote = ["attohttpc", "tempfile"] cli = ["clap", "ryu", "ufmt"] read = ["bytes"] diff --git a/src/bin/bedgraphtobigwig.rs b/src/bin/bedgraphtobigwig.rs index f6f4edc..47488a1 100644 --- a/src/bin/bedgraphtobigwig.rs +++ b/src/bin/bedgraphtobigwig.rs @@ -6,14 +6,14 @@ use std::path::PathBuf; use bigtools::bed::indexer::index_chroms; use bigtools::bedchromdata::{BedParserParallelStreamingIterator, BedParserStreamingIterator}; -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::BigWigWrite; use bigtools::bbiwrite::InputSortType; use bigtools::bed::bedparser::{parse_bedgraph, BedParser}; fn main() -> Result<(), Box> { - let matches = App::new("BedGraphToBigWig") + let matches = Command::new("BedGraphToBigWig") .about("Converts an input bedGraph to a bigWig. Can be multi-threaded for substantial speedups. Note that ~11 temporary files are created/maintained.") .arg(Arg::new("bedgraph") .help("The bedgraph to convert to a bigwig. Can use `-` or `stdin` to read from stdin.") @@ -33,12 +33,12 @@ fn main() -> Result<(), Box> { .arg(Arg::new("nthreads") .short('t') .help("Set the number of threads to use. This tool will typically use ~225% CPU on a HDD. SDDs may be higher. (IO bound)") - .takes_value(true) + .num_args(1) .default_value("6")) .arg(Arg::new("nzooms") .short('z') .help("Set the maximum of zooms to create.") - .takes_value(true) + .num_args(1) .default_value("10")) .arg(Arg::new("uncompressed") .short('u') @@ -46,40 +46,22 @@ fn main() -> Result<(), Box> { .arg(Arg::new("sorted") .short('s') .help("Sets whether the input is sorted. Can take `all`, `start`, or `none`. `all` means that the input bedGraph is sorted by chroms and start (`sort -k1,1 -k2,2n`). `start` means that the the chroms are out of order but the starts within a chrom is sorted. `none` means that the file is not sorted at all. `all` is default. `none` currently errors but may be supported in the future. Note that using a value other than `all` will not guarantee (though likely) support for third-party tools.") - .takes_value(true) + .num_args(1) .default_value("all")) .arg(Arg::new("parallel") .short('p') .help("Set whether to read and convert the bedGraph in parallel. Can take `auto` (default), `yes`, `no`. Ignored when input is stdin or when nthreads is `1`.") - .takes_value(true) + .num_args(1) .default_value("auto")) .get_matches(); - let bedgraphpath = matches.value_of("bedgraph").unwrap().to_owned(); - let chrom_map = matches.value_of("chromsizes").unwrap().to_owned(); - let bigwigpath = matches.value_of("output").unwrap().to_owned(); - let nthreads = { - let nthreads = matches.value_of("nthreads").unwrap(); - match nthreads.parse() { - Ok(parsed) => parsed, - Err(_) => { - eprintln!("Invalid argument for `nthreads`: must be a positive number"); - return Ok(()); - } - } - }; - let nzooms = { - let nzooms = matches.value_of("nzooms").unwrap(); - match nzooms.parse() { - Ok(parsed) => parsed, - Err(_) => { - eprintln!("Invalid argument for `nzooms`: must be a positive number"); - return Ok(()); - } - } - }; - let uncompressed = matches.is_present("uncompressed"); - let input_sort_type = match matches.value_of("sorted") { + let bedgraphpath = matches.get_one::("bedgraph").unwrap().to_owned(); + let chrom_map = matches.get_one::("chromsizes").unwrap().to_owned(); + let bigwigpath = matches.get_one::("output").unwrap().to_owned(); + let nthreads = *matches.get_one::("nthreads").unwrap(); + let nzooms = *matches.get_one::("nzooms").unwrap(); + let uncompressed = matches.get_count("uncompressed") > 0; + let input_sort_type = match matches.get_one::("sorted").map(String::as_ref) { None => InputSortType::ALL, Some("all") => InputSortType::ALL, Some("start") => InputSortType::START, @@ -132,8 +114,8 @@ fn main() -> Result<(), Box> { } else { let infile = File::open(&bedgraphpath)?; let large_file = infile.metadata()?.len() >= 200_000_000; - let parallel = matches.value_of("auto"); - let parallel = match (nthreads, parallel) { + let parallel = matches.get_one::("auto"); + let parallel = match (nthreads, parallel.map(String::as_ref)) { (1, _) | (_, None) | (_, Some("auto")) => large_file, (_, Some("yes")) => true, (_, Some("no")) => false, diff --git a/src/bin/bedtobigbed.rs b/src/bin/bedtobigbed.rs index 7ffd7f6..4c9ed0c 100644 --- a/src/bin/bedtobigbed.rs +++ b/src/bin/bedtobigbed.rs @@ -4,14 +4,14 @@ use std::fs::File; use std::io::{BufRead, BufReader}; use bigtools::bedchromdata::BedParserStreamingIterator; -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::BigBedWrite; use bigtools::bbiwrite::InputSortType; use bigtools::bed::bedparser::BedParser; fn main() -> Result<(), Box> { - let matches = App::new("BedToBigBed") + let matches = Command::new("BedToBigBed") .arg(Arg::new("bed") .help("the n to convert to a bigbed") .index(1) @@ -30,12 +30,12 @@ fn main() -> Result<(), Box> { .arg(Arg::new("nthreads") .short('t') .help("Set the number of threads to use") - .takes_value(true) + .num_args(1) .default_value("6")) .arg(Arg::new("nzooms") .short('z') .help("Set the maximum of zooms to create.") - .takes_value(true) + .num_args(1) .default_value("10")) .arg(Arg::new("uncompressed") .short('u') @@ -43,37 +43,21 @@ fn main() -> Result<(), Box> { .arg(Arg::new("sorted") .short('s') .help("Sets whether the input is sorted. Can take `all`, `start`, or `none`. `all` means that the input bedGraph is sorted by chroms and start (`sort -k1,1 -k2,2n`). `start` means that the the chroms are out of order but the starts within a chrom is sorted. `none` means that the file is not sorted at all. `all` is default. `none` currently errors but may be supported in the future. Note that using a value other than `all` will not guarantee (though likely) support for third-party tools.") - .takes_value(true) + .num_args(1) .default_value("all")) .arg(Arg::new("autosql") .short('a') .help("The path to an .as file containing the autosql that defines the fields in this bigBed") - .takes_value(true)) + .num_args(1)) .get_matches(); - let bedpath = matches.value_of("bed").unwrap().to_owned(); - let chrom_map = matches.value_of("chromsizes").unwrap().to_owned(); - let bigwigpath = matches.value_of("output").unwrap().to_owned(); - let nthreads = { - let nthreads = matches.value_of("nthreads").unwrap(); - let parsed = nthreads.parse(); - if parsed.is_err() { - eprintln!("Invalid argument for `nthreads`: must be a positive number"); - return Ok(()); - } - parsed.unwrap() - }; - let nzooms = { - let nzooms = matches.value_of("nzooms").unwrap(); - let parsed = nzooms.parse(); - if parsed.is_err() { - eprintln!("Invalid argument for `nzooms`: must be a positive number"); - return Ok(()); - } - parsed.unwrap() - }; - let uncompressed = { matches.is_present("uncompressed") }; - let input_sort_type = match matches.value_of("sorted") { + let bedpath = matches.get_one::("bed").unwrap().to_owned(); + let chrom_map = matches.get_one::("chromsizes").unwrap().to_owned(); + let bigwigpath = matches.get_one::("output").unwrap().to_owned(); + let nthreads = *matches.get_one::("nthreads").unwrap(); + let nzooms = *matches.get_one::("nzooms").unwrap(); + let uncompressed = { matches.get_count("uncompressed") > 0 }; + let input_sort_type = match matches.get_one::("sorted").map(String::as_ref) { None => InputSortType::ALL, Some("all") => InputSortType::ALL, Some("start") => InputSortType::START, @@ -118,7 +102,7 @@ fn main() -> Result<(), Box> { let infile = File::open(bedpath)?; let mut vals_iter = BedParser::from_bed_file(infile); - let autosql = match matches.value_of("autosql") { + let autosql = match matches.get_one::("autosql") { None => { use bigtools::utils::chromvalues::ChromValues; let (_, mut group) = vals_iter.next_chrom().unwrap().unwrap(); diff --git a/src/bin/bigbedtobed.rs b/src/bin/bigbedtobed.rs index 00cf669..0025419 100644 --- a/src/bin/bigbedtobed.rs +++ b/src/bin/bigbedtobed.rs @@ -2,7 +2,7 @@ use std::error::Error; use std::fs::File; use std::io::{self, Write}; -use clap::{App, Arg}; +use clap::{Arg, Command}; use futures::task::SpawnExt; @@ -66,7 +66,7 @@ pub fn write_bed( } fn main() -> Result<(), Box> { - let matches = App::new("BigBedToBedGraph") + let matches = Command::new("BigBedToBedGraph") .about("Converts an input bigBed to a bed. Can be multi-threaded for substantial speedups. Note for roughly each core, one temporary file will be opened.") .arg(Arg::new("bigbed") .help("the bigbed to get convert to bed") @@ -81,22 +81,14 @@ fn main() -> Result<(), Box> { .arg(Arg::new("nthreads") .short('t') .help("Set the number of threads to use. This tool will nearly always benefit from more cores (<= # chroms). Note: for parts of the runtime, the actual usage may be nthreads+1") - .takes_value(true) + .num_args(1) .default_value("6")) .get_matches(); - let bigbedpath = matches.value_of("bigbed").unwrap().to_owned(); - let bedpath = matches.value_of("bed").unwrap().to_owned(); + let bigbedpath = matches.get_one::("bigbed").unwrap().to_owned(); + let bedpath = matches.get_one::("bed").unwrap().to_owned(); - let nthreads = { - let nthreads = matches.value_of("nthreads").unwrap(); - let parsed = nthreads.parse(); - if parsed.is_err() { - eprintln!("Invalid argument for `nthreads`: must be a positive number"); - return Ok(()); - } - parsed.unwrap() - }; + let nthreads = *matches.get_one::("nthreads").unwrap(); let bigbed = BigBedRead::open_file(bigbedpath)?; let bed = File::create(bedpath)?; diff --git a/src/bin/bigtools.rs b/src/bin/bigtools.rs index cf7dbba..6c5ef57 100644 --- a/src/bin/bigtools.rs +++ b/src/bin/bigtools.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::io::{self, BufReader, BufWriter, Write}; use bigtools::{BigWigRead, BigWigReadAttachError}; -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::{BigBedRead, BigBedReadAttachError}; use bigtools::utils::reopen::SeekableRead; @@ -148,47 +148,47 @@ fn chromintersect(apath: String, bpath: String, outpath: String) -> io::Result<( } fn main() -> Result<(), BigBedReadAttachError> { - let matches = App::new("BigTools") + let matches = Command::new("BigTools") .subcommand( - App::new("intersect") + Command::new("intersect") .about("Intersect all entries of a bed with a bigBed") .arg( Arg::new("a") .short('a') .help("Each entry in this bed is compared against b for overlaps.") - .takes_value(true) + .num_args(1) .required(true), ) .arg( Arg::new("b") .short('b') .help("Each entry in a will be compared against this bigBed for overlaps.") - .takes_value(true) + .num_args(1) .required(true), ), ) .subcommand( - App::new("chromintersect") + Command::new("chromintersect") .about("Create a new file of the same type, containing only data from `a` with chromosomes from `b`") .arg( Arg::new("a") .short('a') .help("The file to take data from (currently supports: bed)") - .takes_value(true) + .num_args(1) .required(true), ) .arg( Arg::new("b") .short('b') .help("The file to take reference chromosomes from (currently supports: bigWig or bigBed)") - .takes_value(true) + .num_args(1) .required(true), ) .arg( Arg::new("out") .short('o') .help("The name of the output file (or - for stdout). Outputted in same format as `a`") - .takes_value(true) + .num_args(1) .required(true), ), ) @@ -198,8 +198,8 @@ fn main() -> Result<(), BigBedReadAttachError> { Some(("intersect", matches)) => { eprintln!("---BigTools intersect---"); - let apath = matches.value_of("a").unwrap().to_owned(); - let bpath = matches.value_of("b").unwrap().to_owned(); + let apath = matches.get_one::("a").unwrap().to_owned(); + let bpath = matches.get_one::("b").unwrap().to_owned(); let b = BigBedRead::open_file(bpath)?; @@ -208,9 +208,9 @@ fn main() -> Result<(), BigBedReadAttachError> { Some(("chromintersect", matches)) => { eprintln!("---BigTools chromintersect---"); - let apath = matches.value_of("a").unwrap().to_owned(); - let bpath = matches.value_of("b").unwrap().to_owned(); - let outpath = matches.value_of("out").unwrap().to_owned(); + let apath = matches.get_one::("a").unwrap().to_owned(); + let bpath = matches.get_one::("b").unwrap().to_owned(); + let outpath = matches.get_one::("out").unwrap().to_owned(); chromintersect(apath, bpath, outpath)?; } diff --git a/src/bin/bigwigaverageoverbed.rs b/src/bin/bigwigaverageoverbed.rs index 0879dc2..469611f 100644 --- a/src/bin/bigwigaverageoverbed.rs +++ b/src/bin/bigwigaverageoverbed.rs @@ -8,14 +8,14 @@ use bigtools::bed::indexer::index_chroms; use bigtools::utils::chromvalues::ChromValues; use bigtools::utils::reopen::{Reopen, SeekableRead}; use bigtools::utils::streaming_linereader::StreamingLineReader; -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::BigWigRead; use bigtools::utils::misc::{stats_for_bed_item, Name}; use crossbeam_channel::TryRecvError; fn main() -> Result<(), Box> { - let matches = App::new("BigWigAverageOverBed") + let matches = Command::new("BigWigAverageOverBed") .arg(Arg::new("bigwig") .help("The input bigwig file") .index(1) @@ -43,9 +43,9 @@ fn main() -> Result<(), Box> { ) .get_matches(); - let bigwigpath = matches.value_of("bigwig").unwrap(); - let bedinpath = matches.value_of("bedin").unwrap(); - let bedoutpath = matches.value_of("output").unwrap(); + let bigwigpath = matches.get_one::("bigwig").unwrap(); + let bedinpath = matches.get_one::("bedin").unwrap(); + let bedoutpath = matches.get_one::("output").unwrap(); let mut inbigwig = BigWigRead::open_file(bigwigpath)?; let outbed = File::create(bedoutpath)?; @@ -54,7 +54,7 @@ fn main() -> Result<(), Box> { let bedin = BufReader::new(File::open(bedinpath)?); let mut bedstream = StreamingLineReader::new(bedin); - let name = match matches.value_of("namecol") { + let name = match matches.get_one::("namecol").map(String::as_ref) { Some("interval") => Name::Interval, Some("none") => Name::None, Some(col) => { @@ -74,16 +74,7 @@ fn main() -> Result<(), Box> { None => Name::Column(3), }; - let nthreads: usize = { - let nthreads = matches.value_of("nthreads").unwrap(); - match nthreads.parse() { - Ok(parsed) => parsed, - Err(_) => { - eprintln!("Invalid argument for `nthreads`: must be a positive number"); - return Ok(()); - } - } - }; + let nthreads: usize = *matches.get_one::("nthreads").unwrap(); let parallel = nthreads > 1; if parallel { diff --git a/src/bin/bigwiginfo.rs b/src/bin/bigwiginfo.rs index bf34eb1..5afb5e4 100644 --- a/src/bin/bigwiginfo.rs +++ b/src/bin/bigwiginfo.rs @@ -1,9 +1,9 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::{BigWigRead, BigWigReadAttachError}; fn main() -> Result<(), BigWigReadAttachError> { - let matches = App::new("BigWigInfo") + let matches = Command::new("BigWigInfo") .arg( Arg::new("bigwig") .help("the bigwig to get info for") @@ -12,7 +12,7 @@ fn main() -> Result<(), BigWigReadAttachError> { ) .get_matches(); - let bigwigpath = matches.value_of("bigwig").unwrap(); + let bigwigpath = matches.get_one::("bigwig").unwrap(); #[cfg(feature = "remote")] { diff --git a/src/bin/bigwigmerge.rs b/src/bin/bigwigmerge.rs index 17e96aa..68f7241 100644 --- a/src/bin/bigwigmerge.rs +++ b/src/bin/bigwigmerge.rs @@ -3,7 +3,7 @@ use std::error::Error; use std::fs::File; use std::io::{self, BufRead, BufReader}; -use clap::{App, Arg}; +use clap::{Arg, Command}; use thiserror::Error; use bigtools::bbi::Value; @@ -223,7 +223,7 @@ impl> ChromData for ChromGroupReadImpl { } fn main() -> Result<(), Box> { - let matches = App::new("BigWigMerge") + let matches = Command::new("BigWigMerge") .arg(Arg::new("output") .help("the path of the merged output bigwig (if .bw or .bigWig) or bedGraph (if .bedGraph)") .index(1) @@ -232,26 +232,26 @@ fn main() -> Result<(), Box> { .arg(Arg::new("bigwig") .short('b') .help("the path of an input bigwig to merge") - .multiple_occurrences(true) - .takes_value(true) + .action(clap::ArgAction::Append) + .num_args(1) ) .arg(Arg::new("list") .short('l') .help("a line-delimited list of bigwigs") - .multiple_occurrences(true) - .takes_value(true) + .action(clap::ArgAction::Append) + .num_args(1) ) .arg(Arg::new("nthreads") .short('t') .help("Set the number of threads to use") - .takes_value(true) + .num_args(1) .default_value("6")) .get_matches(); - let output = matches.value_of("output").unwrap().to_owned(); + let output = matches.get_one::("output").unwrap().to_owned(); let mut bigwigs: Vec> = vec![]; - if let Some(bws) = matches.values_of("bigwig") { + if let Some(bws) = matches.get_many::("bigwig") { for name in bws { match BigWigRead::open_file(name) { Ok(bw) => bigwigs.push(bw), @@ -262,7 +262,7 @@ fn main() -> Result<(), Box> { } } } - if let Some(lists) = matches.values_of("list") { + if let Some(lists) = matches.get_many::("list") { for list in lists { let list_file = match File::open(list) { Ok(f) => f, @@ -285,15 +285,7 @@ fn main() -> Result<(), Box> { } } - let nthreads = { - let nthreads = matches.value_of("nthreads").unwrap(); - let parsed = nthreads.parse(); - if parsed.is_err() { - eprintln!("Invalid argument for `nthreads`: must be a positive number"); - return Ok(()); - } - parsed.unwrap() - }; + let nthreads = *matches.get_one::("nthreads").unwrap(); let (iter, chrom_map) = get_merged_vals(bigwigs, 10)?; diff --git a/src/bin/bigwigtobedgraph.rs b/src/bin/bigwigtobedgraph.rs index ba9aef9..77e0e44 100644 --- a/src/bin/bigwigtobedgraph.rs +++ b/src/bin/bigwigtobedgraph.rs @@ -2,7 +2,7 @@ use std::error::Error; use std::fs::File; use std::io::{self, Write}; -use clap::{App, Arg}; +use clap::{Arg, Command}; use futures::task::SpawnExt; @@ -85,7 +85,7 @@ pub fn write_bg( } fn main() -> Result<(), Box> { - let matches = App::new("BigWigToBedGraph") + let matches = Command::new("BigWigToBedGraph") .about("Converts an input bigWig to a bedGraph. Can be multi-threaded for substantial speedups. Note for roughly each core, one temporary file will be opened.") .arg(Arg::new("bigwig") .help("the bigwig to get convert to bedgraph") @@ -100,22 +100,14 @@ fn main() -> Result<(), Box> { .arg(Arg::new("nthreads") .short('t') .help("Set the number of threads to use. This tool will nearly always benefit from more cores (<= # chroms). Note: for parts of the runtime, the actual usage may be nthreads+1") - .takes_value(true) + .num_args(1) .default_value("6")) .get_matches(); - let bigwigpath = matches.value_of("bigwig").unwrap(); - let bedgraphpath = matches.value_of("bedgraph").unwrap(); + let bigwigpath = matches.get_one::("bigwig").unwrap(); + let bedgraphpath = matches.get_one::("bedgraph").unwrap(); - let nthreads = { - let nthreads = matches.value_of("nthreads").unwrap(); - let parsed = nthreads.parse(); - if parsed.is_err() { - eprintln!("Invalid argument for `nthreads`: must be a positive number"); - return Ok(()); - } - parsed.unwrap() - }; + let nthreads = *matches.get_one::("nthreads").unwrap(); let bigwig = BigWigRead::open_file(bigwigpath)?; let bedgraph = File::create(bedgraphpath)?; diff --git a/src/bin/bigwigvaluesoverbed.rs b/src/bin/bigwigvaluesoverbed.rs index 534521e..1ee1014 100644 --- a/src/bin/bigwigvaluesoverbed.rs +++ b/src/bin/bigwigvaluesoverbed.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::io::{self, BufRead, BufReader, BufWriter, Write}; use std::path::Path; -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::BigWigRead; use bigtools::bbiread::BBIReadError; @@ -92,7 +92,7 @@ fn write( } fn main() -> Result<(), Box> { - let matches = App::new("BigWigInfo") + let matches = Command::new("BigWigInfo") .arg(Arg::new("bigwig") .help("The input bigwig file") .index(1) @@ -114,17 +114,20 @@ fn main() -> Result<(), Box> { ) .arg(Arg::new("delimiter") .short('d') - .takes_value(true) + .num_args(1) .help("Sets the delimiter to use for the output file. (Defaults to tab).") ) .get_matches(); - let bigwigpath = matches.value_of("bigwig").unwrap(); - let bedinpath = matches.value_of("bedin").unwrap(); - let outputpath = matches.value_of("output").unwrap(); + let bigwigpath = matches.get_one::("bigwig").unwrap(); + let bedinpath = matches.get_one::("bedin").unwrap(); + let outputpath = matches.get_one::("output").unwrap(); - let withnames = matches.is_present("names"); - let mut delimiter = matches.value_of("delimiter").unwrap_or("\t").to_owned(); + let withnames = matches.get_count("names") > 0; + let mut delimiter = matches + .get_one::("delimiter") + .unwrap_or(&"\t".to_string()) + .clone(); if delimiter == "\\t" { delimiter = String::from("\t"); } diff --git a/src/bin/test.rs b/src/bin/test.rs index c37a246..ad8cf6a 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -1,11 +1,11 @@ use std::error::Error; -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::BigBedRead; fn main() -> Result<(), Box> { - let matches = App::new("Testing") + let matches = Command::new("Testing") .arg( Arg::new("bigbed") .help("the bigbed to get info for") @@ -14,7 +14,7 @@ fn main() -> Result<(), Box> { ) .get_matches(); - let bigwigpath = matches.value_of("bigbed").unwrap().to_owned(); + let bigwigpath = matches.get_one::("bigbed").unwrap().to_owned(); let mut bigwig = BigBedRead::open_file(bigwigpath)?; println!("info: {:?}", bigwig.info); diff --git a/src/bin/verify.rs b/src/bin/verify.rs index 9db42a2..5707222 100644 --- a/src/bin/verify.rs +++ b/src/bin/verify.rs @@ -1,9 +1,9 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; use bigtools::bbi::{BigWigRead, BigWigReadAttachError}; fn main() -> Result<(), BigWigReadAttachError> { - let matches = App::new("Verify") + let matches = Command::new("Verify") .about("Verifies different parts of a bigwig or bigbed file. By default, it only verifies the header is correct and that file offsets are valid.") .arg(Arg::new("input") .help("the bigwig or bigbed to verify") @@ -20,9 +20,9 @@ fn main() -> Result<(), BigWigReadAttachError> { ) .get_matches(); - let bigwigpath = matches.value_of("input").unwrap(); - let _index = matches.is_present("index"); - let _data = matches.is_present("data"); + let bigwigpath = matches.get_one::("input").unwrap(); + let _index = matches.get_count("index") > 0; + let _data = matches.get_count("data") > 0; let _bigwig = BigWigRead::open_file(bigwigpath)?;