From 6a2ebece241fd5d1a82787b446d8eb7b273ae97e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 26 Mar 2010 16:23:21 +0100 Subject: Don't try to render PDBs, part II: remove "molecule" from "struct image". --- src/cell.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/cell.c') diff --git a/src/cell.c b/src/cell.c index 721756c9..42f34dfa 100644 --- a/src/cell.c +++ b/src/cell.c @@ -615,3 +615,45 @@ double resolution(UnitCell *cell, signed int h, signed int k, signed int l) return oneoverd / 2; } + + +UnitCell *load_cell_from_pdb(const char *filename) +{ + FILE *fh; + char *rval; + UnitCell *cell = NULL; + + fh = fopen(filename, "r"); + + do { + + char line[1024]; + + rval = fgets(line, 1023, fh); + + if ( strncmp(line, "CRYST1", 6) == 0 ) { + + float a, b, c, al, be, ga; + int r; + + r = sscanf(line+7, "%f %f %f %f %f %f", + &a, &b, &c, &al, &be, &ga); + if ( r != 6 ) { + ERROR("Couldn't understand CRYST1 line\n"); + return NULL; + } + + cell = cell_new_from_parameters(a*1e-10, + b*1e-10, c*1e-10, + deg2rad(al), + deg2rad(be), + deg2rad(ga)); + + } + + } while ( rval != NULL ); + + fclose(fh); + + return cell; +} -- cgit v1.2.3