Skip to content

Commit

Permalink
add alignment validation command which also removes gap-only sites (-…
Browse files Browse the repository at this point in the history
…-check)
  • Loading branch information
amkozlov committed Nov 28, 2017
1 parent 4f49925 commit 04b7f61
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/CommandLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static struct option long_options[] =
{"support", no_argument, 0, 0 }, /* 30 */
{"terrace", no_argument, 0, 0 }, /* 31 */
{"terrace-maxsize", required_argument, 0, 0 }, /* 32 */
{"check", no_argument, 0, 0 }, /* 33 */

{ 0, 0, 0, 0 }
};
Expand Down Expand Up @@ -402,6 +403,10 @@ void CommandLineParser::parse_options(int argc, char** argv, Options &opts)
+ string(optarg) + ", please provide a positive integer number!");
}
break;
case 33: /* check */
opts.command = Command::check;
num_commands++;
break;
default:
throw OptionException("Internal error in option parsing");
}
Expand All @@ -417,11 +422,16 @@ void CommandLineParser::parse_options(int argc, char** argv, Options &opts)
/* check for mandatory options for each command */
if (opts.command == Command::evaluate || opts.command == Command::search ||
opts.command == Command::bootstrap || opts.command == Command::all ||
opts.command == Command::terrace)
opts.command == Command::terrace || opts.command == Command::check)
{
if (opts.msa_file.empty())
throw OptionException("You must specify a multiple alignment file with --msa switch");
}

if (opts.command == Command::evaluate || opts.command == Command::search ||
opts.command == Command::bootstrap || opts.command == Command::all ||
opts.command == Command::terrace)
{
if (opts.model_file.empty())
throw OptionException("You must specify an evolutionary model with --model switch");
}
Expand Down Expand Up @@ -495,15 +505,16 @@ void CommandLineParser::print_help()

cout << "\n"
"Commands (mutually exclusive):\n"
" --help display help information.\n"
" --version display version information.\n"
" --evaluate evaluate the likelihood of a tree.\n"
" --help display help information\n"
" --version display version information\n"
" --evaluate evaluate the likelihood of a tree\n"
" --search ML tree search.\n"
" --bootstrap bootstrapping.\n"
" --bootstrap bootstrapping\n"
" --all all-in-one (ML search + bootstrapping).\n"
" --support compute bipartition support for a given reference tree (e.g., best ML tree)\n"
" and a set of replicate trees (e.g., from a bootstrap analysis) \n"
" and a set of replicate trees (e.g., from a bootstrap analysis)\n"
" --terrace check whether tree lies on a phylogenetic terrace \n"
" --check check alignment correctness and remove empty columns/rows\n"
"\n"
"Input and output options:\n"
" --tree FILE | rand{N} | pars{N} starting tree: rand(om), pars(imony) or user-specified (newick file)\n"
Expand Down
6 changes: 6 additions & 0 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ std::ostream& operator<<(std::ostream& stream, const Options& opts)
case Command::support:
stream << "Compute bipartition support";
break;
case Command::terrace:
stream << "Count/enumerate trees on a phylogenetic terrace";
break;
case Command::check:
stream << "Alignment validation";
break;
default:
break;
}
Expand Down
22 changes: 22 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,16 @@ void load_msa(RaxmlInstance& instance)

/* check alignment */
if (!opts.force_mode)
{
LOG_VERB_TS << "Validating alignment... " << endl;
check_msa(instance);
}

if (opts.use_pattern_compression)
{
LOG_VERB_TS << "Compressing alignment patterns... " << endl;
parted_msa.compress_patterns();
}

// if (parted_msa.part_count() > 1)
// instance.terrace_wrapper.reset(new TerraceWrapper(parted_msa));
Expand Down Expand Up @@ -1172,6 +1178,22 @@ int main(int argc, char** argv)
check_terrace(instance, tree);
break;
}
case Command::check:
{
instance.opts.use_pattern_compression = false;
init_part_info(instance);
load_msa(instance);
if (instance.opts.start_tree == StartingTree::user)
{
LOG_INFO << "Loading tree from: " << instance.opts.tree_file << endl << endl;
if (!sysutil_file_exists(instance.opts.tree_file))
throw runtime_error("File not found: " + instance.opts.tree_file);
instance.start_tree_stream.reset(new NewickStream(instance.opts.tree_file, std::ios::in));
Tree tree = generate_tree(instance, instance.opts.start_tree);
}
LOG_INFO << "Alignment can be successfully read by RAxML-NG." << endl << endl;
break;
}
case Command::none:
default:
LOG_ERROR << "Unknown command!" << endl;
Expand Down
3 changes: 2 additions & 1 deletion src/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum class Command
bootstrap,
all,
support,
terrace
terrace,
check
};

enum class FileFormat
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define RAXML_VERSION "0.5.1 BETA"
#define RAXML_DATE "27.10.2017"
#define RAXML_DATE "28.11.2017"

0 comments on commit 04b7f61

Please sign in to comment.