27 #define CATSCALE 0.71 // downscale factor for rates
28 #define MIO 1000000 // factor to scale rate-values to integers (for RAxML)
33 if (argc<1 || strcmp(argv[0],
"--help") == 0) {
36 "arb_export_rates: Add a line to phylip format which can be used by fastdnaml for rates\n"
37 "syntax: arb_export_rates [--arb-notify] [-d dbname] [SAI_NAME|'--none'] [other_fastdnaml_args]*\n"
38 "if other_fastdnaml_args are given they are inserted to the output\n"
42 "arb_export_rates: Write a weightsfile for RAxML\n"
43 "syntax: arb_export_rates [--arb-notify] [-d dbname] -r [SAI_NAME|'--none']\n"
45 "Note: if no DB is specified using -d, the default server ':' will be used.\n"
50 bool RAxML_mode =
false;
51 bool use_arb_message =
false;
53 const char *dbname =
":";
54 const char *SAI_name =
NULp;
57 if (strcmp(argv[0],
"--arb-notify") == 0) {
58 use_arb_message =
true;
63 if (strcmp(argv[0],
"-d") == 0) {
70 if (strcmp(argv[0],
"-r") == 0) {
82 error =
"Missing argument 'SAI_NAME'";
114 filter_len = strlen(filter);
116 bool have_no_sai = SAI_name[0] == 0 || strcmp(SAI_name,
"--none") == 0;
127 seq_len = strlen(seq);
142 #define APPEARS_IN_HEADER(c) (!strchr(not_in_header, (c)))
143 const char *not_in_header =
"Y";
147 for (
int arg = 0; arg<argc; ++arg) {
148 char command_char = argv[arg][0];
149 if (!command_char)
continue;
157 if (seq)
fputc(
'C', stdout);
158 fputs(firstline, stdout);
164 for (
int appears_in_header = 0; appears_in_header <= 1; ++appears_in_header) {
165 for (
int arg = 0; arg < argc; ++arg) {
166 if (!argv[arg][0])
continue;
167 if (!argv[arg][1])
continue;
170 fputs(argv[arg], stdout);
173 #undef APPEARS_IN_HEADER
179 for (i=0; i<35; i++) {
183 printf(
"\nCategories ");
185 for (i=0; i<seq_len; i++) {
186 if (i>filter_len || filter[i] !=
'0') {
191 if ((c < '0' || c>
'9') && (c < 'A' || c>
'Z')) c =
'1';
195 for (; i<ali_len; i++) {
207 for (i = 0; i <=
'Z'; i++) weight[i] =
NULp;
211 for (i =
'1'; i <=
'9'; i++) {
215 for (i =
'A'; i <=
'Z'; i++) {
221 seq = (
char*)malloc(ali_len+1);
222 memset(seq,
'1', ali_len);
227 freedup(weight[
'1'],
" 1");
230 for (i=0; i<seq_len; i++) {
231 if (i>filter_len || filter[i] !=
'0') {
233 if ((c < '0' || c>
'9') && (c < 'A' || c>
'Z')) c =
'1';
234 fputs(weight[c], stdout);
242 for (; i<ali_len; i++) {
243 if (i>filter_len || filter[i] !=
'0') {
244 fputs(weight[
'1'], stdout);
252 for (i = 0; i <=
'Z'; i++) free(weight[i]);
265 fprintf(stderr,
"Error in arb_export_rates: %s\n", error);
266 if (use_arb_message) {
269 if (msgerror) fprintf(stderr,
"Error: %s\n", msgerror);
270 free(quotedErrorMsg);
GB_ERROR GBK_system(const char *system_command)
char * ARB_strdup(const char *str)
const char * GBS_global_string(const char *templat,...)
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
#define APPEARS_IN_HEADER(c)
#define AWAR_GDE_EXPORT_FILTER
GBDATA * GBT_open(const char *path, const char *opent)
GBDATA * GBT_find_SAI(GBDATA *gb_main, const char *name)
GB_ERROR GB_await_error()
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
static int weight[maxsites+1]
static void error(const char *msg)
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
fputs(TRACE_PREFIX, stderr)
char * GBK_singlequote(const char *arg)
char * GB_read_string(GBDATA *gbd)
char * GBT_get_default_alignment(GBDATA *gb_main)
int ARB_main(int argc, char *argv[])
GB_transaction ta(gb_var)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)