aboutsummaryrefslogtreecommitdiff
path: root/src/sfac.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-03-05 10:55:57 +0100
committerThomas White <taw@physics.org>2010-03-05 10:55:57 +0100
commitac04881c50c140dbf7207363ed7e7400e186334b (patch)
treeb23670dd4e73978806502ace16279800f04ba5fd /src/sfac.c
parent0f9498ed84f7b63c58e23012256fce1e3c46439c (diff)
Read cell from PDB
Diffstat (limited to 'src/sfac.c')
-rw-r--r--src/sfac.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/sfac.c b/src/sfac.c
index d758fa08..0e8b9382 100644
--- a/src/sfac.c
+++ b/src/sfac.c
@@ -324,14 +324,6 @@ struct molecule *load_molecule()
mol->n_species = 0;
mol->reflections = NULL;
- /* FIXME: Read cell from file */
- mol->cell = cell_new_from_parameters(28.10e-9,
- 28.10e-9,
- 16.52e-9,
- deg2rad(90.0),
- deg2rad(90.0),
- deg2rad(120.0));
-
fh = fopen("molecule.pdb", "r");
if ( fh == NULL ) {
ERROR("Couldn't open PDB file\n");
@@ -349,6 +341,21 @@ struct molecule *load_molecule()
rval = fgets(line, 1023, fh);
+ if ( strncmp(line, "CRYST1", 6) == 0 ) {
+
+ float a, b, c, al, be, ga;
+
+ r = sscanf(line+7, "%f %f %f %f %f %f",
+ &a, &b, &c, &al, &be, &ga);
+
+ mol->cell = cell_new_from_parameters(a*1e-10,
+ b*1e-10, c*1e-10,
+ deg2rad(al),
+ deg2rad(be),
+ deg2rad(ga));
+
+ }
+
/* Only interested in atoms */
if ( strncmp(line, "HETATM", 6) != 0 ) continue;
@@ -427,6 +434,11 @@ struct molecule *load_molecule()
// mol->species[i]->n_atoms);
}
+ if ( mol->cell == NULL ) {
+ ERROR("No unit cell found in PDB file\n");
+ return NULL;
+ }
+
return mol;
}