Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add verbose option #157

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/iGenVar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "variant_detection/method_enums.hpp" // for enum detection_methods, clustering_methods and refinement_methods

inline bool gVerbose{false};

struct cmd_arguments
{
// Input:
Expand All @@ -16,7 +18,7 @@ struct cmd_arguments
/* -b */ std::filesystem::path clusters_file_path{};
// Others:
/* -h - help - not part of the args struct */
/* -v - verbose - not implementet yet */
/* -v - verbose - global variable gVerbose */
/* -t */ int16_t threads = 1;
// Methods:
/* -d */ std::vector<detection_methods> methods{cigar_string, split_read, read_pairs, read_depth}; // default: all
Expand Down
3 changes: 3 additions & 0 deletions src/iGenVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ void initialize_argument_parser(seqan3::argument_parser & parser, cmd_arguments
parser.add_option(args.threads, 't', "threads",
"Specify the number of decompression threads used for reading BAM files.",
seqan3::option_spec::standard);
parser.add_flag(gVerbose, 'v', "verbose",
"If you set this flag, we provide additional details about what iGenVar does. The detailed output "
"is printed in the standard error.");

// Options - Optional output:
parser.add_option(args.junctions_file_path, 'a', "junctions",
Expand Down
22 changes: 13 additions & 9 deletions src/modules/clustering/hierarchical_clustering_method.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "iGenVar.hpp" // for global variable gVerbose
#include "modules/clustering/hierarchical_clustering_method.hpp"

#include <limits> // for infinity
Expand Down Expand Up @@ -134,15 +135,18 @@ std::vector<Cluster> hierarchical_clustering_method(std::vector<Junction> const
}
if (partition_size > max_partition_size)
{
seqan3::debug_stream << "A partition exceeds the maximum size ("
<< partition_size
<< ">"
<< max_partition_size
<< ") and has to be subsampled. Representative partition member:\n["
<< partition[0].get_mate1()
<< "] -> ["
<< partition[0].get_mate2()
<< "]\n";
if (gVerbose)
{
seqan3::debug_stream << "A partition exceeds the maximum size ("
<< partition_size
<< ">"
<< max_partition_size
<< ") and has to be subsampled. Representative partition member:\n["
<< partition[0].get_mate1()
<< "] -> ["
<< partition[0].get_mate2()
<< "]\n";
}
partition = subsample_partition(partition, max_partition_size);
partition_size = max_partition_size;
}
Expand Down
7 changes: 5 additions & 2 deletions src/modules/sv_detection_methods/analyze_cigar_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/sequence_file/output.hpp>

#include "iGenVar.hpp" // for global variable gVerbose
#include "structures/breakend.hpp" // for class Breakend
#include "structures/junction.hpp" // for class Junction

Expand Down Expand Up @@ -43,7 +44,8 @@ void analyze_cigar(std::string const & read_name,
inserted_bases,
tandem_dup_count,
read_name};
seqan3::debug_stream << "INS: " << new_junction << "\n";
if (gVerbose)
seqan3::debug_stream << "INS: " << new_junction << "\n";
junctions.push_back(std::move(new_junction));
}
pos_read += length;
Expand All @@ -58,7 +60,8 @@ void analyze_cigar(std::string const & read_name,
""_dna5,
tandem_dup_count,
read_name};
seqan3::debug_stream << "DEL: " << new_junction << "\n";
if (gVerbose)
seqan3::debug_stream << "DEL: " << new_junction << "\n";
junctions.push_back(std::move(new_junction));
}
pos_ref += length;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "iGenVar.hpp" // for global variable gVerbose
#include "modules/sv_detection_methods/analyze_split_read_method.hpp"

#include <seqan3/core/debug_stream.hpp>
Expand Down Expand Up @@ -119,7 +120,8 @@ void analyze_aligned_segments(std::vector<AlignedSegment> const & aligned_segmen
next.get_query_start());
junctions.emplace_back(mate1, mate2, inserted_bases, tandem_dup_count, read_name);
}
seqan3::debug_stream << "BND: " << junctions.back() << "\n";
if (gVerbose)
seqan3::debug_stream << "BND: " << junctions.back() << "\n";
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/api/clustering_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include "iGenVar.hpp" // for global variable gVerbose
#include "modules/clustering/simple_clustering_method.hpp" // for the simple clustering method
#include "modules/clustering/hierarchical_clustering_method.hpp" // for the hierarchical clustering method
#include "structures/cluster.hpp" // for class Cluster
Expand Down Expand Up @@ -448,6 +449,8 @@ TEST(hierarchical_clustering, clustering_25)

TEST(hierarchical_clustering, subsampling)
{
gVerbose = true;

std::vector<Junction> input_junctions;
for (int32_t i = 0; i < 300; ++i)
{
Expand Down
35 changes: 18 additions & 17 deletions test/cli/iGenVar_cli_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ std::string const help_page_part_1
" -t, --threads (signed 16 bit integer)\n"
" Specify the number of decompression threads used for reading BAM\n"
" files. Default: 1.\n"
" -v, --verbose\n"
" If you set this flag, we provide additional details about what\n"
" iGenVar does. The detailed output is printed in the standard error.\n"
};

std::string const help_page_part_2
Expand Down Expand Up @@ -162,10 +165,6 @@ std::string expected_res_empty
std::string expected_err_default_no_err
{
"Detect junctions in long reads...\n"
"INS: chr21\t41972615\tForward\tchr21\t41972616\tForward\t1681\t0\tm2257/8161/CCS\n"
"BND: chr21\t41972615\tReverse\tchr22\t17458415\tReverse\t2\t0\tm41327/11677/CCS\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm21263/13017/CCS\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm38637/7161/CCS\n"
"Start clustering...\n"
"Done with clustering. Found 2 junction clusters.\n"
"No refinement was selected.\n"
Expand All @@ -188,14 +187,23 @@ TEST_F(iGenVar_cli_test, no_options)
// TODO (irallia): There is an open Issue, if we want to add the verbose option https://github.com/seqan/iGenVar/issues/20
TEST_F(iGenVar_cli_test, test_verbose_option)
{
cli_test_result result = execute_app("iGenVar", "-v");
cli_test_result result = execute_app("iGenVar", "-j", data(default_alignment_long_reads_file_path), "--verbose");
std::string expected_err
{
"[Error] Unknown option -v. In case this is meant to be a non-option/argument/parameter, please specify "
"the start of non-options with '--'. See -h/--help for program information.\n"
"Detect junctions in long reads...\n"
"INS: chr21\t41972615\tForward\tchr21\t41972616\tForward\t1681\t0\tm2257/8161/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"BND: chr21\t41972615\tReverse\tchr22\t17458415\tReverse\t2\t0\tm41327/11677/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm21263/13017/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm38637/7161/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"Start clustering...\n"
"Done with clustering. Found 2 junction clusters.\nNo refinement was selected.\n"
};
EXPECT_EQ(result.exit_code, 65280);
EXPECT_EQ(result.out, std::string{});
EXPECT_EQ(result.exit_code, 0);
EXPECT_EQ(result.out, expected_res_default);
EXPECT_EQ(result.err, expected_err);
}

Expand Down Expand Up @@ -351,13 +359,9 @@ TEST_F(iGenVar_cli_test, with_default_arguments)
std::string expected_err
{
"Detect junctions in long reads...\n"
"INS: chr21\t41972615\tForward\tchr21\t41972616\tForward\t1681\t0\tm2257/8161/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"BND: chr21\t41972615\tReverse\tchr22\t17458415\tReverse\t2\t0\tm41327/11677/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm21263/13017/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm38637/7161/CCS\n"
"The read depth method for long reads is not yet implemented.\n"
"Start clustering...\n"
"Done with clustering. Found 2 junction clusters.\n"
Expand Down Expand Up @@ -442,10 +446,6 @@ TEST_F(iGenVar_cli_test, test_direct_methods_input)
std::string expected_err
{
"Detect junctions in long reads...\n"
"INS: chr21\t41972615\tForward\tchr21\t41972616\tForward\t1681\t0\tm2257/8161/CCS\n"
"BND: chr21\t41972615\tReverse\tchr22\t17458415\tReverse\t2\t0\tm41327/11677/CCS\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm21263/13017/CCS\n"
"BND: chr21\t41972616\tReverse\tchr22\t17458416\tReverse\t0\t0\tm38637/7161/CCS\n"
"Start clustering...\n"
"Done with clustering. Found 3 junction clusters.\n"
"No refinement was selected.\n"
Expand Down Expand Up @@ -534,6 +534,7 @@ TEST_F(iGenVar_cli_test, dataset_single_end_mini_example)
{
cli_test_result result = execute_app("iGenVar",
"-j", data("single_end_mini_example.sam"),
"--verbose",
"--method cigar_string --method split_read "
"--min_var_length 8 --max_var_length 400");

Expand Down