From 32d4f204e33f0ad1d26545654d893928c5e0a142 Mon Sep 17 00:00:00 2001 From: Helen Ginn Date: Sat, 21 Apr 2018 12:49:55 +0100 Subject: Theoretical vectors have their own structure including whether they are in the asymmetric unit --- libcrystfel/src/taketwo.c | 111 +++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 65 deletions(-) diff --git a/libcrystfel/src/taketwo.c b/libcrystfel/src/taketwo.c index b2c3fdef..2776a352 100644 --- a/libcrystfel/src/taketwo.c +++ b/libcrystfel/src/taketwo.c @@ -118,15 +118,22 @@ struct SpotVec { struct rvec obsvec; - struct rvec *matches; + struct TheoryVec *matches; int match_num; - struct rvec *asym_matches; - int asym_match_num; double distance; struct rvec *her_rlp; struct rvec *his_rlp; }; +/** + * theoryvec + */ + +struct TheoryVec +{ + struct rvec vec; + int asym; +}; struct taketwo_private { @@ -639,8 +646,8 @@ static int obs_vecs_match_angles(struct SpotVec *her_obs, for ( i=0; imatch_num; i++ ) { for ( j=0; jmatch_num; j++ ) { - struct rvec *her_match = &her_obs->matches[i]; - struct rvec *his_match = &his_obs->matches[j]; + struct rvec *her_match = &her_obs->matches[i].vec; + struct rvec *his_match = &his_obs->matches[j].vec; double theory_angle = rvec_angle(*her_match, *his_match); @@ -739,8 +746,8 @@ static signed int finish_solution(gsl_matrix *rot, struct SpotVec *obs_vecs, struct rvec i_obsvec = i_vec.obsvec; struct rvec j_obsvec = j_vec.obsvec; - struct rvec i_cellvec = i_vec.matches[match_members[i]]; - struct rvec j_cellvec = j_vec.matches[match_members[j]]; + struct rvec i_cellvec = i_vec.matches[match_members[i]].vec; + struct rvec j_cellvec = j_vec.matches[match_members[j]].vec; rotations[count] = generate_rot_mat(i_obsvec, j_obsvec, i_cellvec, j_cellvec, @@ -806,8 +813,8 @@ static int weed_duplicate_matches(struct SpotVec *her_obs, struct rvec i_obsvec = her_obs->obsvec; struct rvec j_obsvec = his_obs->obsvec; - struct rvec i_cellvec = her_obs->matches[her_match]; - struct rvec j_cellvec = his_obs->matches[his_match]; + struct rvec i_cellvec = her_obs->matches[her_match].vec; + struct rvec j_cellvec = his_obs->matches[his_match].vec; gsl_matrix *mat = generate_rot_mat(i_obsvec, j_obsvec, i_cellvec, j_cellvec, cell); @@ -885,18 +892,21 @@ static signed int find_next_index(gsl_matrix *rot, int *obs_members, struct SpotVec *me = &obs_vecs[i]; struct SpotVec *you = &obs_vecs[obs_members[j]]; - struct rvec you_cell = you->matches[match_members[j]]; + struct rvec you_cell = you->matches[match_members[j]].vec; struct rvec me_obs = me->obsvec; struct rvec you_obs = you->obsvec; int one_is_okay = 0; + /* Loop through all possible theoretical vector + * matches for the newcomer.. */ + for ( k=0; kmatch_num; k++ ) { gsl_matrix *test_rot; - struct rvec me_cell = me->matches[k]; + struct rvec me_cell = me->matches[k].vec; test_rot = generate_rot_mat(me_obs, you_obs, me_cell, you_cell, @@ -1058,8 +1068,8 @@ static int start_seed(int i, int j, int i_match, int j_match, rot_mat = generate_rot_mat(obs_vecs[i].obsvec, obs_vecs[j].obsvec, - obs_vecs[i].matches[i_match], - obs_vecs[j].matches[j_match], + obs_vecs[i].matches[i_match].vec, + obs_vecs[j].matches[j_match].vec, cell); /* Try to expand this rotation matrix to a larger network */ @@ -1256,10 +1266,9 @@ static int generate_rotation_sym_ops(struct TakeTwoCell *ttCell) return 1; } - struct sortme { - struct rvec v; + struct TheoryVec v; double dist; }; @@ -1271,9 +1280,9 @@ static int sort_func(const void *av, const void *bv) } -static int match_obs_to_cell_vecs(struct rvec *cell_vecs, int cell_vec_count, +static int match_obs_to_cell_vecs(struct TheoryVec *cell_vecs, int cell_vec_count, struct SpotVec *obs_vecs, int obs_vec_count, - int is_asymmetric, struct TakeTwoCell *cell) + struct TakeTwoCell *cell) { int i, j; @@ -1284,7 +1293,7 @@ static int match_obs_to_cell_vecs(struct rvec *cell_vecs, int cell_vec_count, for ( j=0; jtrace_tol))); } - success = match_obs_to_cell_vecs(asym_vecs, asym_vec_count, - obs_vecs, obs_vec_count, 1, &ttCell); - - success = match_obs_to_cell_vecs(cell_vecs, cell_vec_count, - obs_vecs, obs_vec_count, 0, &ttCell); + success = match_obs_to_cell_vecs(theory_vecs, cell_vec_count, + obs_vecs, obs_vec_count, &ttCell); - free(cell_vecs); - free(asym_vecs); + free(theory_vecs); if ( !success ) return NULL; -- cgit v1.2.3