diff options
author | Thomas White <taw@physics.org> | 2010-03-05 10:55:57 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-03-05 10:55:57 +0100 |
commit | ac04881c50c140dbf7207363ed7e7400e186334b (patch) | |
tree | b23670dd4e73978806502ace16279800f04ba5fd | |
parent | 0f9498ed84f7b63c58e23012256fce1e3c46439c (diff) |
Read cell from PDB
-rw-r--r-- | src/sfac.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -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; } |