1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use clap::{Command, CommandFactory, Parser, Subcommand};

#[derive(Parser, Debug)]
#[clap(
    author,
    version,
    about,
    propagate_version = true,
    subcommand_required = true,
    infer_subcommands = true,
    arg_required_else_help = true,
    help_expected = true
)]
pub struct Cli {
    /// Threads for decompression
    #[clap(
        global = true,
        short,
        long,
        default_value_t = 8,
        help_heading = "GLOBAL-OPTIONS"
    )]
    pub threads: usize,
    /// Logging level [-v: Info, -vv: Debug, -vvv: Trace]
    #[clap(
        global = true,
        short,
        long,
        action = clap::ArgAction::Count,
        help_heading = "DEBUG-OPTIONS"
    )]
    pub verbose: u8,
    /// Turn of all logging
    #[clap(global = true, long, help_heading = "DEBUG-OPTIONS")]
    pub quiet: bool,
    /// Subcommands for fibertools-rs
    #[clap(subcommand)]
    pub command: Option<Commands>,
}

///
/// This structure contains all the subcommands for fiberseq-rs and their help descriptions.
///
#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Extract fiberseq data into plain text files
    #[clap(visible_aliases = &["ex", "e"])]
    Extract {
        /// Fiberseq bam file
        #[clap(default_value = "-")]
        bam: String,
        /// Report in reference sequence coordinates
        #[clap(short, long)]
        reference: bool,
        /// Minium score in the ML tag to include in the output
        #[clap(short, long, default_value = "150")]
        min_ml_score: u8,
        /// Output path for m6a bed12
        #[clap(long)]
        m6a: Option<String>,
        /// Output path for 5mC (CpG, primrose) bed12
        #[clap(short, long)]
        cpg: Option<String>,
        /// Output path for methylation sensitive patch (msp) bed12
        #[clap(long)]
        msp: Option<String>,
        /// Output path for nucleosome bed12
        #[clap(short, long)]
        nuc: Option<String>,
        /// Output path for a tabular format including "all" fiberseq information in the bam
        #[clap(short, long)]
        all: Option<String>,
        /// Include per base quality scores in "fiber_qual"
        #[clap(short, long, help_heading = "ALL-FORMATTING-OPTIONS")]
        quality: bool,
        /// Add the full floating point predictions of the ML model
        #[clap(short, long, help_heading = "ALL-FORMATTING-OPTIONS")]
        full_float: bool,
        /// Simplify output by remove fiber sequence
        #[clap(short, long, help_heading = "ALL-FORMATTING-OPTIONS")]
        simplify: bool,
    },
    /// This command centers fiberseq data around given reference positions. This is useful for making aggregate m6a and CpG observations, as well as visualization of SVs
    #[clap(visible_aliases = &["c", "ct"])]
    Center {
        /// Fiberseq bam file, must be aligned and have an index
        bam: String,
        /// Bed file on which to center fiberseq reads. Data is adjusted to the start position of the bed file and corrected for strand if a 4th strand column is included
        ///
        /// If you include strand information in the 4th column it will orient data accordingly and use the end position of bed record instead of the start if on the minus strand. This means that profiles of motifs in both the forward and minus orientation will align to the same central position.
        bed: String,
        /// Minium score in the ML tag to include in the output
        #[clap(short, long, default_value = "150")]
        min_ml_score: u8,
        /// Provide data in wide format, one row per read
        #[clap(short, long)]
        wide: bool,
    },
    /// Predict m6A positions using HiFi kinetics data and encode the results in the MM and ML bam tags
    #[clap(visible_aliases = &["m6A", "m6a"])]
    PredictM6A {
        /// Bam HiFi file with kinetics
        #[clap(default_value = "-")]
        bam: String,
        /// Output bam file with m6A calls in new/extended MM and ML bam tags
        #[clap(default_value = "-")]
        out: String,
        /// Keep hifi kinetics data
        #[clap(short, long)]
        keep: bool,
        /// Use CNN model for prediction instead of XGBoost
        #[clap(short, long)]
        cnn: bool,
        /// Add a bam tag (mp) with the full floating point predictions of the ML model
        #[clap(short, long)]
        full_float: bool,
    },
}

pub fn make_cli_parse() -> Cli {
    Cli::parse()
}

pub fn make_cli_app() -> Command {
    Cli::command()
}