33 double left_bs = node->
leftlen * 100.0;
34 double right_bs = node->
rightlen * 100.0;
36 #if defined(DEBUG) && 0
37 fprintf(stderr,
"node->leftlen = %f left_bs = %f\n", node->
leftlen, left_bs);
38 fprintf(stderr,
"node->rightlen = %f right_bs = %f\n", node->
rightlen, right_bs);
62 printf(
"arb_read_tree: %s\n", msg);
70 fputs(
"Usage: arb_read_tree [options] tree_name treefile [comment]\n"
71 "Available options:\n"
72 " -db database savename specify database and savename (default is 'running ARB')\n"
73 " -scale factor scale branchlengths by 'factor'\n"
74 " -consense numberOfTrees reinterpret branchlengths as consense values\n"
75 " -commentFromFile file read tree comment from 'file'\n"
108 #define SHIFT_ARGS(off) do { argc -= off; argv += off; } while (0)
109 #define SHIFT_NONSWITCHES(off) do { nonSwitches -= off; nonSwitch += off; } while (0)
114 const char *nonSwitch_buf[20];
115 const char **nonSwitch = nonSwitch_buf;
120 while (argc>0 && !error) {
121 if (strcmp(
"-scale", argv[0]) == 0) {
123 if (argc<2) error =
"-scale expects a 2nd argument (scale factor)";
125 scale_factor = atof(argv[1]);
129 else if (strcmp(
"-consense", argv[0]) == 0) {
131 if (argc<2) error =
"-consense expects a 2nd argument (number of trees)";
133 calculated_trees = atoi(argv[1]);
134 if (calculated_trees < 1) {
135 error =
GBS_global_string(
"Illegal # of trees (%i) for -consense (minimum is 1)", calculated_trees);
140 else if (strcmp(
"-commentFromFile", argv[0]) == 0) {
141 if (argc<2) error =
"-commentFromFile expects a 2nd argument (file containing comment)";
143 commentFile = argv[1];
147 else if (strcmp(
"-db", argv[0]) == 0) {
148 if (argc<3) error =
"-db expects two arguments (database and savename)";
151 dbsavename = argv[2];
156 nonSwitch[nonSwitches++] = argv[0];
162 if (!nonSwitches) error =
"Missing argument 'tree_name'";
164 tree_name = nonSwitch[0];
169 if (!nonSwitches) error =
"Missing argument 'treefile'";
171 treefilename = nonSwitch[0];
175 if (!error && nonSwitches>0) {
176 comment = nonSwitch[0];
180 if (!error && nonSwitches>0) {
187 int main(
int argc,
char **argv) {
192 bool connectToArb = strcmp(param.
dbname,
":") == 0;
195 if (!error || connectToArb) {
197 if (connectToArb) gb_msg_main =
gb_main;
203 if (connectToArb) error =
"you have to start an arbdb server first";
207 char *comment_from_file =
NULp;
208 char *comment_from_treefile =
NULp;
214 if (!comment_from_file) {
243 error =
"Minimum for -consense is 1";
255 if (!error && tree->
is_leaf()) error =
"Cannot load tree (need at least 2 leafs)";
260 const char *comments[] = {
263 comment_from_treefile,
271 if (!empty) tree_remark.
put(
'\n');
272 tree_remark.
cat(comments[c]);
288 free(comment_from_file);
289 free(comment_from_treefile);
293 if (!error && !connectToArb) {
GB_ERROR GB_begin_transaction(GBDATA *gbd)
void set_bootstrap(double bootstrap)
static void error_with_usage(GB_ERROR error)
GBDATA * GB_open(const char *path, const char *opent)
void TREE_scale(TreeNode *tree, double length_scale, double bootstrap_scale)
static GBDATA * gb_msg_main
static void show_error(GB_ERROR error)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
#define DEFAULT_BRANCH_LENGTH
const char * GBS_global_string(const char *templat,...)
void cat(const char *from)
#define ARRAY_ELEMS(array)
GB_ERROR GBT_write_tree_remark(GBDATA *gb_main, const char *tree_name, const char *remark)
GB_ERROR scan(int argc, char **argv)
GB_ERROR GB_await_error()
#define SHIFT_NONSWITCHES(off)
GB_ERROR GB_save_as(GBDATA *gbd, const char *path, const char *savetype)
GB_ERROR GBT_write_tree(GBDATA *gb_main, const char *tree_name, TreeNode *tree)
static void error(const char *msg)
int main(int argc, char **argv)
TreeNode * TREE_load(const char *path, TreeRoot *troot, char **commentPtr, bool allow_length_scaling, char **warningPtr)
fputs(TRACE_PREFIX, stderr)
static list< LineAttachedMessage > warnings
void GBT_message(GBDATA *gb_main, const char *msg)
const char * get_data() const
static void show_message(const char *msg)
void destroy(TreeNode *that)
const char * treefilename
static void add_bootstrap(TreeNode *node, double hundred)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
char * GB_read_file(const char *path)