From 02e1ef093dc34e79e832764029db838cd5c13261 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 16 Aug 2010 15:44:35 +0200 Subject: Read symmetry from PDB and store in unit cell structure --- src/cell.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/cell.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 ); -- cgit v1.2.3