/* * get_hkl.c * * Small program to write out a list of h,k,l,I values given a structure * * (c) 2006-2010 Thomas White * * Part of CrystFEL - crystallography with a FEL * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "utils.h" #include "sfac.h" #include "reflections.h" #include "symmetry.h" #include "beam-parameters.h" static void show_help(const char *s) { printf("Syntax: %s [options]\n\n", s); printf( "Create reflections lists.\n" "\n" " -h, --help Display this help message.\n" "\n" " -t, --template= Only include reflections mentioned in file.\n" " --poisson Simulate Poisson samples.\n" " --noise Add 10%% random noise.\n" " -y, --symmetry= The symmetry of the input file (-i).\n" " -w, --twin= Generate twinned data according to the given\n" " point group.\n" " -e, --expand= Expand reflections to this point group.\n" " -o, --output= Output filename (default: stdout).\n" " -i, --intensities= Read intensities from file instead of\n" " calculating them from scratch. You might use\n" " this if you need to apply noise or twinning.\n" " -p, --pdb= PDB file from which to get the structure.\n" " --no-phases Do not try to use phases in the input file.\n" " --multiplicity Multiply intensities by the number of\n" " equivalent reflections.\n" " -b, --beam= Get beam parameters from file (used for sigmas).\n" ); } /* Apply Poisson noise to all reflections */ static void poisson_reflections(double *ref, ReflItemList *items) { int i; const int n = num_items(items); for ( i=0; ih, it->k, it->l); c = poisson_noise(val); set_intensity(ref, it->h, it->k, it->l, c); progress_bar(i, n-1, "Simulating noise"); } } /* Apply 10% uniform noise to all reflections */ static void noise_reflections(double *ref, ReflItemList *items) { int i; const int n = num_items(items); for ( i=0; ih, it->k, it->l); r = (double)random()/RAND_MAX; val += 0.1 * val * r; set_intensity(ref, it->h, it->k, it->l, val); progress_bar(i, n-1, "Simulating noise"); } } static ReflItemList *twin_reflections(double *ref, ReflItemList *items, const char *holo, const char *mero, double *esds) { int i; ReflItemList *new; new = new_items(); if ( num_general_equivs(holo) < num_general_equivs(mero) ) { ERROR("%s is not a subgroup of %s!\n", mero, holo); return NULL; } for ( i=0; ih, it->k, it->l, &h, &k, &l, holo); if ( find_item(new, h, k, l) ) continue; n = num_equivs(h, k, l, holo); total = 0.0; sigma = 0.0; skip = 0; for ( j=0; j num_general_equivs(initial) ) { ERROR("%s is not a subgroup of %s!\n", initial, target); return NULL; } for ( i=0; ih; k = it->k; l = it->l; /* Actually we don't really care what the equivalent is, * we just want to be sure that there is nly be one version of * this reflection. */ find_unique_equiv(items, h, k, l, initial, &hd, &kd, &ld); /* Now find out how many reflections need to be filled in */ n = num_equivs(h, k, l, initial); intensity = lookup_intensity(ref, h, k, l); for ( j=0; jh, it->k, it->l); inty *= num_equivs(it->h, it->k, it->l, mero); set_intensity(ideal_ref, it->h, it->k, it->l, inty); STATUS("%i %i %i %i\n", it->h, it->k, it->l, num_equivs(it->h, it->k, it->l, mero)); } } if ( template ) { /* Write out only reflections which are in the template * (and which we have in the input) */ ReflItemList *template_items; template_items = read_reflections(template, NULL, NULL, NULL, NULL); write_items = intersection_items(input_items, template_items); delete_items(template_items); } else { /* Write out all reflections */ write_items = new_items(); /* (quick way of copying a list) */ union_items(write_items, input_items); } write_reflections(output, write_items, ideal_ref, esds, phases, NULL, cell); delete_items(input_items); delete_items(write_items); return 0; }