48 FILE *DUMPOUT = stdout;
54 for (
unsigned L = 0; L<line.
size(); ++L) {
58 fputs(line[L], DUMPOUT);
72 int argc = param.
size();
73 for (i=0; i<argc; i++) {
75 const char *argument = param.
get(i);
77 for (para = ppara; para && !
error; para = para->
next) {
81 if (strncmp(argument, para->
param_name, len) == 0) {
82 const char *value = argument+len;
90 else if (value[0] ==
'=') {
97 *(
const char **)para->
varaddr = value;
102 *(
int *)para->
varaddr = atoi(value);
107 *(
int *)para->
varaddr = (value[0] ? atoi(value) : 1);
111 *(
char *)para->
varaddr = *value;
112 if (value[0] && value[1]) {
113 GB_warningf(
"Only one character expected in value '%s' of param '%s' - rest is ignored", value, para->
param_name);
127 if (!error && !para) {
129 for (para = ppara; para; para = para->
next) pcount++;
135 for (k = 0, para = ppara; para; para = para->
next) params[k++] = para;
140 for (pcount--; pcount>=0; pcount--) {
141 para = params[pcount];
145 switch (para->
type) {
161 return GB_export_errorf(
"Unknown Parameter '%s' in command '%s'\n PARAMETERS:\n%s",
179 char c1 = tolower(s1[i]);
180 char c2 = tolower(s2[i]);
186 if (c1<c2)
return -1;
195 for (i = 0; i<size2; ++i) {
196 char c1 = tolower(s1[i]);
197 char c2 = tolower(s2[i]);
203 if (c1<c2)
return -1;
209 static const char *
gbl_stristr(
const char *haystack,
const char *needle) {
211 const char *hp = haystack;
212 char c1 = toupper(needle[0]);
213 char c2 = tolower(c1);
214 int needle_size = strlen(needle);
219 if (
gbl_strincmp(hp, needle, needle_size) == 0)
return hp;
220 hp = strchr(hp+1, c1);
225 const char *h1 = strchr(hp, c1);
226 const char *h2 = strchr(hp, c2);
230 if (
gbl_strincmp(h1, needle, needle_size) == 0)
return h1;
235 if (
gbl_strincmp(h2, needle, needle_size) == 0)
return h2;
241 else if (h2) { hp = h2; c1 = c2; }
245 if (
gbl_strincmp(hp, needle, needle_size) == 0)
return hp;
246 hp = strchr(hp+1, c1);
254 inline int approve_pos(
int pos,
int len) {
return pos<0 ? (-pos<len ? len+pos : 0) : pos; }
258 for (
int i=0; i<arg_input.
size(); i++) {
259 const char *p = arg_input.
get(i);
266 if (s >= len || e<s) {
284 if (tmp_trace<0 || tmp_trace>1)
return GBS_global_string(
"Illegal value %i to trace", tmp_trace);
327 template <
typename T>
333 if (args->
input.
size() == 0) error =
"Expect at least two input streams if called with 0 parameters";
334 else if (args->
input.
size()%2) error =
"Expect an even number of input streams if called with 0 parameters";
338 for (i = 0; i<inputpairs; ++i) {
346 if (args->
input.
size() == 0) error =
"Expect at least one input stream if called with 1 parameter";
349 const char *argument = args->
get_param(0);
358 for (
int i = 0; i<args->
input.
size(); ++i) {
365 PASS_2_OUT(args, op(result1, result2, client_data));
386 char *
result = nulldup(escapedString);
406 int len = strlen(unescapedString);
407 char *
result = ARB_alloc<char>(2*len+1);
409 const char *from = unescapedString;
415 if (c==
'\\' || c ==
'\"') {
433 for (
int i=0; i<args->
input.
size(); i++) {
441 for (
int i=0; i<args->
input.
size(); i++) {
443 int len = strlen(str);
445 if (str[0] ==
'\"' && str[len-1] ==
'\"') {
458 for (
int i=0; i<args->
input.
size(); i++) {
467 for (
int i=0; i<args->
input.
size(); i++) {
494 EXPECT_PARAMS(args, 1,
"\"expression evaluating to ACI command\"");
523 const char *
get(
const char *name)
const {
return (
const char *)
GBS_read_hash(cmds, name); }
535 defined_commands.
set(name, cmd);
545 const char *cmd = defined_commands.
get(name);
548 error =
GBS_global_string(
"Can't do undefined command '%s' - use define(%s, ...) first", name, name);
622 const char *in = args->
input.
get(i);
639 char *
result = callEnv.interpret_subcommand(
"", command);
678 error =
"'findgene' cannot be used here (was applied to 'gene', but could not find gene-owning organism)";
682 error =
GBS_global_string(
"'findgene' cannot be applied to '%s' (need an organism)",
692 Tab(
bool take,
const char *invert) {
694 for (
int i = 0; i<256; ++i) tab[i] = init;
695 for (
int i = 0; invert[i]; ++i) tab[
safeCharIndex(invert[i])] = take;
701 for (
int i=0; i<args->
input.
size(); ++i) {
712 for (
int i=0; i<args->
input.
size(); ++i) {
714 for (
const char *p = args->
input.
get(i); *p; p++) {
715 if (!tab[(
unsigned int)*p]) {
743 static char *
binop_compare(
const char *arg1,
const char *arg2,
bool case_sensitive) {
746 if (case_sensitive) result = strcmp(arg1, arg2);
751 static char *
binop_equals(
const char *arg1,
const char *arg2,
bool case_sensitive) {
754 if (case_sensitive) result = strcmp(arg1, arg2);
759 static char *
binop_contains(
const char *arg1,
const char *arg2,
bool case_sensitive) {
760 const char *found =
NULp;
762 if (!arg2[0])
return strdup(
"0");
764 if (case_sensitive) found = strstr(arg1, arg2);
769 static char *
binop_partof(
const char *arg1,
const char *arg2,
bool case_sensitive) {
784 for (
int i=0; i<args->
input.
size(); i++) {
796 for (
int i=0; i<args->
input.
size(); i++) {
798 bool inRange = low<=val && val<=high;
809 if (other && (other[0] == 0 || other[1] != 0)) {
810 return "third parameter of translate has to be one character (i.e. \"-\")";
812 const char replace_other = other ? other[0] : 0;
815 unsigned char tab[256];
817 const unsigned char *o = (
const unsigned char *)args->
get_param(0);
818 const unsigned char *n = (
const unsigned char *)args->
get_param(1);
821 if (strlen((
const char *)o) != strlen((
const char *)n)) {
822 return "arguments 1 and 2 of translate should be strings with identical length";
825 for (
int i = 0; i<256; ++i) {
826 tab[i] = replace_other ? replace_other : i;
830 for (
int i = 0; o[i]; ++i) {
831 if (used[o[i]])
return GBS_global_string(
"character '%c' used twice in argument 1 of translate", o[i]);
838 for (
int i=0; i<args->
input.
size(); i++) {
840 for (
const char *p = args->
input.
get(i); *p; p++) {
841 buf.
put(tab[(
unsigned char)*p]);
866 for (
int i=0; i<args->
input.
size(); i++) {
868 bool last_was_alnum =
false;
870 for (
char *pp = p; pp[0]; ++pp) {
872 case LOWER: pp[0] = tolower(pp[0]);
break;
873 case UPPER: pp[0] = toupper(pp[0]);
break;
875 bool alnum = isalnum(pp[0]);
876 if (alnum) pp[0] = (last_was_alnum ? tolower : toupper)(pp[0]);
877 last_was_alnum = alnum;
918 for (
int i=0; i<args->
input.
size(); i++) {
919 int len = strlen(args->
input.
get(i));
922 char *p = ARB_alloc<char>(tab+1);
924 int spaces = tab-len;
925 for (
int j = 0; j<spaces; ++j) p[j] =
' ';
926 strcpy(p+spaces, args->
input.
get(i));
930 for (
int j=len; j<
tab; j++) p[j] =
' ';
944 const char *chars_to_crop = args->
get_param(0);
945 for (
int i=0; i<args->
input.
size(); i++) {
947 while (s[0] && strchr(chars_to_crop, s[0])) s++;
950 char *p = ARB_alloc<char>(len+1);
956 while (pe >= p && strchr(chars_to_crop, pe[0])) {
983 bool *dropped = ARB_alloc<bool>(args->
input.
size());
985 for (
int i=0; i<args->
input.
size(); ++i) dropped[i] =
false;
990 if (!error) dropped[
bio2info(stream)] =
true;
994 for (
int i=0; i<args->
input.
size(); ++i) {
1006 for (
int i=0; i<args->
input.
size(); ++i) {
1017 for (
int i=0; i<args->
input.
size(); ++i) {
1028 if (args->
input.
size()<2)
return "need at least two input streams";
1049 for (
int i = 0; i<args->
input.
size(); ++i) {
1050 int j = i == swap1 ? swap2 : (i == swap2 ? swap1 : i);
1059 if (args->
input.
size()<1)
return "need at least one input stream";
1061 int stream_to_move = atoi(args->
get_param(0));
1063 stream_to_move =
bio2info(stream_to_move);
1065 if (!toback)
IN_2_OUT(args, stream_to_move);
1066 for (
int i = 0; i<args->
input.
size(); ++i) {
1067 if (i != stream_to_move)
IN_2_OUT(args, i);
1069 if (toback)
IN_2_OUT(args, stream_to_move);
1084 for (
int i = 1; i<args->
input.
size(); ++i) {
1085 if (separator) str.
cat(separator);
1100 if (!separator[0]) {
1102 return "Invalid separator (cannot be empty; please try to quote the parameter)";
1105 if (split_mode<0 || split_mode>2)
return GBS_global_string(
"Illegal split mode '%i' (valid: 0..2)", split_mode);
1108 size_t sepLen = strlen(separator);
1110 for (
int i = 0; i<args->
input.
size(); ++i) {
1111 const char *in = args->
input.
get(i);
1112 const char *from = in;
1115 const char *splitAt = strstr(from, separator);
1120 if (split_mode == 2) splitAt += sepLen;
1127 in = splitAt + (split_mode == 0 ? sepLen : 0);
1128 from = in+(split_mode == 1 ? sepLen : 0);
1145 if (width<1)
return "Invalid width";
1147 for (
int i = 0; i<args->
input.
size(); ++i) {
1148 const char *in = args->
input.
get(i);
1149 int len = strlen(in);
1172 int iminlen =
int(minlen+.5);
1176 char **ps = ARB_calloc<char*>((strlen(source)>>1) + 1);
1178 while (
char *p = strtok(f,
" \t,;:|")) {
1181 const int len = strlen(p);
1182 for (
char *h=p; *h; h++) {
1183 if (strchr(chars, *h)) ++cnt;
1186 if (minlen == 1.0) {
1187 if (cnt != len)
continue;
1189 else if (minlen > 1.0) {
1190 if (cnt < iminlen)
continue;
1193 if (len < 3 || cnt < minlen*len)
continue;
1205 for (
int cnt = 0; cnt<count; ++cnt) {
1206 if (cnt) buf.
put(
' ');
1220 for (
int i=0; i<args->
input.
size(); i++) {
1232 float minFreq = atof(args->
get_param(1));
1234 if (minFreq <0.0 || minFreq > 1.0)
return GBS_global_string(
"Illegal minFrequency=%f (allowed: ]0.0 .. 1.0[)", minFreq);
1236 for (
int i=0; i<args->
input.
size(); i++) {
1246 GBL_PARAM_STRING(exclude,
"exclude=",
"",
"Remove given characters before calculating");
1247 GBL_PARAM_BIT (upper,
"toupper", 0,
"Convert all characters to uppercase before calculating");
1251 for (
int i=0; i<args->
input.
size(); i++) {
1261 for (
int i=0; i<args->
input.
size(); i++) {
1276 char *modsource =
NULp;
1281 if (hs) freeset(modsource, hs);
1301 double (*DOUBLE)(double, double);
1302 binop_pair(
int (*INT_)(
int,
int),
double (*DOUBLE_)(
double,
double)) : INT(INT_), DOUBLE(DOUBLE_) {}
1306 int v1 = atoi(arg1);
1307 int v2 = atoi(arg2);
1308 int result = num_bin_op(v1, v2);
1313 static char *
apply_double_binop(
const char *arg1,
const char *arg2,
double (*num_bin_op)(
double,
double)) {
1314 double v1 = strtod(arg1,
NULp);
1315 double v2 = strtod(arg2,
NULp);
1316 double result = num_bin_op(v1, v2);
1323 int i1 = atoi(arg1);
1324 int i2 = atoi(arg2);
1325 double d1 = strtod(arg1,
NULp);
1326 double d2 = strtod(arg2,
NULp);
1328 if (
double(i1) == d1 ||
double(i2) == d2) {
1343 template <
typename T>
static T binop_div (
T v1,
T v2) {
return v2 ? v1/v2 : 0; }
1386 for (
int i=0; i<args->
input.
size(); ++i) {
1388 val = round(val*factor)/factor;
1401 for (
int i=0; i<args->
input.
size(); ++i) {
1411 bool conjunction =
true;
1412 for (
int i=0; conjunction && i<args->
input.
size(); ++i) {
1414 conjunction = conjunction && atoi(s);
1421 bool disjunction =
false;
1422 for (
int i=0; !disjunction && i<args->
input.
size(); ++i) {
1424 disjunction = disjunction || atoi(s);
1435 int paraidx = atoi(args->
input.
get(i));
1480 const char *key =
GB_KEY(gb_item);
1482 if (strcmp(key,
"species") == 0 &&
1483 strcmp(
GB_KEY(gb_father),
"species_data") == 0) {
1486 else if (strcmp(key,
"gene") == 0 &&
1487 strcmp(
GB_KEY(gb_father),
"gene_data") == 0 &&
1504 #define GROUP_COUNT_CHARS 6 // characters in taxonomy-key reserved for group-counter (hex number)
1505 #define BITS_PER_HEXCHAR 4
1506 #define MAX_GROUPS (1 << (GROUP_COUNT_CHARS*BITS_PER_HEXCHAR)) // resulting number of groups
1539 const char *hash_binary_entry;
1594 #ifdef DUMP_TAXONOMY_CACHING
1595 if (tree) printf(
"tree_of_cached_taxonomy: tree='%s' ct->tree_name='%s'\n", tree, ct->
tree_name);
1596 #endif // DUMP_TAXONOMY_CACHING
1610 #ifdef DUMP_TAXONOMY_CACHING
1611 fprintf(stderr,
"Deleting cached taxonomy ct=%p (tree='%s')\n", ct, found);
1612 #endif // DUMP_TAXONOMY_CACHING
1616 #ifdef DUMP_TAXONOMY_CACHING
1618 fprintf(stderr,
"No tree found for cached_taxonomies ct=%p (already deleted?)\n", ct);
1620 #endif // DUMP_TAXONOMY_CACHING
1626 if (found && !error) {
1630 if (!gb_tree_refresh) {
1640 fprintf(stderr,
"Error in flush_taxonomy_cb: %s\n", error);
1646 #ifdef DUMP_TAXONOMY_CACHING
1647 fputs(
"flush_taxonomy_if_new_group_cb() has been called\n", stderr);
1648 #endif // DUMP_TAXONOMY_CACHING
1655 for (gb_group_node =
GB_entry(gb_tree,
"node");
1659 if (
GB_entry(gb_group_node,
"group_name")) {
1664 #ifdef DUMP_TAXONOMY_CACHING
1665 fprintf(stderr,
"cached_groups=%i counted_groups=%i\n", ct->
groups, groups);
1666 #endif // DUMP_TAXONOMY_CACHING
1667 if (groups != ct->
groups) {
1668 #ifdef DUMP_TAXONOMY_CACHING
1669 fprintf(stderr,
"Number of groups changed -> invoking flush_taxonomy_cb() manually\n");
1670 #endif // DUMP_TAXONOMY_CACHING
1674 #ifdef DUMP_TAXONOMY_CACHING
1676 fprintf(stderr,
"cached taxonomy no longer valid.\n");
1678 #endif // DUMP_TAXONOMY_CACHING
1684 if (!cached_taxonomies) {
1701 int group_counter = 0;
1718 if (gb_tree_entry) {
1724 for (gb_group_node =
GB_entry(gb_tree,
"node");
1729 if (gb_group_name) {
1736 #ifdef DUMP_TAXONOMY_CACHING
1737 fprintf(stderr,
"Created taxonomy hash for '%s' (ct=%p)\n", tree_name, ct);
1738 #endif // DUMP_TAXONOMY_CACHING
1759 gb_assert(!(group_key[0] ==
'>' && group_key[1] ==
'>'));
1763 const char *parent_group_key = (
const char *)found;
1764 if (strcmp(parent_group_key,
"<root>") == 0) {
1775 *error =
GBS_global_string(
"In get_taxonomy_string(%s): %s", group_key, *error);
1797 GBDATA *gb_group_name =
GB_entry(gb_species_or_group,
"group_name");
1799 if (gb_name && !gb_group_name) {
1806 const char *parent_group = (
const char *)found;
1808 if (strcmp(parent_group,
"<root>") == 0) {
1812 static char *parent =
NULp;
1827 else if (gb_group_name && !gb_name) {
1830 if (is_current_tree) {
1835 static char *full_group =
NULp;
1836 const char *group_id = (
const char *)found;
1839 result = full_group;
1846 *error =
"It's not possible to specify the tree name in taxonomy() for groups";
1851 *error =
"Group without 'group_name' entry";
1854 else if (gb_group_name) {
1855 *error =
"Container has 'name' and 'group_name' entry - can't detect container type";
1858 *error =
"Container has neither 'name' nor 'group_name' entry - can't detect container type";
1871 char *tree_name =
NULp;
1872 bool is_current_tree =
false;
1883 is_current_tree =
true;
1897 if (taxonomy_string) result =
ARB_strdup(taxonomy_string);
1916 error =
"'sequence' used for unknown item";
1956 error =
"'export_sequence' used for unknown item";
1961 error =
"No export-sequence-hook defined (can't use 'export_sequence' here)";
1974 error =
"'export_sequence' cannot be used for gene";
2017 GBL_PARAM_INT(firsttab,
"firsttab=", 10,
"Indent first line");
2019 GBL_PARAM_INT(width,
"width=", 50,
"Sequence width (bases only)");
2023 GBL_PARAM_INT (numright,
PARAM_IF(!simple_format,
"numright="), 0,
"Numbers right of sequence (specifies width; -1 -> auto-width)");
2034 if (firsttab < 0) firsttab = 0;
2036 if (width == 0)
return "Illegal zero width";
2037 if (numleft && numright != 0)
return "You may only specify 'numleft' OR 'numright', not both.";
2039 if (gap<1) gap = UINT_MAX;
2041 for (ic = 0; ic<args->
input.
size(); ++ic) {
2042 const char *src = args->
input.
get(ic);
2043 size_t data_size = strlen(src);
2046 int numright_used = numright;
2048 if (numright_used<0) {
2055 if (simple_format) {
2056 lines = data_size/2 + 1;
2057 line_size =
tab + (width>0 ? width : data_size) + 1;
2060 size_t gapsPerLine = (width-1)/gap;
2061 lines = data_size/width+1;
2062 line_size =
tab + width + gapsPerLine + 1;
2064 if (numright_used) {
2066 line_size += numright_used+1;
2070 needed_size = lines*line_size + firsttab + 1 + 10;
2073 char *
result = ARB_alloc<char>(needed_size);
2075 error =
GBS_global_string(
"Out of memory (tried to alloc %zu bytes)", needed_size);
2079 size_t rest_data = data_size;
2081 if (simple_format) {
2087 unsigned char isWrapChar[256];
2088 memset(isWrapChar, 0,
sizeof(isWrapChar));
2089 for (
int i = 0;
nl[i]; ++i) isWrapChar[(
unsigned char)
nl[i]] = 1;
2090 for (
int i = 0; forcenl[i]; ++i) isWrapChar[(
unsigned char)forcenl[i]] = 2;
2093 memset(dst,
' ', firsttab);
2097 while (width>0 && rest_data>
unsigned(width)) {
2102 for (take = width; take > 0; --take) {
2103 if (isWrapChar[(
unsigned char)src[take]])
break;
2106 take = move = width;
2112 for (took = 0; took<take; took++) {
2114 if (isWrapChar[(
unsigned char)c] == 2) {
2129 memset(dst,
' ',
tab);
2137 for (j = 0, k = 0; j<rest_data; ++j) {
2140 if (isWrapChar[(
unsigned char)c] == 2) {
2143 memset(dst+k,
' ',
tab);
2159 const char *src_start = src;
2160 const char *dst_linestart = dst;
2168 dst += sprintf(dst, firstFormat, (
unsigned)1);
2172 dst += sprintf(dst,
"%u ", (
unsigned)1);
2176 else if (firsttab>0) {
2177 memset(dst,
' ', firsttab);
2181 while (rest_data>0) {
2182 size_t take = (width>0 && rest_data>unsigned(width)) ? width : rest_data;
2187 memcpy(dst, src, gap);
2194 memcpy(dst, src, take);
2198 if (numright_used) {
2199 if (rest_data) *dst++ =
' ';
2202 size_t currSize = dst-dst_linestart;
2203 size_t wantSize = line_size-numright_used-1;
2204 if (currSize<wantSize) {
2205 size_t spaces = wantSize-currSize;
2206 memset(dst,
' ', spaces);
2210 unsigned int num = (src-src_start);
2211 dst += sprintf(dst,
"%*u", numright_used, num);
2216 dst_linestart = dst;
2218 unsigned int num = (src-src_start)+1;
2219 dst += sprintf(dst, format, num);
2222 memset(dst,
' ',
tab);
2235 size_t used_size = dst-
result;
2261 int sources = !!species + !!sai;
2263 error =
"Either parameters 'species' or 'SAI' must be specified";
2267 const char *what =
NULp;
2268 const char *name =
NULp;
2283 char *freeMe =
NULp;
2311 if (!seq) error =
GBS_global_string(
"%s '%s' has no (usable) data in alignment '%s'", what, name, ali);
2333 #define GBL_COMMON_FILTER_PARAMS \
2334 common_filter_params common_param; \
2335 GBL_STRUCT_PARAM_STRING(common_param, align, "align=", NULp, "alignment to use (defaults to default alignment)"); \
2336 GBL_STRUCT_PARAM_STRING(common_param, sai, "SAI=", NULp, "Use default sequence of given SAI as a filter"); \
2337 GBL_STRUCT_PARAM_STRING(common_param, species, "species=", NULp, "Use default sequence of given species as a filter"); \
2338 GBL_STRUCT_PARAM_BIT (common_param, first, "first=", 0, "Use 1st stream as filter for other streams"); \
2339 GBL_STRUCT_PARAM_BIT (common_param, pairwise, "pairwise=", 0, "Use 1st stream as filter for 2nd, 3rd for 4th, ...")
2341 typedef char* (*filter_fun)(
const char *
seq,
const char *filter,
size_t flen,
void *param);
2351 if (args->
input.
size()==0) error =
"No input stream";
2355 if (methodCount != 1) error =
"Need exactly one of the parameters 'SAI', 'species', 'pairwise' or 'first'";
2358 if (args->
input.
size() % 2) error =
"Using 'pairwise' requires an even number of input streams";
2361 for (i = 1; i<args->
input.
size(); i += 2) {
2368 char *filter =
NULp;
2371 if (common->
first) {
2372 if (args->
input.
size()<2) error =
"Using 'first' needs at least 2 input streams";
2374 const char *in = args->
input.
get(i++);
2406 static char *
calc_diff(
const char *seq,
const char *filter,
size_t ,
void *paramP) {
2412 char equal_char = param->
equalC;
2413 char diff_char = param->
diffC;
2418 for (p = 0; result[p] && filter[p]; ++p) {
2419 if (result[p] == filter[p]) {
2420 if (equal_char) result[p] = equal_char;
2423 if (diff_char) result[p] = diff_char;
2430 for (; result[p]; ++p) {
2431 result[p] = diff_char;
2443 GBL_STRUCT_PARAM_CHAR(param, diffC,
"differ=", 0,
"symbol for diff characters (default: use char from input stream)");
2467 static char *
filter_seq(
const char *seq,
const char *filter,
size_t flen,
void *paramP) {
2470 size_t slen = strlen(seq);
2471 if (!flen) flen = strlen(filter);
2472 size_t mlen = slen<flen ? slen : flen;
2476 const char *charset;
2504 count = (inset ? strspn : strcspn)(filter+pos, charset);
2507 int applies = !!include == !!inset;
2508 if (count>rest) count = rest;
2512 if (applies) out.
ncat(seq+pos, count);
2518 for (i = 0; i<count; i++) {
2519 char c = seq[pos+i];
2525 out.
ncat(seq+pos, count);
2553 if (inOrEx != 1) error =
"Need exactly one parameter of: 'include', 'exclude'";
2566 GBL_STRUCT_PARAM_INT (param, change_pc,
"change=", 0,
"percentage of changed columns (default: silently change nothing)");
2576 if (inOrEx != 1) error =
"Need exactly one parameter of: 'include', 'exclude'";
2596 for (
int i = 0; i<args->
input.
size(); i++) {
2597 fprintf(out,
"%s\n", args->
input.
get(i));
2624 FILE *in = popen(sys,
"r");
2629 while ((i=getc(in)) != EOF) { str.
put(i); }
static GB_ERROR gbl_drop(GBL_command_arguments *args)
static GB_ERROR gbl_toback(GBL_command_arguments *args)
static GBL_command_definition gbl_command_table[]
static char * binop_contains(const char *arg1, const char *arg2, bool case_sensitive)
static T binop_per_cent(T v1, T v2)
size_t GBT_count_leafs(const TreeNode *tree)
static GB_ERROR gbl_extract_words(GBL_command_arguments *args)
void GB_remove_all_callbacks_to(GBDATA *gbd, GB_CB_TYPE type, GB_CB func)
static void flush_taxonomy_if_new_group_cb(GBDATA *gb_tree, cached_taxonomy *ct)
static char * calc_diff(const char *seq, const char *filter, size_t, void *paramP)
static GB_ERROR gbl_iequals(GBL_command_arguments *args)
GB_ERROR check_optional_parameters(GBL_command_arguments *args, int fix, const char *fixParam, int opt, const char *optParam, bool opt_trailing, bool opt_expect_all)
static GB_ERROR tab(GBL_command_arguments *args, bool pretab)
static GB_ERROR gbl_and(GBL_command_arguments *args)
static GB_ERROR gbl_isBelow(GBL_command_arguments *args)
static GB_ERROR gbl_keep(GBL_command_arguments *args)
static GB_ERROR gbl_compare(GBL_command_arguments *args)
#define GBL_STRUCT_PARAM_CHAR(strct,member, param_name, def, help_text)
bool GEN_is_organism(GBDATA *gb_species)
bool operator[](int i) const
#define EXPECT_OPTIONAL_PARAMS(args, fixCnt, fixhelp, optCnt, opthelp)
static GB_ERROR gbl_icompare(GBL_command_arguments *args)
static GB_ERROR gbl_gcgchecksum(GBL_command_arguments *args)
GBDATA * GB_child(GBDATA *father)
static GB_ERROR gbl_icontains(GBL_command_arguments *args)
static GB_ERROR gbl_mult(GBL_command_arguments *args)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
static GB_ERROR gbl_fper_cent(GBL_command_arguments *args)
static GB_ERROR gbl_unescape(GBL_command_arguments *args)
static GB_ERROR gbl_merge(GBL_command_arguments *args)
static GB_ERROR gbl_origin_organism(GBL_command_arguments *args)
char * GBS_string_eval_in_env(const char *insource, const char *icommand, const GBL_call_env &callEnv)
CONSTEXPR_INLINE unsigned char safeCharIndex(char c)
#define GBL_PARAM_UINT(var,param_name, def, help_text)
bool has_group_info() const
GB_ERROR GB_add_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
const char * get(int idx) const
static GB_ERROR gbl_dropzero(GBL_command_arguments *args)
#define EXPECT_OPTIONAL_PARAMS_CUSTOM(args, fixCnt, fixhelp, optCnt, opthelp, trail, all)
static gb_export_sequence_cb get_export_sequence
void GB_unlink_or_warn(const char *path, GB_ERROR *error)
#define GBL_PARAM_INT(var,param_name, def, help_text)
void GB_sort(void **array, size_t first, size_t behind_last, gb_compare_function compare, void *client_data)
GBDATA * get_gb_main() const
static char * apply_auto_numeric_binop(const char *arg1, const char *arg2, binop_pair multiop)
static GB_ERROR gbl_quote(GBL_command_arguments *args)
GBDATA * GB_nextEntry(GBDATA *entry)
static GB_ERROR gbl_ali_name(GBL_command_arguments *args)
static GB_ERROR gbl_crop(GBL_command_arguments *args)
static T binop_minus(T v1, T v2)
char * interpret_subcommand(const char *input, const char *command) const
char * ARB_strdup(const char *str)
const char * get_cmdName() const
static char * escapeString(const char *unescapedString)
static GB_ERROR gbl_ipartof(GBL_command_arguments *args)
TreeNode * GBT_read_tree(GBDATA *gb_main, const char *tree_name, TreeRoot *troot)
#define GBL_PARAM_BIT(var,param_name, def, help_text)
static GB_ERROR gbl_taxonomy(GBL_command_arguments *args)
static GB_ERROR gbl_eval(GBL_command_arguments *args)
static GB_ERROR gbl_escape(GBL_command_arguments *args)
const char * GBS_global_string(const char *templat,...)
int approve_pos(int pos, int len)
GB_HASH * GBS_create_dynaval_hash(long estimated_elements, GB_CASE case_sens, void(*freefun)(long))
static GB_ERROR gbl_format(GBL_command_arguments *args)
static GB_ERROR gbl_div(GBL_command_arguments *args)
static GB_ERROR gbl_findgene(GBL_command_arguments *args)
#define GBL_STRUCT_PARAM_INT(strct,member, param_name, def, help_text)
void(* GB_CB)(GBDATA *, int *clientdata, GB_CB_TYPE gbtype)
static GB_ERROR gbl_minus(GBL_command_arguments *args)
void GBS_free_hash(GB_HASH *hs)
long GBS_gcgchecksum(const char *seq)
void cat(const char *from)
#define COPY_2_OUT(args, s)
char * ARB_strpartdup(const char *start, const char *end)
static GB_ERROR gbl_pretab(GBL_command_arguments *args)
static GB_ERROR gbl_readdb(GBL_command_arguments *args)
static GB_ERROR gbl_contains(GBL_command_arguments *args)
long GB_read_bits_count(GBDATA *gbd)
static T binop_div(T v1, T v2)
const char * get(const char *name) const
#define ARRAY_ELEMS(array)
GB_ERROR GBT_link_tree(TreeNode *tree, GBDATA *gb_main, bool show_status, int *zombies, int *duplicates)
GBDATA * GB_get_grandfather(GBDATA *gbd)
char * GBT_get_alignment_type_string(GBDATA *gb_main, const char *aliname)
#define ACCEPT_ANY_PARAMS(args)
GBDATA * GB_get_father(GBDATA *gbd)
GB_ERROR gbl_apply_binary_operator(GBL_command_arguments *args, char *(*op)(const char *, const char *, T), T client_data)
const GBL_call_env & get_callEnv() const
Tab(bool take, const char *invert)
static GB_HASH * cached_taxonomies
static GB_ERROR gbl_rest(GBL_command_arguments *args)
static GB_ERROR gbl_round(GBL_command_arguments *args)
static GB_ERROR apply_to_origin(GBL_command_arguments *args, bool organism)
GB_ERROR check_no_parameter(GBL_command_arguments *args)
static GB_ERROR gbl_remove(GBL_command_arguments *args)
static char * apply_numeric_binop(const char *arg1, const char *arg2, int(*num_bin_op)(int, int))
const char * get_optional_param(int idx, const char *defaultValue) const
int GB_string_comparator(const void *v0, const void *v1, void *)
static HelixNrInfo * start
const GBL_env & get_env() const
const char * GBS_hash_next_element_that(const GB_HASH *hs, const char *last_key, bool(*condition)(const char *key, long val, void *cd), void *cd)
static GB_ERROR gbl_change_gc(GBL_command_arguments *args)
static GB_ERROR gbl_or(GBL_command_arguments *args)
static GB_ERROR gbl_tail(GBL_command_arguments *args)
GBDATA * GBT_find_SAI(GBDATA *gb_main, const char *name)
static T binop_isBelow(T i1, T i2)
static GB_ERROR gbl_exec(GBL_command_arguments *args)
GB_ERROR GB_export_error(const char *error)
#define IN_2_OUT(args, i)
GB_ERROR check_valid_stream_index(GBL_command_arguments *args, int number)
static GB_ERROR gbl_unquote(GBL_command_arguments *args)
size_t GB_read_string_count(GBDATA *gbd)
GB_ERROR GB_await_error()
static int gbl_strincmp(const char *s1, const char *s2, int size2)
static char * do_extract_words(const char *source, const char *chars, float minlen, bool sort_output)
char * ARB_strduplen(const char *p, unsigned len)
GB_TYPES GB_read_type(GBDATA *gbd)
static GB_ERROR gbl_command(GBL_command_arguments *args)
static GB_ERROR gbl_cut(GBL_command_arguments *args)
static void build_taxonomy_rek(TreeNode *node, GB_HASH *tax_hash, const char *parent_group, int *group_counter)
static GB_ERROR gbl_extract_sequence(GBL_command_arguments *args)
#define PARAM_IF(cond, param)
void GB_warningf(const char *templat,...)
static T binop_isAbove(T i1, T i2)
static GB_ERROR gbl_upper(GBL_command_arguments *args)
GB_CSTR GB_read_key_pntr(GBDATA *gbd)
#define PASS_2_OUT(args, s)
static char * gbl_read_seq_sai_or_species(GBDATA *gb_main, const char *species, const char *sai, const char *ali, size_t *seqLen)
static GB_ERROR gbl_swap(GBL_command_arguments *args)
void print_trace(const char *text)
static GB_ERROR gbl_checksum(GBL_command_arguments *args)
CONSTEXPR_INLINE int digits(int parts)
static const char * gbl_stristr(const char *haystack, const char *needle)
#define EXPECT_ITEM_REFERENCED(args)
static GBT_ITEM_TYPE identify_gb_item(GBDATA *gb_item)
bool set_params_checked()
double(* DOUBLE)(double, double)
#define COMMAND_DROPS_INPUT_STREAMS(args)
static GB_ERROR gbl_dropempty(GBL_command_arguments *args)
static bool is_cached_taxonomy(const char *, long val, void *cl_ct)
static GB_ERROR gbl_tab(GBL_command_arguments *args)
const char * get_param(int idx) const
static void error(const char *msg)
GBDATA * GB_get_root(GBDATA *gbd)
#define GBL_STRUCT_PARAM_STRING(strct, member, param_name, def, help_text)
static GB_ERROR gbl_isEqual(GBL_command_arguments *args)
char * GB_read_bits(GBDATA *gbd, char c_0, char c_1)
#define AWAR_TREE_REFRESH
FILE * GB_fopen_tempfile(const char *filename, const char *fmode, char **res_fullname)
static GB_ERROR gbl_not(GBL_command_arguments *args)
static T binop_mult(T v1, T v2)
#define GROUP_COUNT_CHARS
#define PARAM_2_OUT(args, i)
static GB_ERROR backfront_stream(GBL_command_arguments *args, int toback)
#define GBL_COMMON_FILTER_PARAMS
GB_ERROR trace_params(const GBL_streams ¶m, gbl_param *ppara, const char *com)
static GB_ERROR gbl_sequence(GBL_command_arguments *args)
static GB_ERROR gbl_select(GBL_command_arguments *args)
GB_write_int const char GB_write_autoconv_string WRITE_SKELETON(write_pointer, GBDATA *,"%p", GB_write_pointer) char *AW_awa if)(!gb_var) return strdup("")
GBDATA * GEN_find_gene_data(GBDATA *gb_species)
static void free_cached_taxonomy(cached_taxonomy *ct)
static GB_ERROR gbl_findacc(GBL_command_arguments *args)
static void flush_taxonomy_cb(GBDATA *gbd, cached_taxonomy *ct)
void GBS_dynaval_free(long val)
static GB_ERROR gbl_mid(GBL_command_arguments *args)
static SearchTree * tree[SEARCH_PATTERNS]
static GB_ERROR gbl_colsplit(GBL_command_arguments *args)
static GB_ERROR gbl_partof(GBL_command_arguments *args)
static GB_ERROR gbl_filter(GBL_command_arguments *args)
static const char * tree_of_cached_taxonomy(cached_taxonomy *ct)
static GB_ERROR gbl_fmult(GBL_command_arguments *args)
static GB_ERROR gbl_isEmpty(GBL_command_arguments *args)
static GB_ERROR gbl_mid_streams(const GBL_streams &arg_input, GBL_streams &arg_out, int start, int end)
GB_ERROR count_by_tab(GBL_command_arguments *args, const Tab &tab)
static GB_ERROR apply_filters(GBL_command_arguments *args, common_filter_params *common, filter_fun filter_one, void *param)
binop_pair(int(*INT_)(int, int), double(*DOUBLE_)(double, double))
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
char * GBT_read_gene_sequence(GBDATA *gb_gene, bool use_revComplement, char partSeparator)
static char * filter_seq(const char *seq, const char *filter, size_t flen, void *paramP)
static char * apply_double_binop(const char *arg1, const char *arg2, double(*num_bin_op)(double, double))
static GB_ERROR gbl_origin_gene(GBL_command_arguments *args)
static GB_ERROR gbl_trace(GBL_command_arguments *args)
const char *(* gb_export_sequence_cb)(GBDATA *gb_species, size_t *seq_len, GB_ERROR *error)
static GB_ERROR gbl_export_sequence(GBL_command_arguments *args)
char * GB_unique_filename(const char *name_prefix, const char *suffix)
GBDATA * get_item_ref() const
#define EXPECT_NO_PARAM(args)
static GB_ERROR gbl_equals(GBL_command_arguments *args)
static GB_ERROR gbl_srt(GBL_command_arguments *args)
static GB_ERROR gbl_lower(GBL_command_arguments *args)
static GB_ERROR convert_case(GBL_command_arguments *args, Case convTo)
fputs(TRACE_PREFIX, stderr)
ASSERTING_CONSTEXPR_INLINE int bio2info(int biopos)
static GB_ERROR gbl_sequence_type(GBL_command_arguments *args)
GB_ERROR GB_export_errorf(const char *templat,...)
static T binop_plus(T v1, T v2)
static void copy(double **i, double **j)
static GB_ERROR gbl_fdiv(GBL_command_arguments *args)
void ncat(const char *from, size_t count)
static GB_ERROR gbl_echo(GBL_command_arguments *args)
TYPE * ARB_calloc(size_t nelem)
static DefinedCommands defined_commands
void set(const char *name, char *cmd)
#define FORMAT_2_OUT(args, fmt, value)
GBDATA * GEN_find_origin_organism(GBDATA *gb_pseudo, const GB_HASH *organism_hash)
char * ARB_strndup(const char *start, int len)
static const char * get_taxonomy(GBDATA *gb_species_or_group, const char *tree_name, bool is_current_tree, int depth, GB_ERROR *error)
NOT4PERL void GB_set_export_sequence_hook(gb_export_sequence_cb escb)
static GB_ERROR format(GBL_command_arguments *args, bool simple_format)
static GB_ERROR gbl_plus(GBL_command_arguments *args)
void GB_touch(GBDATA *gbd)
static char * binop_partof(const char *arg1, const char *arg2, bool case_sensitive)
static int gbl_stricmp(const char *s1, const char *s2)
static GB_ERROR gbl_fplus(GBL_command_arguments *args)
GB_ERROR check_valid_param_index(GBL_command_arguments *args, int number)
#define GBL_PARAM_STRING(var, param_name, def, help_text)
void ARB_realloc(TYPE *&tgt, size_t nelem)
static GB_ERROR gbl_count(GBL_command_arguments *args)
char * GB_read_string(GBDATA *gbd)
static int binop_rest(int i1, int i2)
static GB_ERROR gbl_diff(GBL_command_arguments *args)
static char * get_taxonomy_string(GB_HASH *tax_hash, const char *group_key, int depth, GB_ERROR *error)
char * GBT_read_as_string(GBDATA *gb_container, const char *fieldpath)
static GB_ERROR gbl_split(GBL_command_arguments *args)
static ARB_init_perl_interface init
uint32_t GBS_checksum(const char *seq, int ignore_case, const char *exclude)
static GB_ERROR gbl_len(GBL_command_arguments *args)
static GB_ERROR gbl_isAbove(GBL_command_arguments *args)
GB_ERROR remove_by_tab(GBL_command_arguments *args, const Tab &tab)
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
static T binop_isEqual(T i1, T i2)
static GB_ERROR gbl_do(GBL_command_arguments *args)
char *(* filter_fun)(const char *seq, const char *filter, size_t flen, void *param)
static char * binop_equals(const char *arg1, const char *arg2, bool case_sensitive)
static GB_ERROR gbl_define(GBL_command_arguments *args)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
static GB_ERROR gbl_caps(GBL_command_arguments *args)
static GB_ERROR applyToItemFoundByKey(GBL_command_arguments *args, const char *itemname, GBDATA *gb_item_data, const char *key)
void GBT_split_string(ConstStrArray &dest, const char *namelist, const char *separator, SplitMode mode)
double float_shift_factor(int digits)
char * GBT_get_default_alignment(GBDATA *gb_main)
const char * get_data() const
const char * GBT_get_name(GBDATA *gb_item)
GBDATA * GB_nextChild(GBDATA *child)
#define GBL_TRACE_PARAMS(args)
static GB_ERROR gbl_dd(GBL_command_arguments *args)
GBDATA * GBT_find_tree(GBDATA *gb_main, const char *tree_name)
void destroy(TreeNode *that)
GBDATA * GB_get_gb_main_during_cb()
static GB_ERROR gbl_fminus(GBL_command_arguments *args)
static GB_ERROR gbl_per_cent(GBL_command_arguments *args)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
const char * GB_KEY(GBDATA *gbd)
NOT4PERL bool GB_inside_callback(GBDATA *of_gbd, GB_CB_TYPE cbtype)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
bool GEN_is_genome_db(GBDATA *gb_main, int default_value)
const char * track_field_access(const char *fieldname) const
static GB_ERROR gbl_streams(GBL_command_arguments *args)
#define EXPECT_LEGAL_STREAM_INDEX(args, number)
bool GEN_is_pseudo_gene_species(GBDATA *gb_species)
static GB_ERROR expect_used_in_genome_db(GBL_command_arguments *args)
#define STATIC_ASSERT(const_expression)
static GB_ERROR gbl_translate(GBL_command_arguments *args)
static cached_taxonomy * get_cached_taxonomy(GBDATA *gb_main, const char *tree_name, GB_ERROR *error)
static GB_ERROR gbl_head(GBL_command_arguments *args)
const GBL_command_lookup_table & ACI_get_standard_commands()
#define EXPECT_PARAMS(args, cnt, help)
char * release_memfriendly()
long GBS_read_hash(const GB_HASH *hs, const char *key)
GB_ERROR mid(GBL_command_arguments *args, int start_index)
static GB_ERROR gbl_format_sequence(GBL_command_arguments *args)
GBDATA * GB_entry(GBDATA *father, const char *key)
static GB_ERROR gbl_mid0(GBL_command_arguments *args)
#define EXPECT_PARAMS_PASSED(args, syntax)
char * GBS_global_string_copy(const char *templat,...)
static GB_ERROR gbl_findspec(GBL_command_arguments *args)
static GB_ERROR gbl_tofront(GBL_command_arguments *args)
bool GB_is_privatefile(const char *path, bool read_private)
static char * binop_compare(const char *arg1, const char *arg2, bool case_sensitive)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
GBDATA * GEN_find_origin_gene(GBDATA *gb_pseudo, const GB_HASH *organism_hash)
static GB_ERROR gbl_inRange(GBL_command_arguments *args)
const char * get_treename() const
static char * unEscapeString(const char *escapedString)
GBDATA * GBT_get_species_data(GBDATA *gb_main)
GB_write_int const char s