diff options
author | Thomas White <taw@physics.org> | 2020-08-27 16:18:40 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-08-27 16:18:40 +0200 |
commit | 4e0d428addebd689abadfaa0ef8cafd2bd1fd726 (patch) | |
tree | 1aac03947e8ffb2417a45b8f3755f3dcfdc634fb | |
parent | fd1ac49e0a97dadf4a87cde83840cd80863c57ca (diff) |
Construct complete command line for indexamajig
-rw-r--r-- | src/gui_backend_local.c | 77 | ||||
-rw-r--r-- | src/gui_index.c | 118 | ||||
-rw-r--r-- | src/gui_index.h | 5 |
3 files changed, 133 insertions, 67 deletions
diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c index 3c74c10a..3aee7904 100644 --- a/src/gui_backend_local.c +++ b/src/gui_backend_local.c @@ -37,6 +37,7 @@ #include <utils.h> #include "gui_project.h" +#include "gui_index.h" struct local_indexing_opts @@ -134,19 +135,6 @@ static int write_file_list(char **filenames, } -static void add_arg(char **args, int pos, const char *label, - float val) -{ - char *str; - - str = malloc(64); - if ( str == NULL ) return; - - snprintf(str, 63, "--%s=%f", label, val); - args[pos] = str; -} - - void setup_subprocess(gpointer user_data) { const char *workdir = user_data; @@ -168,11 +156,8 @@ static void *run_indexing(const char *job_title, { struct local_indexing_opts *opts = opts_priv; GIOChannel *ioch; - char *args[64]; - char index_str[64]; - char peaks_str[64]; char n_thread_str[64]; - int n_args; + char **args; int i; int r; int ch_stderr; @@ -212,57 +197,15 @@ static void *run_indexing(const char *job_title, job->n_frames = n_frames; job->frac_complete = 0.0; - strcpy(index_str, "--indexing=dirax"); /* FIXME */ - - strcpy(peaks_str, "--peaks="); - strncat(peaks_str, - str_peaksearch(peak_search_params->method), 50); - snprintf(n_thread_str, 63, "%i", opts->n_processes); - - args[0] = "indexamajig"; - args[1] = "-i"; - args[2] = "files.lst"; - args[3] = "-g"; - args[4] = geom_filename; - args[5] = "-o"; - args[6] = "test.stream"; - args[7] = index_str; - args[8] = "--no-check-cell"; - args[9] = "-j"; - args[10] = n_thread_str; - args[11] = "--integration=none"; - args[12] = peaks_str; - n_args = 13; - - if ( peak_search_params->method == PEAK_ZAEF ) { - add_arg(args, n_args++, "threshold", - peak_search_params->threshold); - add_arg(args, n_args++, "min-squared-gradient", - peak_search_params->min_sq_gradient); - add_arg(args, n_args++, "min-snr", - peak_search_params->min_snr); - } else if ( peak_search_params->method == PEAK_PEAKFINDER8 ) { - add_arg(args, n_args++, "threshold", - peak_search_params->threshold); - add_arg(args, n_args++, "min-snr", - peak_search_params->min_snr); - add_arg(args, n_args++, "min-pix-count", - peak_search_params->min_pix_count); - add_arg(args, n_args++, "max-pix-count", - peak_search_params->max_pix_count); - add_arg(args, n_args++, "local-bg-radius", - peak_search_params->local_bg_radius); - add_arg(args, n_args++, "min-res", - peak_search_params->min_res); - add_arg(args, n_args++, "max-res", - peak_search_params->max_res); - } - - args[n_args] = NULL; - - for ( i=0; i<n_args; i++ ) { - STATUS("%s ", args[i]); + args = indexamajig_command_line(geom_filename, + n_thread_str, + peak_search_params, + indexing_params); + + i = 0; + while ( args[i] != NULL ) { + STATUS("%s ", args[i++]); } STATUS("\n"); diff --git a/src/gui_index.c b/src/gui_index.c index 7e9401a6..ebb0b54d 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -521,3 +521,121 @@ gint index_one_sig(GtkWidget *widget, struct crystfelproject *proj) return FALSE; } + + +static void add_arg(char **args, int pos, const char *label) +{ + args[pos] = strdup(label); +} + + +static void add_arg_float(char **args, int pos, const char *label, + float val) +{ + char *str = malloc(64); + if ( str == NULL ) return; + snprintf(str, 63, "--%s=%f", label, val); + args[pos] = str; +} + + +static void add_arg_int(char **args, int pos, const char *label, + int val) +{ + char *str = malloc(64); + if ( str == NULL ) return; + snprintf(str, 63, "--%s=%i", label, val); + args[pos] = str; +} + + +char **indexamajig_command_line(const char *geom_filename, + const char *n_thread_str, + struct peak_params *peak_search_params, + struct index_params *indexing_params) +{ + char **args; + char tols[2048]; + int n_args = 0; + + args = malloc(64*sizeof(char *)); + if ( args == NULL ) return NULL; + + /* The basics */ + add_arg(args, n_args++, "indexamajig"); + add_arg(args, n_args++, "-i"); + add_arg(args, n_args++, "files.lst"); + add_arg(args, n_args++, "-g"); + add_arg(args, n_args++, geom_filename); + add_arg(args, n_args++, "-o"); + add_arg(args, n_args++, "crystfel.stream"); + add_arg(args, n_args++, "-j"); + add_arg(args, n_args++, n_thread_str); + + /* Peak search */ + add_arg(args, n_args++, "--peaks"); + add_arg(args, n_args++, str_peaksearch(peak_search_params->method)); + + if ( peak_search_params->method == PEAK_ZAEF ) { + add_arg_float(args, n_args++, "threshold", + peak_search_params->threshold); + add_arg_float(args, n_args++, "min-squared-gradient", + peak_search_params->min_sq_gradient); + add_arg_float(args, n_args++, "min-snr", + peak_search_params->min_snr); + + } else if ( peak_search_params->method == PEAK_PEAKFINDER8 ) { + add_arg_float(args, n_args++, "threshold", + peak_search_params->threshold); + add_arg_float(args, n_args++, "min-snr", + peak_search_params->min_snr); + add_arg_int(args, n_args++, "min-pix-count", + peak_search_params->min_pix_count); + add_arg_int(args, n_args++, "max-pix-count", + peak_search_params->max_pix_count); + add_arg_int(args, n_args++, "local-bg-radius", + peak_search_params->local_bg_radius); + add_arg_int(args, n_args++, "min-res", + peak_search_params->min_res); + add_arg_int(args, n_args++, "max-res", + peak_search_params->max_res); + } + + if ( indexing_params->min_peaks > 0 ) { + add_arg_int(args, n_args++, "min-peaks", + indexing_params->min_peaks); + } + + /* Indexing */ + add_arg(args, n_args++, "--indexing"); + add_arg(args, n_args++, indexing_params->indexing_methods); + if ( indexing_params->cell_file != NULL ) { + add_arg(args, n_args++, "-p"); + add_arg(args, n_args++, indexing_params->cell_file); + } + snprintf(tols, 2048, "--tolerance=%f,%f,%f,%f,%f,%f", + indexing_params->tols[0], + indexing_params->tols[1], + indexing_params->tols[2], + indexing_params->tols[3], + indexing_params->tols[4], + indexing_params->tols[5]); + add_arg(args, n_args++, tols); + if ( indexing_params->multi ) add_arg(args, n_args++, "--multi"); + if ( indexing_params->no_refine ) add_arg(args, n_args++, "--no-refine"); + if ( indexing_params->no_retry ) add_arg(args, n_args++, "--no-retry"); + if ( indexing_params->no_peak_check ) add_arg(args, n_args++, "--no-peak-check"); + if ( indexing_params->no_cell_check ) add_arg(args, n_args++, "--no-cell-check"); + + /* Integration */ + add_arg(args, n_args++, "--integration"); + add_arg(args, n_args++, indexing_params->integration_method); + if ( indexing_params->overpredict ) args[n_args++] = "--overpredict"; + if ( !isinf(indexing_params->push_res) ) { + add_arg_float(args, n_args++, "push-res", + indexing_params->push_res); + } + + args[n_args] = NULL; + return args; +} diff --git a/src/gui_index.h b/src/gui_index.h index 991151ef..89b6a7e3 100644 --- a/src/gui_index.h +++ b/src/gui_index.h @@ -41,4 +41,9 @@ extern gint index_all_sig(GtkWidget *widget, extern void cell_explorer_sig(struct crystfelproject *proj); +extern char **indexamajig_command_line(const char *geom_filename, + const char *n_thread_str, + struct peak_params *peak_search_params, + struct index_params *indexing_params); + #endif |