15 #define PRM_BUFFERSIZE 256
52 memset(buffer, 0,
sizeof(buffer));
56 for (
int i = 0; i<
sp_count; ++i) free(data[i]);
75 printf(
" Please select an Alignment:\n");
90 printf(
"This module will search for primers for all positions.\n"
91 " The best result is one primer for all (marked) taxa , the worst case\n"
92 " are n primers for n taxa.\n"
93 " Please specify the maximum number of primers:\n"
97 printf(
"Select minimum length of a primer, the maximum will be (minimum + %i)\n",
ADD_LEN);
99 if ((i<4) || (i>30)) {
105 printf(
"There may be short sequences or/and deletes in full sequences\n"
106 " So a primer normally does not match all sequences\n"
107 " Specify minimum percentage of species (0-100 %%):\n");
109 if ((i<1) || (i>100)) {
115 printf(
"Write output to file (enter \"\" to write to screen)\n");
117 char *lf = strchr(aprm.
buffer,
'\n');
149 if (gb_source_data) {
156 char *data = ARB_calloc<char>(aprm.
al_len+1);
157 aprm.
data[sp_count ++] = data;
159 if (sp_count % 50 == 0) printf(
"Reading taxa %i\n", sp_count);
163 for (i=0; i<size; i++) {
165 if ((c>=
'a') && (c<=
'z')) {
172 for (; i<aprm.
al_len; i++) {
180 printf(
"%i taxa read\n", sp_count);
183 return "No marked taxa found";
201 for (p = key; *p; p++) {
202 if (*p ==
'G' || *p ==
'C') gc++;
204 fprintf(aprm.
out,
" %s matching %4li taxa GC = %3i%%\n",
205 key, val, 100*gc/(
int)strlen(key));
209 #define is_base(c) (((c>='a') && (c<='z')) || ((c>='A')&&(c<='Z')))
220 if (c ==
'N' || c ==
'n')
return 1;
234 const int BUFLEN = 256;
237 int size = strlen(key)-aprm.
reduce;
241 memcpy(buffer, key, size);
258 int *best_primer_cnt;
259 int *best_primer_new;
260 int *best_primer_swap;
268 for (pos = 0; pos < aprm.
al_len; pos++) {
272 if (pos % 50 == 0) printf(
"Pos. %i (%i)\n", pos, aprm.
al_len);
273 cutoff_cnt = aprm.
prmanz+1;
274 for (sp = 0; sp < aprm.
sp_count; sp++) {
289 (aprm.
key_cnt<best_primer_cnt[prmlen+1])) {
290 fprintf(aprm.
out,
"%3i primer found len %3i(of %4i taxa) for position %i\n", aprm.
key_cnt, prmlen, pspecies, pos);
292 fprintf(aprm.
out,
"\n\n");
295 best_primer_new[prmlen] = aprm.
key_cnt;
307 for (; prmlen>0; prmlen--) best_primer_new[prmlen] = aprm.
prmanz+1;
310 best_primer_swap = best_primer_new;
311 best_primer_new = best_primer_cnt;
312 best_primer_cnt = best_primer_swap;
316 free(best_primer_new);
317 free(best_primer_cnt);
322 const char *path =
NULp;
325 if (strcmp(argv[1],
"--help") == 0) {
327 "Usage: arb_primer [dbname]\n"
328 "Searches sequencing primers\n");
335 if (!path) path =
":";
378 fprintf(stderr,
"Error in arb_primer: %s\n", error);
GB_ERROR GB_begin_transaction(GBDATA *gbd)
static void arb_count_keys(const char *, long val, void *)
GBDATA * GB_open(const char *path, const char *opent)
GB_ERROR GB_commit_transaction(GBDATA *gbd)
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
long GB_read_int(GBDATA *gbd)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
long GBS_incr_hash(GB_HASH *hs, const char *key)
static GB_ERROR arb_prm_menu()
void GBT_get_alignment_names(ConstStrArray &names, GBDATA *gbd)
char buffer[PRM_BUFFERSIZE]
GB_ERROR GB_IO_error(const char *action, const char *filename)
char * ARB_strdup(const char *str)
const char * GBS_global_string(const char *templat,...)
void GBS_free_hash(GB_HASH *hs)
char buffer[MESSAGE_BUFFERSIZE]
size_t GB_read_string_count(GBDATA *gbd)
GB_ERROR GB_await_error()
static void arb_prm_primer(int)
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
static void error(const char *msg)
GB_ERROR GB_abort_transaction(GBDATA *gbd)
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
static int primer_print(char *dest, char *source, int size)
static long arb_reduce_primer_len(const char *key, long val, void *cl_hash)
GBDATA * GB_brother(GBDATA *entry, const char *key)
static void arb_print_primer(const char *key, long val, void *)
void GBS_hash_do_loop(GB_HASH *hs, gb_hash_loop_type func, void *client_data)
long GBT_count_marked_species(GBDATA *gb_main)
GB_ERROR GB_print_error()
int ARB_main(int argc, char *argv[])
TYPE * ARB_calloc(size_t nelem)
ConstStrArray alignment_names
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
static GB_ERROR arb_prm_read(int)
static arb_prm_struct aprm
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GBDATA * GBT_get_presets(GBDATA *gb_main)
long GBS_read_hash(const GB_HASH *hs, const char *key)
GBDATA * GB_entry(GBDATA *father, const char *key)
void GB_close(GBDATA *gbd)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)