From fdb92d52738d9b388718756f3a221f41ec619682 Mon Sep 17 00:00:00 2001 From: Anicet Ebou Date: Tue, 25 Jun 2024 02:33:33 +0000 Subject: [PATCH] refactor: update field name and tests --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 8 +++----- src/app.rs | 41 +++++++++-------------------------------- src/main.rs | 8 -------- test/test.txt | 3 +-- 6 files changed, 15 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 567591b..715f17c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1400,7 +1400,7 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "xgt" -version = "0.3.0" +version = "0.4.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index ea00ad9..626fc2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xgt" -version = "0.3.0" +version = "0.4.0" edition = "2021" authors = ["Anicet Ebou "] description = "xgt enables efficient querying and parsing of GTDB data" diff --git a/README.md b/README.md index 75042f7..052aaa2 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ xgt -h ``` # Search subcommand: search GTDB ## Search all Escherichia (genus) genomes -xgt search Escherichia +xgt search g__Escherichia -## Search all genomes with genus name containing escherichia -xgt search --partial escherichia +## Search all genomes with genus name containing Escherichia +xgt search --partial g__Escherichia -o output.json ## Search from a list xgt search -f list.txt @@ -63,8 +63,6 @@ Full help is available from `xgt --help`. To tell `xgt` to _not_ verify the peer, use the `-k/--insecure` option. Currently (as of Apr 28, 2024), you should add this option to your command to get the desired result as GTDB API's server has a certificate issue. - - ## Minimum supported Rust version `xgt` minimum [Rust](https://www.rust-lang.org/) version is 1.70.0. diff --git a/src/app.rs b/src/app.rs index 3a573fe..3423a8b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -21,41 +21,30 @@ pub fn build_app() -> Command { .short('c') .long("count") .action(ArgAction::SetTrue) - .help("Count the number of genomes"), + .help("count the number of genomes"), ) .arg( Arg::new("id") .short('i') .long("id") .action(ArgAction::SetTrue) - .help("Print only genome ID"), + .help("only print genome id"), ) .arg( Arg::new("field") .short('F') .long("field") .value_name("STR") - .default_value("gtdb_tax") - .value_parser(["all", "gtdb_tax", "ncbi_tax", "ncbi_org", "ncbi_id"]) - .help("Search field"), + .default_value("gtdb") + .value_parser(["gtdb", "ncbi"]) + .help("which taxonomy to search"), ) .arg( Arg::new("file") .short('f') .long("file") .value_name("FILE") - .help("Search from name in FILE"), - ) - .arg( - Arg::new("level") - .short('l') - .long("level") - .value_name("STR") - .help("Taxon level to search") - .default_value("genus") - .value_parser([ - "species", "genus", "family", "order", "class", "phylum", "domain", - ]), + .help("search from name in FILE"), ) .arg( Arg::new("out") @@ -267,9 +256,7 @@ mod tests { fn test_app() { std::env::set_var("NO_COLOR", "true"); let app = build_app(); - let args = vec![ - "xgt", "search", "p__taxon", "-l", "class", "--count", "--raw", - ]; + let args = vec!["xgt", "search", "p__taxon", "--count", "--raw"]; let matches = app.get_matches_from(args); assert_eq!(matches.subcommand_name(), Some("search")); let submatches = matches.subcommand_matches("search").unwrap(); @@ -277,10 +264,6 @@ mod tests { submatches.get_one::("name"), Some(&"p__taxon".to_owned()) ); - assert_eq!( - submatches.get_one::("level"), - Some(&"class".to_owned()) - ); assert!(submatches.get_flag("count")); assert!(submatches.get_flag("raw")); } @@ -291,8 +274,6 @@ mod tests { "xgt", "search", "p__taxon", - "-l", - "class", "--count", "--raw", "--id", @@ -300,7 +281,7 @@ mod tests { "--rep", "--type", "--field", - "ncbi_tax", + "ncbi", ]); let subcommand_parser = arg_parser.subcommand_matches("search").unwrap(); assert!(subcommand_parser.get_flag("count")); @@ -313,13 +294,9 @@ mod tests { subcommand_parser.get_one::("name"), Some(&"p__taxon".to_owned()) ); - assert_eq!( - subcommand_parser.get_one::("level"), - Some(&"class".to_owned()) - ); assert_eq!( subcommand_parser.get_one::("field"), - Some(&"ncbi_tax".to_owned()) + Some(&"ncbi".to_owned()) ); } diff --git a/src/main.rs b/src/main.rs index fffac26..efbca7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,6 @@ fn handle_taxon_command(sub_matches: &clap::ArgMatches) -> Result<()> { Ok(()) } -/* #[cfg(test)] mod tests { use super::*; @@ -60,8 +59,6 @@ mod tests { #[test] fn test_search_command() { - let needle = vec!["Aminobacter".to_string(), "Rhizobium".to_string()]; - let level = "phylum".to_string(); let id = true; let count = true; let raw = true; @@ -73,8 +70,6 @@ mod tests { OsString::from("search"), OsString::from("--file"), OsString::from("test/test.txt"), - OsString::from("--level"), - OsString::from(level.clone()), OsString::from("--id"), OsString::from("--partial"), OsString::from("--count"), @@ -88,8 +83,6 @@ mod tests { let args = utils::SearchArgs::from_arg_matches(matches.subcommand_matches("search").unwrap()); - assert_eq!(args.get_needle(), needle); - assert_eq!(args.get_level(), level); assert_eq!(args.get_gid(), id); assert_eq!(args.get_count(), count); assert_eq!(args.get_raw(), raw); @@ -115,4 +108,3 @@ mod tests { assert_eq!(args.output, Some(String::from("met.json"))); } } -*/ diff --git a/test/test.txt b/test/test.txt index 4f1791b..e1fa023 100644 --- a/test/test.txt +++ b/test/test.txt @@ -1,2 +1 @@ -Aminobacter -Rhizobium +g__Aminobacter