32 fputs(
"Command line usage:\n"
33 " $ arb_convert_aln [--arb-notify] -INFMT input_file -OUTFMT output_file\n"
36 " INFMT may be 'GenBank', 'EMBL', 'AE2' or 'SwissProt' and\n"
37 " OUTFMT may be 'GenBank', 'EMBL', 'AE2', 'NEXUS', 'PHYLIP', 'FASTDNAML', 'GCG' or 'Printable'\n"
38 " (Note: you may abbreviate the format names)\n"
40 " FASTDNAML writes a PHYLIP file with content from STDIN appended at end of first line (used for arb_fastdnaml).\n"
42 " if argument '--arb-notify' is given, arb_convert_aln assumes it has been started by ARB\n"
43 " and reports errors using the 'arb_message' script.\n"
53 FILE *ifp = fopen(file_name,
"r");
64 for (indi =
str0len(old_file) - 1; indi >= 0 && old_file[indi] !=
'.'; indi--)
66 strcpy(file_name, old_file);
68 for (indj = 0; indj < (indi - 1); indj++)
69 file_name[indj] = old_file[indj];
70 file_name[indj] =
'\0';
74 strcat(file_name,
".GB");
77 strcat(file_name,
".aln");
80 strcat(file_name,
".NEXUS");
83 strcat(file_name,
".PHY");
86 strcat(file_name,
".EMBL");
89 strcat(file_name,
".prt");
92 strcat(file_name,
".???");
100 fputs(
"---------------------------------------------------------------\n"
102 " convert_aln - an alignment and file converter written by\n"
103 " WenMin Kuan for the RDP database project.\n"
105 " Modified for use in ARB by Oliver Strunk & Ralf Westram\n"
106 " Report errors or deficiencies to devel@arb-home.de\n"
111 "---------------------------------------------------------------\n"
113 "Select input format (<CR> means default)\n"
115 " (1) GenBank [default]\n"
128 case '1': inType =
GENBANK;
break;
129 case '2': inType =
EMBL;
break;
130 case '3': inType =
MACKE;
break;
133 default:
throw_errorf(16,
"Unknown input format selection '%s'", choice);
136 fputs(
"\nInput file name? ", stderr);
138 in.
init(temp, inType);
146 "Select output format (<CR> means default)\n"
150 " (3) AE2 [default]\n"
151 " (4) NEXUS (Paup)\n"
162 case '1': ouType =
GENBANK;
break;
163 case '2': ouType =
EMBL;
break;
165 case '3': ouType =
MACKE;
break;
166 case '4': ouType =
NEXUS;
break;
167 case '5': ouType =
PHYLIP;
break;
168 case '6': ouType =
GCG;
break;
171 default:
throw_errorf(66,
"Unknown output format selection '%s'", choice);
175 fprintf(stderr,
"\nOutput file name [%s]? ", temp);
180 out.
init(temp, ouType);
186 for (
int p = 0; !
cmp; p++) {
187 cmp = tolower(s1[p])-tolower(s2[p]);
188 if (!s1[p])
return 0;
198 for (
size_t i = 0; i<
ARRAY_ELEMS(convertible_type); ++i) {
221 return strcmp(arg,
"-h") == 0 || strcmp(arg,
"--help") == 0;
224 for (
int c = 1; c<argc; c++) {
231 if (argc != 5)
throw_errorf(69,
"arb_convert_aln expects exactly 4 parameters (you specified %i). Try '--help'", argc-1);
241 fprintf(stderr,
"\n\nConvert file %s to file %s.\n", in.
name(), out.
name());
254 bool use_arb_message =
false;
259 if (argc>1 && strcmp(argv[1],
"--arb-notify") == 0) {
260 use_arb_message =
true;
276 if (use_arb_message) {
279 if (error) fprintf(stderr,
"Error: %s\n", error);
280 free(quotedErrorMsg);
292 void TEST_BASIC_switch_parsing() {
CONSTEXPR_INLINE int str0len(const char *str)
GB_ERROR GBK_system(const char *system_command)
void throw_errorf(int error_num, const char *error_messagef,...) __ATTR__FORMAT(2) __ATTR__NORETURN
void warningf(int warning_num, const char *warning_messagef,...) __ATTR__FORMAT(2)
static void change_file_suffix(const char *old_file, char *file_name, int type)
const char * GBS_global_string(const char *templat,...)
void convert(const FormattedFile &in, const FormattedFile &out)
const char * get_msg() const
static bool file_exists(const char *file_name)
#define ARRAY_ELEMS(array)
static void do_conversion(const FormattedFile &in, const FormattedFile &out)
#define TEST_EXPECT(cond)
#define TEST_REJECT(cond)
static int strcasecmp_start(const char *s1, const char *s2)
static void error(const char *msg)
static Format parse_type(const char *arg)
static bool command_line_conversion(int argc, const char *const *argv, FormattedFile &in, FormattedFile &out)
CONSTEXPR_INLINE bool is_input_format(Format inType)
static void ask_for_conversion_params(FormattedFile &in, FormattedFile &out)
static TypeSwitch convertible_type[]
#define TEST_EXPECT_ZERO(cond)
fputs(TRACE_PREFIX, stderr)
void Getstr(char *line, int linenum)
char * GBK_singlequote(const char *arg)
static Format parse_outtype(const char *arg)
void throw_error(int error_num, const char *error_message) __ATTR__NORETURN
static bool is_help_req(const char *arg)
static bool is_abbrev_switch(const char *arg, const char *switchtext)
static void valid_name_or_die(const char *file_name)
static void show_command_line_usage()
int ARB_main(int argc, char *argv[])
static Format parse_intype(const char *arg)
#define TEST_EXPECT_EQUAL(expr, want)