diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cell.c | 38 | ||||
-rw-r--r-- | src/cell.h | 4 | ||||
-rw-r--r-- | src/index.c | 7 |
3 files changed, 17 insertions, 32 deletions
@@ -569,7 +569,8 @@ static int same_vector(struct cvec a, struct cvec b) /* Attempt to make 'cell' fit into 'template' somehow */ -UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose) +UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose, + int reduce) { signed int n1l, n2l, n3l; double asx, asy, asz; @@ -582,6 +583,7 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose) UnitCell *new_cell = NULL; float best_fom = +999999999.9; /* Large number.. */ int ncand[3] = {0,0,0}; + signed int ilow, ihigh; float ltl = 5.0; /* percent */ float angtol = deg2rad(1.5); @@ -619,10 +621,16 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose) return NULL; } + if ( reduce ) { + ilow = -2; ihigh = 4; + } else { + ilow = 1; ihigh = 1; + } + /* Negative values mean 1/n, positive means n, zero means zero */ - for ( n1l=-2; n1l<=4; n1l++ ) { - for ( n2l=-2; n2l<=4; n2l++ ) { - for ( n3l=-2; n3l<=4; n3l++ ) { + for ( n1l=ilow; n1l<=ihigh; n1l++ ) { + for ( n2l=ilow; n2l<=ihigh; n2l++ ) { + for ( n3l=ilow; n3l<=ihigh; n3l++ ) { float n1, n2, n3; signed int b1, b2, b3; @@ -759,28 +767,6 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose) } -int cells_similar(UnitCell *cell1, UnitCell *cell2) -{ - double a1, b1, c1, al1, be1, ga1; - double a2, b2, c2, al2, be2, ga2; - double ltl = 5.0; /* percent */ - double angtol = deg2rad(1.5); - - cell_get_parameters(cell1, &a1, &b1, &c1, &al1, &be1, &ga1); - cell_get_parameters(cell2, &a2, &b2, &c2, &al2, &be2, &ga2); - - if ( !within_tolerance(a1, a2, ltl) ) return 0; - if ( !within_tolerance(b1, b2, ltl) ) return 0; - if ( !within_tolerance(c1, c2, ltl) ) return 0; - - if ( fabs(al1-al2) > angtol ) return 0; - if ( fabs(be1-be2) > angtol ) return 0; - if ( fabs(ga1-ga2) > angtol ) return 0; - - return 1; -} - - /* Return sin(theta)/lambda = 1/2d. Multiply by two if you want 1/d */ double resolution(UnitCell *cell, signed int h, signed int k, signed int l) { @@ -75,8 +75,8 @@ extern double resolution(UnitCell *cell, extern void cell_print(UnitCell *cell); -extern UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose); -extern int cells_similar(UnitCell *c1, UnitCell *c2); +extern UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose, + int reduce); extern UnitCell *load_cell_from_pdb(const char *filename); diff --git a/src/index.c b/src/index.c index f285cccb..bb725fcb 100644 --- a/src/index.c +++ b/src/index.c @@ -179,12 +179,11 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod indm, break; case CELLR_REDUCE : new_cell = match_cell(image->candidate_cells[i], - cell, verbose); + cell, verbose, 1); break; case CELLR_COMPARE : - if ( cells_similar(image->candidate_cells[i], cell) ) { - new_cell = image->candidate_cells[i]; - } + new_cell = match_cell(image->candidate_cells[i], + cell, verbose, 0); break; } |