19 fprintf(stderr,
"arb_2_bin - ARB database ascii to binary converter\n");
21 if (argc <= 1 || strcmp(argv[1],
"--help") == 0) {
24 "Purpose: Converts a database to binary format\n"
25 "Syntax: arb_2_bin [Options] database [newdatabase]\n"
26 "Options: -m create map file too\n"
27 " -r try to repair destroyed database\n"
28 " -c[tree_xxx] optimize database using tree_xxx or largest tree\n"
29 " -C<type> use extra compression\n"
30 " (known <type>s: %s)\n"
31 " -e <treefile> optimize the database using the tree from the\n"
32 " file. The tree is not stored in the database.\n"
34 "database my be '-' in which case arb_2_bin reads from stdin.\n"
38 if (argc>1 && strcmp(argv[1],
"--help") != 0) { error =
"Missing arguments"; }
46 const char *opt_tree =
NULp;
47 const char *ext_tree =
NULp;
59 while (argv[ci] && argv[ci][0] ==
'-' && argv[ci][1] != 0 && !error) {
60 if (!strcmp(argv[ci],
"-m")) { ci++; *(wtypep++) =
'm'; }
61 else if (!strcmp(argv[ci],
"-r")) { ci++; *(rtypep++) =
'R'; }
62 else if (!strncmp(argv[ci],
"-c", 2)) { opt_tree = argv[ci]+2; ci++; }
63 else if (!strncmp(argv[ci],
"-i", 2)) { nidx = atoi(argv[ci]+2); ci++; }
64 else if (!strncmp(argv[ci],
"-C", 2)) {
65 char cflag = argv[ci][2]; ci++;
73 else if (!strcmp(argv[ci],
"-e")) { ci++; ext_tree = argv[ci]; ci++; }
81 const char *in = argv[ci++];
82 const char *out = ci >= argc ? in : argv[ci++];
84 if (!error && !in) error =
"missing arguments";
87 printf(
"Reading database...\n");
97 printf(
"Reading tree from '%s' ..\n", ext_tree);
103 printf(
"Warning from TREE_load: %s\n", warnings);
106 opt_tree =
"tree_zzzz_comp_opt_tree_zzzz";
108 if (tree->
is_leaf()) error =
"Cannot load tree (need at least 2 leafs)";
118 if (!error && opt_tree) {
124 if (!strlen(opt_tree)) opt_tree =
NULp;
126 printf(
"Optimizing database...\n");
133 if (!error && ext_tree) {
134 printf(
"Deleting compression tree from database...\n");
137 if (!error) error =
GB_delete(gb_comp_tree);
138 if (error) error =
GBS_global_string(
"Failed to delete optimization tree: %s", error);
144 printf(
"Saving database...\n");
145 error =
GB_save(gb_main, out, wtype);
153 fprintf(stderr,
"arb_2_bin: Error: %s\n", error);
GB_ERROR GB_begin_transaction(GBDATA *gbd)
GB_ERROR GB_save(GBDATA *gb, const char *path, const char *savetype)
void GB_set_next_main_idx(long idx)
int ARB_main(int argc, char *argv[])
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
const char * GBS_global_string(const char *templat,...)
GBDATA * GBT_open(const char *path, const char *opent)
GB_ERROR GB_delete(GBDATA *&source)
GB_ERROR GB_await_error()
GB_ERROR GBT_write_tree(GBDATA *gb_main, const char *tree_name, TreeNode *tree)
static void error(const char *msg)
TreeNode * TREE_load(const char *path, TreeRoot *troot, char **commentPtr, bool allow_length_scaling, char **warningPtr)
static list< LineAttachedMessage > warnings
GB_ERROR GBT_compress_sequence_tree2(GBDATA *gbd, const char *tree_name, const char *ali_name) __ATTR__USERESULT
char * GBT_get_default_alignment(GBDATA *gb_main)
GBDATA * GBT_find_tree(GBDATA *gb_main, const char *tree_name)
const char * GB_get_supported_compression_flags(bool verboose)
void GB_close(GBDATA *gbd)