diff options
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 7 | ||||
-rw-r--r-- | src/cell.c | 33 | ||||
-rw-r--r-- | src/cell.h | 2 | ||||
-rw-r--r-- | src/utils.c | 14 | ||||
-rw-r--r-- | src/utils.h | 2 |
6 files changed, 50 insertions, 10 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 81089265..b7108918 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,7 @@ process_hkl_LDADD = @LIBS@ indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \ peaks.c index.c filters.c diffraction.c detector.c \ - sfac.c dirax.c reflections.c templates.c + sfac.c dirax.c reflections.c templates.c symmetry.c indexamajig_LDADD = @LIBS@ if HAVE_OPENCL indexamajig_SOURCES += diffraction-gpu.c cl-utils.c diff --git a/src/Makefile.in b/src/Makefile.in index 23079835..9355ef39 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -88,7 +88,7 @@ hdfsee_OBJECTS = $(am_hdfsee_OBJECTS) hdfsee_DEPENDENCIES = am__indexamajig_SOURCES_DIST = indexamajig.c hdf5-file.c utils.c \ cell.c image.c peaks.c index.c filters.c diffraction.c \ - detector.c sfac.c dirax.c reflections.c templates.c \ + detector.c sfac.c dirax.c reflections.c templates.c symmetry.c \ diffraction-gpu.c cl-utils.c @HAVE_OPENCL_TRUE@am__objects_1 = diffraction-gpu.$(OBJEXT) \ @HAVE_OPENCL_TRUE@ cl-utils.$(OBJEXT) @@ -96,7 +96,8 @@ am_indexamajig_OBJECTS = indexamajig.$(OBJEXT) hdf5-file.$(OBJEXT) \ utils.$(OBJEXT) cell.$(OBJEXT) image.$(OBJEXT) peaks.$(OBJEXT) \ index.$(OBJEXT) filters.$(OBJEXT) diffraction.$(OBJEXT) \ detector.$(OBJEXT) sfac.$(OBJEXT) dirax.$(OBJEXT) \ - reflections.$(OBJEXT) templates.$(OBJEXT) $(am__objects_1) + reflections.$(OBJEXT) templates.$(OBJEXT) symmetry.$(OBJEXT) \ + $(am__objects_1) indexamajig_OBJECTS = $(am_indexamajig_OBJECTS) indexamajig_DEPENDENCIES = am__pattern_sim_SOURCES_DIST = pattern_sim.c diffraction.c utils.c \ @@ -259,7 +260,7 @@ process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c \ process_hkl_LDADD = @LIBS@ indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \ peaks.c index.c filters.c diffraction.c detector.c sfac.c \ - dirax.c reflections.c templates.c $(am__append_3) + dirax.c reflections.c templates.c symmetry.c $(am__append_3) indexamajig_LDADD = @LIBS@ @HAVE_GTK_TRUE@hdfsee_SOURCES = hdfsee.c displaywindow.c render.c hdf5-file.c utils.c image.c \ @HAVE_GTK_TRUE@ filters.c @@ -56,6 +56,8 @@ struct _unitcell { double ays; double bys; double cys; double azs; double bzs; double czs; + char *pointgroup; + }; @@ -77,6 +79,8 @@ UnitCell *cell_new() cell->rep = CELL_REP_CRYST; + cell->pointgroup = strdup("1"); + return cell; } @@ -447,6 +451,12 @@ int cell_get_reciprocal(UnitCell *cell, } +const char *cell_get_pointgroup(UnitCell *cell) +{ + return cell->pointgroup; +} + + /********************************* Utilities **********************************/ void cell_print(UnitCell *cell) @@ -731,6 +741,21 @@ double resolution(UnitCell *cell, signed int h, signed int k, signed int l) } +static void cell_set_pointgroup_from_pdb(UnitCell *cell, const char *sym) +{ + char *new = NULL; + + if ( strcmp(sym, "P 63") == 0 ) new = "6"; + + if ( new != NULL ) { + free(cell->pointgroup); + cell->pointgroup = strdup(new); + } else { + ERROR("Can't determine point group for space group %s\n", sym); + } +} + + UnitCell *load_cell_from_pdb(const char *filename) { FILE *fh; @@ -753,8 +778,9 @@ UnitCell *load_cell_from_pdb(const char *filename) float a, b, c, al, be, ga; int r; + char *sym; - r = sscanf(line+7, "%f %f %f %f %f %f", + r = sscanf(line+7, "%f %f %f %f %f %f\n", &a, &b, &c, &al, &be, &ga); if ( r != 6 ) { ERROR("Couldn't understand CRYST1 line\n"); @@ -767,6 +793,11 @@ UnitCell *load_cell_from_pdb(const char *filename) deg2rad(be), deg2rad(ga)); + sym = strndup(line+55, 11); + notrail(sym); + cell_set_pointgroup_from_pdb(cell, sym); + free(sym); + } } while ( rval != NULL ); @@ -67,6 +67,8 @@ extern void cell_set_reciprocal(UnitCell *cell, double bsx, double bsy, double bsz, double csx, double csy, double csz); +extern const char *cell_get_pointgroup(UnitCell *cell); + extern double resolution(UnitCell *cell, signed int h, signed int k, signed int l); diff --git a/src/utils.c b/src/utils.c index 0f20435e..a47f234f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -18,15 +18,21 @@ #include "image.h" -size_t skipspace(const char *s) +size_t notrail(char *s) { size_t i; + size_t munched = 0; - for ( i=0; i<strlen(s); i++ ) { - if ( (s[i] != ' ') && (s[i] != '\t') ) return i; + for ( i=strlen(s)-1; i>=0; i-- ) { + if ( (s[i] == ' ') || (s[i] == '\t') ) { + s[i] = '\0'; + munched++; + } else { + return munched; + } } - return strlen(s); + return munched; } diff --git a/src/utils.h b/src/utils.h index f7e98469..a8d7aa2d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -65,7 +65,7 @@ extern struct rvec quat_rot(struct rvec q, struct quaternion z); /* --------------------------- Useful functions ----------------------------- */ -extern size_t skipspace(const char *s); +extern size_t notrail(char *s); extern void chomp(char *s); typedef enum { |