diff options
author | Thomas White <taw@physics.org> | 2021-01-20 16:25:14 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-01-20 16:25:14 +0100 |
commit | b1ad534716b532a54103200fb0749aa82b929fde (patch) | |
tree | c8c3a46a0065a9fd739abf9263d7d0957d904dbc | |
parent | b3c159fc276c3c8032b05a010495d0a255f06dda (diff) |
GUI: Implement merge results
-rw-r--r-- | src/gui_backend_local.c | 34 | ||||
-rw-r--r-- | src/gui_merge.c | 6 | ||||
-rw-r--r-- | src/gui_project.c | 94 | ||||
-rw-r--r-- | src/gui_project.h | 13 |
4 files changed, 113 insertions, 34 deletions
diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c index b5c38b5a..bbea063c 100644 --- a/src/gui_backend_local.c +++ b/src/gui_backend_local.c @@ -65,6 +65,7 @@ struct local_job GPid pid; guint child_watch_source; guint io_readable_source; + GFile *workdir; }; @@ -169,7 +170,6 @@ static struct local_job *start_local_job(char **args, GFile *cwd_file; GFile *notes_file; char *notes_path; - char **streams; FILE *fh; workdir = strdup(job_title); @@ -212,6 +212,7 @@ static struct local_job *start_local_job(char **args, chdir(old_pwd); job->frac_complete = 0.0; + job->workdir = workdir_file; STATUS("Running program: "); i = 0; @@ -246,16 +247,6 @@ static struct local_job *start_local_job(char **args, readable_func, job); - streams = malloc(sizeof(char *)); - if ( streams != NULL ) { - GFile *stream_gfile = g_file_get_child(workdir_file, - "crystfel.stream"); - streams[0] = g_file_get_path(stream_gfile); - g_object_unref(stream_gfile); - add_indexing_result(proj, strdup(job_title), streams, 1); - } - - g_object_unref(workdir_file); return job; } @@ -455,6 +446,8 @@ static void *run_merging(const char *job_title, char **args; struct local_job *job; struct local_merging_opts *opts = opts_priv; + GFile *hkl_gfile; + char *hkl; snprintf(n_thread_str, 63, "%i", opts->n_threads); args = merging_command_line(n_thread_str, @@ -464,6 +457,14 @@ static void *run_merging(const char *job_title, job = start_local_job(args, job_title, job_notes, proj, merge_readable); + if ( job == NULL ) return NULL; + + hkl_gfile = g_file_get_child(job->workdir, + "crystfel.hkl"); + hkl = g_file_get_path(hkl_gfile); + g_object_unref(hkl_gfile); + add_merge_result(proj, strdup(job_title), hkl); + return job; } @@ -477,6 +478,7 @@ static void *run_indexing(const char *job_title, struct local_job *job; char n_thread_str[64]; char **args; + char **streams; int i; snprintf(n_thread_str, 63, "%i", opts->n_processes); @@ -500,6 +502,16 @@ static void *run_indexing(const char *job_title, /* Indexing-specific job data */ job->n_frames = proj->n_frames; + streams = malloc(sizeof(char *)); + if ( streams != NULL ) { + GFile *stream_gfile = g_file_get_child(job->workdir, + "crystfel.stream"); + streams[0] = g_file_get_path(stream_gfile); + g_object_unref(stream_gfile); + add_indexing_result(proj, strdup(job_title), + streams, 1); + } + return job; } diff --git a/src/gui_merge.c b/src/gui_merge.c index 3d4039e4..64e5416d 100644 --- a/src/gui_merge.c +++ b/src/gui_merge.c @@ -417,6 +417,9 @@ static GSList *process_hkl_command_line(struct gui_indexing_result *input, args = g_slist_append(args, input->streams[i]); } + args = g_slist_append(args, "-o"); + args = g_slist_append(args, "crystfel.hkl"); + args = append_arg_str(args, "symmetry", params->symmetry); if ( params->scale ) { @@ -455,6 +458,9 @@ static GSList *partialator_command_line(const char *n_thread_str, args = g_slist_append(args, input->streams[i]); } + args = g_slist_append(args, "-o"); + args = g_slist_append(args, "crystfel.hkl"); + args = append_arg_str(args, "symmetry", params->symmetry); args = g_slist_append(args, "-j"); diff --git a/src/gui_project.c b/src/gui_project.c index d88ea791..ec6f616b 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -563,6 +563,34 @@ static void read_parameters(FILE *fh, struct crystfelproject *proj) } +static void add_result(struct crystfelproject *proj, + char *results_name, + char **streams, + int n_streams, + int selected, + char *hkl) +{ + if ( (n_streams > 0) && (hkl == NULL) ) { + add_indexing_result(proj, results_name, + streams, n_streams); + + if ( selected ) { + select_result(proj, results_name); + } + + } else if ( (hkl != NULL) && (n_streams == 0) ) { + add_merge_result(proj, + results_name, + hkl); + + } else { + ERROR("Bad results %s (%i %s)\n", + results_name, n_streams, hkl); + } + +} + + static void read_results(FILE *fh, struct crystfelproject *proj) { char *rval; @@ -570,7 +598,9 @@ static void read_results(FILE *fh, struct crystfelproject *proj) char **streams = NULL; int n_streams = 0; char *results_name = NULL; + char *hkl = NULL; int selected = 0; + int first = 1; do { @@ -581,21 +611,18 @@ static void read_results(FILE *fh, struct crystfelproject *proj) if ( strncmp(line, "Result ", 7) == 0 ) { - if ( n_streams > 0 ) { - /* Add the previously-read result */ - add_indexing_result(proj, - results_name, - streams, - n_streams); - - if ( selected ) { - select_result(proj, results_name); - } + if ( !first ) { + add_result(proj, results_name, + streams, n_streams, selected, + hkl); } + first = 0; n_streams = 0; selected = 0; streams = NULL; + hkl = NULL; + results_name = strdup(line+7); } @@ -609,21 +636,15 @@ static void read_results(FILE *fh, struct crystfelproject *proj) &n_streams); } - if ( strcmp(line, "-----") == 0 ) { - - if ( n_streams > 0 ) { - add_indexing_result(proj, - results_name, - streams, - n_streams); - - if ( selected ) { - select_result(proj, results_name); - } - } + if ( strncmp(line, " HKL ", 7) == 0 ) { + hkl = strdup(line+7); + } + if ( strcmp(line, "-----") == 0 ) { + add_result(proj, results_name, + streams, n_streams, selected, + hkl); break; - } } while ( rval != NULL ); @@ -863,6 +884,10 @@ int save_project(struct crystfelproject *proj) fprintf(fh, " Selected\n"); } } + for ( i=0; i<proj->n_merge_results; i++ ) { + fprintf(fh, "Result %s\n", proj->merge_results[i].name); + fprintf(fh, " HKL %s\n", proj->merge_results[i].hkl); + } fprintf(fh, "-----\n"); for ( i=0; i<proj->n_frames; i++ ) { @@ -986,6 +1011,9 @@ void default_project(struct crystfelproject *proj) proj->results = NULL; proj->n_results = 0; + + proj->merge_results = NULL; + proj->n_merge_results = 0; } @@ -1021,6 +1049,26 @@ int add_indexing_result(struct crystfelproject *proj, } +int add_merge_result(struct crystfelproject *proj, + char *name, + char *hkl) +{ + struct gui_merge_result *new_results; + + new_results = realloc(proj->merge_results, + (proj->n_merge_results+1)*sizeof(struct gui_merge_result)); + if ( new_results == NULL ) return 1; + + new_results[proj->n_merge_results].name = name; + new_results[proj->n_merge_results].hkl = hkl; + + proj->merge_results = new_results; + proj->n_merge_results++; + + return 0; +} + + static void update_result_index(struct gui_indexing_result *result) { int i; diff --git a/src/gui_project.h b/src/gui_project.h index bb85be43..62503e6f 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -123,6 +123,12 @@ struct gui_indexing_result StreamIndex **indices; }; +struct gui_merge_result +{ + char *name; + char *hkl; +}; + struct crystfelproject; struct crystfel_backend { @@ -256,6 +262,9 @@ struct crystfelproject { struct gui_indexing_result *results; int n_results; + + struct gui_merge_result *merge_results; + int n_merge_results; }; extern enum match_type_id decode_matchtype(const char *type_id); @@ -287,4 +296,8 @@ extern struct image *find_indexed_image(struct crystfelproject *proj, extern struct gui_indexing_result *find_indexing_result_by_name(struct crystfelproject *proj, const char *name); +extern int add_merge_result(struct crystfelproject *proj, + char *name, + char *hkl); + #endif |