Skip to content

Commit

Permalink
pretty examples
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed Jan 21, 2025
1 parent acce174 commit dee32f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 46 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ edition = "2021"
clap = { version = "4.5.4", features = ["derive"] }
md5 = { version = "0.7.0" }
reqwest = { version = "0.12.9", features = ["blocking"] }
num_cpus = "1.16.0"
num_cpus = "1.16.0"
color-print = "0.3.7"
60 changes: 15 additions & 45 deletions src/util/arg_parser.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use color_print::cstr;
use crate::util::arg_parser::Commands::*;

#[derive(Parser)]
#[clap(disable_version_flag = true, arg_required_else_help = true)]
pub struct ClapArgs {
Expand Down Expand Up @@ -29,18 +31,21 @@ fn _threshold_in_range_f64(s: &str) -> Result<f64, String> {
}
}

// Extra help messages
const PROFILE_HELP: &str = cstr!(r#"<bold><underline>Example:</underline></bold>
# Define core genes above 85% coverage threshold
<bold>unicore profile -t 85 example/db/proteome_db example/out/clu.tsv result</bold>
"#);
const GENETREE_HELP: &str = cstr!(r#"<bold><underline>Example:</underline></bold>
# Create a list of hashed gene names
<bold>awk -F'\t' 'NR==FNR {a[$1];next} ($3 in a) {print $1}' /path/to/original/gene/names db/proteome_db.map > /path/to/hashed/gene/names</bold>
# Run gene-tree with the list of hashed gene names; use --realign option to recompute the alignment with custom --threshold option for MSA gap threshold
<bold>unicore gene-tree --realign --threshold 30 --name /path/to/hashed/gene/names example/tree</bold>
"#);
#[derive(Subcommand)]
pub enum Commands {
/// Create Foldseek database from amino acid sequences
#[clap(arg_required_else_help = true, allow_hyphen_values = true, verbatim_doc_comment)]
#[command(
after_help=
"
Example:
// Download ProstT5 weights as below if you haven't already
// foldseek databases ProstT5 /path/to/prostt5/weights tmp
unicore createdb example/data example/db/proteome_db example/model
")]
Createdb {
/// Input directory with fasta files or a single fasta file
input: PathBuf,
Expand Down Expand Up @@ -89,12 +94,6 @@ pub enum Commands {
},
/// Cluster Foldseek database
#[clap(arg_required_else_help = true, allow_hyphen_values = true)]
#[command(
after_help=
"
Example:
unicore cluster example/db/proteome_db example/out/clu tmp
")]
Cluster {
/// Input database (createdb output)
input: PathBuf,
Expand Down Expand Up @@ -141,13 +140,7 @@ pub enum Commands {
},
/// Create core structures from Foldseek database
#[clap(arg_required_else_help = true)]
#[command(
after_help=
"
Example:
// 85% coverage
unicore profile -t 85 example/db/proteome_db example/out/clu.tsv result
")]
#[command(after_help=PROFILE_HELP)]
Profile {
/// Input database (createdb output)
input_db: PathBuf,
Expand All @@ -170,12 +163,6 @@ pub enum Commands {
},
/// Infer phylogenetic tree from core structures
#[clap(arg_required_else_help = true, allow_hyphen_values = true)]
#[command(
after_help=
"
Example:
unicore tree example/db/proteome_db example/result example/tree
")]
Tree {
/// Input database (createdb output)
db: PathBuf,
Expand Down Expand Up @@ -207,18 +194,7 @@ pub enum Commands {
},
// Infer phylogenetic tree of each core structures
#[clap(arg_required_else_help = true, allow_hyphen_values = true)]
#[command(
after_help=
"
Examples:
unicore gene-tree example/tree
// Create a list of hashed gene names
awk -F'\t' 'NR==FNR {a[$1];next} ($3 in a) {print $1}' /path/to/original/gene/names db/proteome_db.map > /path/to/hashed/gene/names
// Run gene-tree with the list of hashed gene names
// Also optionally use --realign option to recompute the alignment and --threshold option to filter the MSA
unicore gene-tree --realign --threshold 30 --name /path/to/hashed/gene/names example/tree
")]
#[command(after_help=GENETREE_HELP)]
GeneTree {
/// Input directory containing species phylogenetic tree (Output of the Tree module)
input: PathBuf,
Expand Down Expand Up @@ -252,12 +228,6 @@ pub enum Commands {
},
/// Easy core gene phylogeny workflow, from fasta files to phylogenetic tree
#[clap(arg_required_else_help = true, allow_hyphen_values = true)]
#[command(
after_help=
"
Example:
unicore easy-core --use-foldseek --gpu example/data example/results example/model example/tmp
")]
EasyCore {
/// Input directory with fasta files or a single fasta file
input: PathBuf,
Expand Down

0 comments on commit dee32f2

Please sign in to comment.