diff options
author | Thomas White <taw@physics.org> | 2010-08-16 15:44:35 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:26:55 +0100 |
commit | 02e1ef093dc34e79e832764029db838cd5c13261 (patch) | |
tree | 959fb50440d764a44092a9f53d35a8999283487b /src/cell.c | |
parent | 7cac57dd3a4fe1e2be8102c03e4fad0fa997273e (diff) |
Read symmetry from PDB and store in unit cell structure
Diffstat (limited to 'src/cell.c')
-rw-r--r-- | src/cell.c | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -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 ); |