aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-08-16 15:44:35 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:55 +0100
commit02e1ef093dc34e79e832764029db838cd5c13261 (patch)
tree959fb50440d764a44092a9f53d35a8999283487b /src
parent7cac57dd3a4fe1e2be8102c03e4fad0fa997273e (diff)
Read symmetry from PDB and store in unit cell structure
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in7
-rw-r--r--src/cell.c33
-rw-r--r--src/cell.h2
-rw-r--r--src/utils.c14
-rw-r--r--src/utils.h2
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
diff --git a/src/cell.c b/src/cell.c
index cc252b70..d6464a71 100644
--- a/src/cell.c
+++ b/src/cell.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 );
diff --git a/src/cell.h b/src/cell.h
index 42ef2eb6..f44de74f 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -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 {