Skip to content

Commit

Permalink
Add easy parsable tsv output to databases
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Jul 20, 2022
1 parent ba4e11f commit 1c739ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/commons/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,7 @@ Parameters::Parameters():
databases.push_back(&PARAM_HELP);
databases.push_back(&PARAM_HELP_LONG);
databases.push_back(&PARAM_TSV);
databases.push_back(&PARAM_REUSELATEST);
databases.push_back(&PARAM_REMOVE_TMP_FILES);
databases.push_back(&PARAM_COMPRESSED);
Expand Down
22 changes: 21 additions & 1 deletion src/workflow/Databases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ std::string listDatabases(const Command &command, std::vector<DatabaseDownload>
return description;
}

std::string listDatabasesTsv(std::vector<DatabaseDownload> &downloads) {
std::string description;
description.reserve(1024);
for (size_t i = 0; i < downloads.size(); ++i) {
description.append(downloads[i].name);
description.append(1, '\t');
description.append(Parameters::getDbTypeName(downloads[i].dbType));
description.append(1, '\t');
description.append(downloads[i].hasTaxonomy ? "true" : "false");
description.append(1, '\t');
description.append(downloads[i].url);
description.append(1, '\n');
}
return description;
}

int databases(int argc, const char **argv, const Command &command) {
Parameters &par = Parameters::getInstance();
par.parseParameters(argc, argv, command, false, Parameters::PARSE_ALLOW_EMPTY, 0);
Expand All @@ -244,7 +260,11 @@ int databases(int argc, const char **argv, const Command &command) {
}
std::string description = listDatabases(command, usedDownloads, par.help);
if (par.filenames.size() == 0 || par.help) {
par.printUsageMessage(command, par.help ? MMseqsParameter::COMMAND_EXPERT : 0, description.c_str());
if (par.tsvOut) {
Debug(Debug::INFO) << listDatabasesTsv(usedDownloads);
} else {
par.printUsageMessage(command, par.help ? MMseqsParameter::COMMAND_EXPERT : 0, description.c_str());
}
EXIT(EXIT_SUCCESS);
}

Expand Down

0 comments on commit 1c739ae

Please sign in to comment.