| 1 |
#include <pbcopper/cli2/internal/MultiToolInterfaceHelpPrinter.h> |
| 2 |
|
| 3 |
#include <sstream> |
| 4 |
#include <string> |
| 5 |
#include <vector> |
| 6 |
|
| 7 |
#include <gtest/gtest.h> |
| 8 |
|
| 9 |
#include <pbcopper/cli2/Interface.h> |
| 10 |
#include <pbcopper/cli2/MultiToolInterface.h> |
| 11 |
#include <pbcopper/cli2/internal/InterfaceHelpPrinter.h> |
| 12 |
|
| 13 |
#include "../../../src/cli2/PbBoilerplateDisclaimer.h" |
| 14 |
#include "pbcopper/cli2/Tool.h" |
| 15 |
|
| 16 |
using HiddenOptionMode = PacBio::CLI_v2::internal::HiddenOptionMode; |
| 17 |
using Interface = PacBio::CLI_v2::Interface; |
| 18 |
using MultiToolInterface = PacBio::CLI_v2::MultiToolInterface; |
| 19 |
using MultiToolInterfaceHelpPrinter = PacBio::CLI_v2::internal::MultiToolInterfaceHelpPrinter; |
| 20 |
using ToolVisibility = PacBio::CLI_v2::ToolVisibility; |
| 21 |
|
| 22 |
// clang-format off |
| 23 |
|
| 24 |
namespace CLI_v2_MultiToolInterfaceHelpPrinterTests { |
| 25 |
|
| 26 |
Interface MakeRefineInterface() |
| 27 |
{ |
| 28 |
Interface refine{"refine", "Remove concatemers and optionally poly-A tails (FL to FLNC)"}; |
| 29 |
refine.Example("isoseq3 refine movie.consensusreadset.xml primers.barcodeset.xml movie.flnc.bam"); |
| 30 |
return refine; |
| 31 |
} |
| 32 |
|
| 33 |
int RefineRunner(const PacBio::CLI_v2::Results&) |
| 34 |
{ |
| 35 |
return EXIT_SUCCESS; |
| 36 |
} |
| 37 |
|
| 38 |
Interface MakeClusterInterface() |
| 39 |
{ |
| 40 |
Interface cluster{"cluster", "Cluster FLNC reads and generate unpolished transcripts (FLNC to UNPOLISHED"}; |
| 41 |
cluster.Example("isoseq3 cluster movie.flnc.bam unpolished.bam"); |
| 42 |
return cluster; |
| 43 |
} |
| 44 |
|
| 45 |
int ClusterRunner(const PacBio::CLI_v2::Results&) |
| 46 |
{ |
| 47 |
return EXIT_SUCCESS; |
| 48 |
} |
| 49 |
|
| 50 |
Interface MakePolishInterface() |
| 51 |
{ |
| 52 |
Interface polish{"polish", "Polish transcripts using subreads (UNPOLISHED to POLISHED)"}; |
| 53 |
polish.Example("isoseq3 polish unpolished.bam movie.subreadset.xml polished.bam"); |
| 54 |
return polish; |
| 55 |
} |
| 56 |
|
| 57 |
int PolishRunner(const PacBio::CLI_v2::Results&) |
| 58 |
{ |
| 59 |
return EXIT_SUCCESS; |
| 60 |
} |
| 61 |
|
| 62 |
Interface MakeSummarizeInterface() |
| 63 |
{ |
| 64 |
Interface summarize{"summarize", "Create barcode overview from transcripts (POLISHED to CSV)"}; |
| 65 |
summarize.Example("isoseq3 summarize polished.bam summary.csv"); |
| 66 |
return summarize; |
| 67 |
} |
| 68 |
|
| 69 |
int SummarizeRunner(const PacBio::CLI_v2::Results&) |
| 70 |
{ |
| 71 |
return EXIT_SUCCESS; |
| 72 |
} |
| 73 |
|
| 74 |
} // namespace CLI_v2_MultiToolInterfaceHelpPrinterTests |
| 75 |
|
| 76 |
TEST(CLI2_MultiToolInterfaceHelpPrinter, can_print_top_level_help) |
| 77 |
{ |
| 78 |
using namespace CLI_v2_MultiToolInterfaceHelpPrinterTests; |
| 79 |
|
| 80 |
const std::string expectedText{R"(isoseq3 - De Novo Transcript Reconstruction |
| 81 |
|
| 82 |
Usage: |
| 83 |
isoseq3 <tool> |
| 84 |
|
| 85 |
-h,--help Show this help and exit. |
| 86 |
--version Show application version and exit. |
| 87 |
|
| 88 |
Tools: |
| 89 |
refine7890123 Remove concatemers and optionally poly-A tails (FL to FLNC) |
| 90 |
cluster Cluster FLNC reads and generate unpolished transcripts (FLNC to UNPOLISHED |
| 91 |
polish Polish transcripts using subreads (UNPOLISHED to POLISHED) |
| 92 |
summarize Create barcode overview from transcripts (POLISHED to CSV) |
| 93 |
|
| 94 |
Examples: |
| 95 |
isoseq3 refine movie.consensusreadset.xml primers.barcodeset.xml movie.flnc.bam |
| 96 |
isoseq3 cluster movie.flnc.bam unpolished.bam |
| 97 |
isoseq3 polish unpolished.bam movie.subreadset.xml polished.bam |
| 98 |
isoseq3 summarize polished.bam summary.csv |
| 99 |
|
| 100 |
Typical workflow: |
| 101 |
1. Generate consensus sequences from your raw subread data |
| 102 |
$ ccs movie.subreads.bam movie.ccs.bam --noPolish --minPasses 1 |
| 103 |
|
| 104 |
2. Generate full-length reads by primer removal and demultiplexing |
| 105 |
$ cat primers.fasta |
| 106 |
>primer_5p |
| 107 |
AAGCAGTGGTATCAACGCAGAGTACATGGGG |
| 108 |
>primer_3p |
| 109 |
AAGCAGTGGTATCAACGCAGAGTAC |
| 110 |
$ lima movie.ccs.bam primers.fasta movie.fl.bam --isoseq --no-pbi |
| 111 |
|
| 112 |
3. Remove noise from FL reads |
| 113 |
$ isoseq3 refine movie.fl.P5--P3.bam primers.fasta movie.flnc.bam |
| 114 |
|
| 115 |
4. Cluster consensus sequences to generate unpolished transcripts |
| 116 |
$ isoseq3 cluster movie.flnc.bam unpolished.bam --verbose |
| 117 |
|
| 118 |
5. Polish transcripts using subreads |
| 119 |
$ isoseq3 polish unpolished.bam movie.subreads.bam polished.bam |
| 120 |
|
| 121 |
)" |
| 122 |
PB_BOILERPLATE_DISCLAIMER |
| 123 |
}; |
| 124 |
|
| 125 |
MultiToolInterface i{"isoseq3", "De Novo Transcript Reconstruction", "3.1.2"}; |
| 126 |
i.AddTools({{"refine7890123", MakeRefineInterface(), &RefineRunner}, |
| 127 |
{"cluster", MakeClusterInterface(), &ClusterRunner}, |
| 128 |
{"polish", MakePolishInterface(), &PolishRunner}, |
| 129 |
{"summarize", MakeSummarizeInterface(), &SummarizeRunner}}); |
| 130 |
|
| 131 |
i.HelpFooter(R"(Typical workflow: |
| 132 |
1. Generate consensus sequences from your raw subread data |
| 133 |
$ ccs movie.subreads.bam movie.ccs.bam --noPolish --minPasses 1 |
| 134 |
|
| 135 |
2. Generate full-length reads by primer removal and demultiplexing |
| 136 |
$ cat primers.fasta |
| 137 |
>primer_5p |
| 138 |
AAGCAGTGGTATCAACGCAGAGTACATGGGG |
| 139 |
>primer_3p |
| 140 |
AAGCAGTGGTATCAACGCAGAGTAC |
| 141 |
$ lima movie.ccs.bam primers.fasta movie.fl.bam --isoseq --no-pbi |
| 142 |
|
| 143 |
3. Remove noise from FL reads |
| 144 |
$ isoseq3 refine movie.fl.P5--P3.bam primers.fasta movie.flnc.bam |
| 145 |
|
| 146 |
4. Cluster consensus sequences to generate unpolished transcripts |
| 147 |
$ isoseq3 cluster movie.flnc.bam unpolished.bam --verbose |
| 148 |
|
| 149 |
5. Polish transcripts using subreads |
| 150 |
$ isoseq3 polish unpolished.bam movie.subreads.bam polished.bam)"); |
| 151 |
|
| 152 |
MultiToolInterfaceHelpPrinter help{i, 80, HiddenOptionMode::HIDE}; |
| 153 |
std::ostringstream out; |
| 154 |
help.Print(out); |
| 155 |
EXPECT_EQ(expectedText, out.str()); |
| 156 |
|
| 157 |
out.str(""); |
| 158 |
out << help; |
| 159 |
EXPECT_EQ(expectedText, out.str()); |
| 160 |
} |
| 161 |
|
| 162 |
TEST(CLI2_MultiToolInterfaceHelpPrinter, can_handle_hidden_tools) |
| 163 |
{ |
| 164 |
using namespace CLI_v2_MultiToolInterfaceHelpPrinterTests; |
| 165 |
|
| 166 |
MultiToolInterface i{"isoseq3", "De Novo Transcript Reconstruction", "3.1.2"}; |
| 167 |
i.AddTools({{"refine", MakeRefineInterface(), &RefineRunner, ToolVisibility::HIDDEN}, |
| 168 |
{"cluster", MakeClusterInterface(), &ClusterRunner}, |
| 169 |
{"polish", MakePolishInterface(), &PolishRunner}, |
| 170 |
{"summarize", MakeSummarizeInterface(), &SummarizeRunner}}); |
| 171 |
|
| 172 |
// ensure hidden |
| 173 |
{ |
| 174 |
MultiToolInterfaceHelpPrinter help{i, HiddenOptionMode::HIDE}; |
| 175 |
std::ostringstream out; |
| 176 |
help.Print(out); |
| 177 |
EXPECT_EQ(std::string::npos, out.str().find("refine")); |
| 178 |
} |
| 179 |
|
| 180 |
// expose via --show-all-help |
| 181 |
{ |
| 182 |
MultiToolInterfaceHelpPrinter help{i, HiddenOptionMode::SHOW}; |
| 183 |
std::ostringstream out; |
| 184 |
help.Print(out); |
| 185 |
EXPECT_NE(std::string::npos, out.str().find("refine")); |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
// clang-format on |