From 7fe3ad557caa79313ae566c225fb5de7bfcf21bf Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 18 Oct 2017 14:59:25 +0200 Subject: Add read_reflections_2() to API New version for reading the symmetry as well --- libcrystfel/src/reflist-utils.c | 48 ++++++++++++++++++++++++++++++----------- libcrystfel/src/reflist-utils.h | 5 +++-- 2 files changed, 39 insertions(+), 14 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c index 1aee6018..7ff78f52 100644 --- a/libcrystfel/src/reflist-utils.c +++ b/libcrystfel/src/reflist-utils.c @@ -3,11 +3,11 @@ * * Utilities to complement the core reflist.c * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2016 Thomas White + * 2011-2017 Thomas White * 2014 Valerio Mariani * * This file is part of CrystFEL. @@ -283,15 +283,13 @@ int write_reflist(const char *filename, RefList *list) #define HEADER_2_0 "CrystFEL reflection list version 2.0" -/** - * read_reflections_from_file: - * @fh: File handle to read from - * - * This function reads a reflection list from @fh. +/* fh: File handle to read from + * sym: Location at which to store pointer to symmetry, or NULL if you don't + * need it * * Returns: a %RefList read from the file, or NULL on error - **/ -RefList *read_reflections_from_file(FILE *fh) + */ +static RefList *read_reflections_from_file(FILE *fh, char **sym) { char *rval = NULL; RefList *out; @@ -317,7 +315,9 @@ RefList *read_reflections_from_file(FILE *fh) chomp(line); if ( strncmp(line, "Symmetry: ", 10) != 0 ) return NULL; - /* FIXME: Do something with the symmetry */ + if ( sym != NULL ) { + *sym = strdup(line+10); + } /* Read (and ignore) the header */ rval = fgets(line, 1023, fh); @@ -418,7 +418,17 @@ RefList *read_reflections_from_file(FILE *fh) } -RefList *read_reflections(const char *filename) +/** + * read_reflections_2: + * @filename: Filename to read from + * @sym: Pointer to a "char *" at which to store the symmetry + * + * This function reads a reflection list from a file, including the + * symmetry from the header (e.g. "Symmetry: 4/mmm"). + * + * Returns: A %RefList read from the file, or NULL on error + */ +RefList *read_reflections_2(const char *filename, char **sym) { FILE *fh; RefList *out; @@ -434,7 +444,7 @@ RefList *read_reflections(const char *filename) return NULL; } - out = read_reflections_from_file(fh); + out = read_reflections_from_file(fh, sym); fclose(fh); @@ -442,6 +452,20 @@ RefList *read_reflections(const char *filename) } +/** + * read_reflections: + * @filename: Filename to read from + * + * This function reads a reflection list from a file. + * + * Returns: A %RefList read from the file, or NULL on error + */ +RefList *read_reflections(const char *filename) +{ + return read_reflections_2(filename, NULL); +} + + /** * asymmetric_indices: * @in: A %RefList diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h index 7e16c677..f64e9f51 100644 --- a/libcrystfel/src/reflist-utils.h +++ b/libcrystfel/src/reflist-utils.h @@ -3,11 +3,11 @@ * * Utilities to complement the core reflist.c * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2016 Thomas White + * 2011-2017 Thomas White * 2014 Valerio Mariani * * This file is part of CrystFEL. @@ -50,6 +50,7 @@ extern int write_reflist(const char *filename, RefList *list); extern int write_reflist_2(const char *filename, RefList *list, SymOpList *sym); extern RefList *read_reflections(const char *filename); +extern RefList *read_reflections_2(const char *filename, char **sym); extern int check_list_symmetry(RefList *list, const SymOpList *sym); extern int find_equiv_in_list(RefList *list, signed int h, signed int k, -- cgit v1.2.3