aboutsummaryrefslogtreecommitdiff
path: root/src/cell.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-03-26 16:23:21 +0100
committerThomas White <taw@physics.org>2010-03-26 16:23:21 +0100
commit6a2ebece241fd5d1a82787b446d8eb7b273ae97e (patch)
tree4e60ef94a90351bbf2439b29fbc3284b8176e9a4 /src/cell.c
parent6a9811f69425e47b061f4987970681dbbf27a2bd (diff)
Don't try to render PDBs, part II: remove "molecule" from "struct image".
Diffstat (limited to 'src/cell.c')
-rw-r--r--src/cell.c42
1 files changed, 42 insertions, 0 deletions
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;
+}