From 1f6fc155eca22806f7280ace99ae281d57ba88d9 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 28 Jul 2011 12:01:01 +0200 Subject: partial_sim: Add "-r" option for specifying the filename for the random intensities --- src/partial_sim.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/partial_sim.c') diff --git a/src/partial_sim.c b/src/partial_sim.c index 04838552..79c2f832 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -120,14 +120,16 @@ static void show_help(const char *s) " -h, --help Display this help message.\n" "\n" "You need to provide the following basic options:\n" -" -i, --input= Read reflections from .\n" -" -o, --output= Write partials in stream format to .\n" -" -g. --geometry= Get detector geometry from file.\n" -" -b, --beam= Get beam parameters from file\n" -" -p, --pdb= PDB file from which to get the unit cell.\n" +" -i, --input= Read reflections from .\n" +" Default: generate random ones instead (see -r).\n" +" -o, --output= Write partials in stream format to .\n" +" -g. --geometry= Get detector geometry from file.\n" +" -b, --beam= Get beam parameters from file\n" +" -p, --pdb= PDB file from which to get the unit cell.\n" "\n" -" -y, --symmetry= Symmetry of the input reflection list.\n" -" -n Simulate patterns. Default: 2.\n" +" -y, --symmetry= Symmetry of the input reflection list.\n" +" -n Simulate patterns. Default: 2.\n" +" -r, --save-random= Save randomly generated intensities to file.\n" ); } @@ -152,6 +154,7 @@ int main(int argc, char *argv[]) int n = 2; int i; int random_intensities = 0; + char *save_file = NULL; /* Long options */ const struct option longopts[] = { @@ -162,11 +165,12 @@ int main(int argc, char *argv[]) {"pdb", 1, NULL, 'p'}, {"geometry", 1, NULL, 'g'}, {"symmetry", 1, NULL, 'y'}, + {"save-random", 1, NULL, 'r'}, {0, 0, NULL, 0} }; /* Short options */ - while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:n:", + while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:n:r:", longopts, NULL)) != -1) { switch (c) { @@ -202,13 +206,16 @@ int main(int argc, char *argv[]) n = atoi(optarg); break; + case 'r' : + save_file = strdup(optarg); + break; + case 0 : break; default : return 1; } - } /* Load beam */ @@ -251,6 +258,8 @@ int main(int argc, char *argv[]) sym = get_pointgroup(sym_str); free(sym_str); + if ( save_file == NULL ) save_file = strdup("partial_sim.hkl"); + /* Load (full) reflections */ if ( input_file != NULL ) { @@ -336,8 +345,8 @@ int main(int argc, char *argv[]) } if ( random_intensities ) { - STATUS("Writing full intensities to partial_sim.hkl\n"); - write_reflist("partial_sim.hkl", full, cell); + STATUS("Writing full intensities to %s\n", save_file); + write_reflist(save_file, full, cell); } fclose(ofh); -- cgit v1.2.3