aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-06-03 16:43:22 +0200
committerThomas White <taw@physics.org>2010-06-03 16:43:22 +0200
commit7d0973929be8086954359f614a7da7dea6c549c7 (patch)
treeb9006b54dbdd2080e9d3cbf73fefd24e5bc840f4
parent056de872eb5ba91f282b605d4bd425ac855acf11 (diff)
Configure PDB filename for get_hkl and pattern_sim
-rw-r--r--src/get_hkl.c21
-rw-r--r--src/pattern_sim.c18
-rw-r--r--src/sfac.c4
-rw-r--r--src/sfac.h2
4 files changed, 36 insertions, 9 deletions
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=<file> 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=<file> 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=<file> 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);