From 7d0973929be8086954359f614a7da7dea6c549c7 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 3 Jun 2010 16:43:22 +0200 Subject: Configure PDB filename for get_hkl and pattern_sim --- src/get_hkl.c | 21 +++++++++++++++++---- src/pattern_sim.c | 18 ++++++++++++++++-- src/sfac.c | 4 ++-- src/sfac.h | 2 +- 4 files changed, 36 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/get_hkl.c b/src/get_hkl.c index ae279a8e..735ae52a 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -41,7 +41,9 @@ static void show_help(const char *s) " --zone-axis Generate hk0 intensities only (and add\n" " Synth2D-style header.\n" " -i, --intensities= Read intensities from file instead of\n" -" calculating them from scratch.\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" ); } @@ -114,6 +116,7 @@ int main(int argc, char *argv[]) unsigned int *cts; char *input = NULL; signed int h, k, l; + char *filename = NULL; /* Long options */ const struct option longopts[] = { @@ -124,11 +127,12 @@ int main(int argc, char *argv[]) {"twin", 0, &config_twin, 1}, {"zone-axis", 0, &config_za, 1}, {"intensities", 1, NULL, 'i'}, + {"pdb", 1, NULL, 'p'}, {0, 0, NULL, 0} }; /* Short options */ - while ((c = getopt_long(argc, argv, "ht:o:i:", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "ht:o:i:p:", longopts, NULL)) != -1) { switch (c) { case 'h' : { @@ -151,6 +155,11 @@ int main(int argc, char *argv[]) break; } + case 'p' : { + filename = strdup(optarg); + break; + } + case 0 : { break; } @@ -162,10 +171,14 @@ int main(int argc, char *argv[]) } - mol = load_molecule(); + if ( filename == NULL ) { + filename = strdup("molecule.pdb"); + } + + mol = load_molecule(filename); cts = new_list_count(); if ( input == NULL ) { - ideal_ref = get_reflections(mol, eV_to_J(1790.0), 1/(0.6e-9), cts); + ideal_ref = get_reflections(mol, eV_to_J(1790.0), 1/(0.05e-9), cts); } else { ideal_ref = read_reflections(input, cts); free(input); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index e09ab72a..cdc918b6 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -41,6 +41,9 @@ static void show_help(const char *s) "pulses of X-rays from a free electron laser.\n" "\n" " -h, --help Display this help message.\n" +" -p, --pdb= PDB file from which to get the unit cell.\n" +" (The actual Bragg intensities come from the\n" +" intensities file)\n" " --simulation-details Show technical details of the simulation.\n" " --gpu Use the GPU to speed up the calculation.\n" "\n" @@ -166,6 +169,7 @@ int main(int argc, char *argv[]) int config_nosfac = 0; int config_gpu = 0; int config_powder = 0; + char *filename = NULL; char *grad_str = NULL; GradientMethod grad; int ndone = 0; /* Number of simulations done (images or not) */ @@ -189,11 +193,12 @@ int main(int argc, char *argv[]) {"intensities", 1, NULL, 'i'}, {"powder", 0, &config_powder, 1}, {"gradients", 1, NULL, 'g'}, + {"pdb", 1, NULL, 'p'}, {0, 0, NULL, 0} }; /* Short options */ - while ((c = getopt_long(argc, argv, "hrn:i:g:", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "hrn:i:g:p:", longopts, NULL)) != -1) { switch (c) { case 'h' : { @@ -221,6 +226,11 @@ int main(int argc, char *argv[]) break; } + case 'p' : { + filename = strdup(optarg); + break; + } + case 0 : { break; } @@ -232,6 +242,10 @@ int main(int argc, char *argv[]) } + if ( filename == NULL ) { + filename = strdup("molecule.pdb"); + } + if ( config_simdetails ) { show_details(); return 0; @@ -282,7 +296,7 @@ int main(int argc, char *argv[]) image.width = 1024; image.height = 1024; image.lambda = ph_en_to_lambda(eV_to_J(1790.0)); /* Wavelength */ - cell = load_cell_from_pdb("molecule.pdb"); + cell = load_cell_from_pdb(filename); image.filename = NULL; #include "geometry-lcls.tmp" diff --git a/src/sfac.c b/src/sfac.c index 62c1e76e..aa7b3bf6 100644 --- a/src/sfac.c +++ b/src/sfac.c @@ -311,7 +311,7 @@ static void centre_molecule(struct molecule *mol) /* Load PDB file into a memory format suitable for efficient(ish) structure * factor calculation */ -struct molecule *load_molecule() +struct molecule *load_molecule(const char *filename) { struct molecule *mol; FILE *fh; @@ -327,7 +327,7 @@ struct molecule *load_molecule() mol->reflections = NULL; mol->cell = NULL; - fh = fopen("molecule.pdb", "r"); + fh = fopen(filename, "r"); if ( fh == NULL ) { ERROR("Couldn't open PDB file\n"); return NULL; diff --git a/src/sfac.h b/src/sfac.h index f6b4874f..54104700 100644 --- a/src/sfac.h +++ b/src/sfac.h @@ -58,7 +58,7 @@ struct molecule /* This is so that the water background calculation can use it */ extern double complex get_sfac(const char *n, double s, double en); -extern struct molecule *load_molecule(void); +extern struct molecule *load_molecule(const char *filename); extern void free_molecule(struct molecule *mol); extern double *get_reflections(struct molecule *mol, double en, double res, unsigned int *counts); -- cgit v1.2.3