L498 Thermolysin

From cctbx_xfel
Jump to: navigation, search

In this tutorial, we assume that we are handed an SFX dataset containing thermolysin diffraction, but are not told anything else. We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology. At this point, we will be prepared to integrate and merge the data. Finally, we will perform simple molecular replacement and ask whether there is any Zn signal in the anomalous difference Fourier.

Discovery of data collection parameters

Log in to pslogin.slac.stanford.edu, and then to psana. Carry through flags so that X-windows will work

ssh -YAC $USER@pslogin.slac.stanford.edu
ssh -YAC psana

Go in to the working directory and source the package manager:

cd ~/myrelease

Create a subdirectory for the 2014 tutorial files if not already done:

mkdir -p cxi84914

List out the thermolysin XTC files:

ls /reg/d/psdm/cxi/cxi84914/xtc/e157

Notice that there are numerous runs in the directory. Now we will create composite averages for each run. Grab this configuration file: mkdark.cfg and put it in your cxi84914 directory. For one run only:

cxi.lsf -c ~/myrelease/cxi84914/mkdark.cfg \
-o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/ \
-i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r 16 -t 0

Take note:

  • -c configuration file
  • -o output directory (will be created)
  • -i input files (directory containing the XTC streams)
  • -q which batch queue to use
  • -s funnel all streams for the run into one node (takes longer, but necessary for averaging)
  • -p number of cores to use on the node
  • -x which experiment number
  • -r which run number
  • -t which processing trial (auto increments from 0 if not given)

For all the runs in the thermolysin data set:

for m in 16 17 18 19 20 21 22 23 24 25 26 27 31 71 72 73; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r ${m} -t 0; done

bjobs lists all your batch jobs; use this form for more information including other-user load:

bjobs -w -u all -q psanacsq
bkill [number] # stops unwanted job

Some runs take up to 2 hrs wall time to average. Find the averages, view the max-composites, and list out header information:

ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000/out/*.pickle
cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000 -name "max*.pickle"`
for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000 -name "max*.pickle"`; 
 do echo $m; cxi.print_pickle $m; echo; done

Let's make a table of the results:

Run Distance Wavelength Diffraction Comments Events Wall clock
000 psanacsq
6 cores
Wall clock
001 psanaq
6 cores
16 271.0 1.2686 weak powder 39313 60:36 36:20
17 221.0 1.2686 weak powder 66647 72:32 62:16
18 221.0 1.2686 weak powder 47297 77:21 45:28
19 221.0 1.2686 weak powder
20 221.0 1.2686 strong powder
21 171.0 1.2686 strong powder shadow
22 171.0 1.2686 strong powder shadow
23 171.0 1.2686 strong powder shadow
24 171.0 1.2686 strong powder shadow
25 171.0 1.2686 strong powder shadow
26 171.0 1.2686 strong powder shadow
27 171.0 1.2686 strong powder shadow
31 570.9 1.2686 Dark
71 271.0 1.2966 weak powder
72 131.0 1.2966 weak powder shadow
73 131 1.2966 strong powder shadow

Some conclusions:

  • Run 31 was the dark run. We'll use the average and standard deviation for further processing. Tutorial students can take result from the instructor's directory:
  • We are interested in getting the Zn anomalous signal from thermolysin, therefore we'll discard runs 71-73 collected at 1.2966 Angstroms, lower energy than the Zn K-edge at 9659 eV or 1.2836 Angstroms. See the X-ray handbook.
  • We'll also discard run 16 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.
  • We'll accept runs 17-20 ("calibration17"), and runs 21-27 ("calibration21").

Prepare to mask out the untrusted pixels

We'll now calculate dark-subtracted averages.

for m in 17 18 19 20 21 22 23 24 25 26 27; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e157.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r ${m} -t 0; done

This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted. The dark image to be subtracted (along with its std deviation) is defined in the configuration file mkavg_e157.cfg.

Now we'll figure out which pixels are untrusted, and thus should not be integrated. Three criteria will be used:

  • Hot pixels--on the average-dark the pixel values exceed 1350 (should be fine tuned by inspecting the dark & using trial and error)
  • Hot pixels--on the standard deviation-dark the stddev exceeds 5 and therefore unreliable (also should be fine tuned by trial and error)
  • Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 20 here)
cxi.make_mask -v --maxproj_min 20 --avg_max 1350 --stddev_max 5 --output mask_base.pickle \
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \

Inspect the mask:

cctbx.image_viewer mask_base.pickle show_untrusted=true

Simple thresholding wasn't sufficient for capturing some shadow areas and also an apparent untrusted region in one of the ASICs. Calculate some additional masks using the polygon feature; tied to our current metrology. Reading off polygon vertices from the cctbx.image_viewer, be sure to read coordinates as fast,slow (reverse order).

cxi.make_mask -v --poly_mask=1258,83,1148,9,1258,9 --output=mask_inactive.pickle -a 3000 -s 100 -m 0 \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \

Shadow on runs 17-20:

cxi.make_mask -v --poly_mask=915,1696,712,1719,506,1750,915,1750 --output=mask_shadow17.pickle -a 3000 -s 100 -m 0 \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \

Shadow on runs 21-27:

cxi.make_mask -v  --output=mask_shadow21.pickle -a 3000 -s 100 -m 0 \
 --poly_mask=1741,1536,1540,1518,1331,1506,1120,1505,918,1515,712,1550,496,1576,286,1629,86,1685,86,1754,1741,1754 \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \

Combine three masks together for runs 17-20:

cxi.or_mask mask_base.pickle mask_inactive.pickle mask_shadow17.pickle \

Combine three masks together for runs 21-27:

cxi.or_mask mask_base.pickle mask_inactive.pickle mask_shadow21.pickle \

Correct the detector metrology

Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology). Gaining this knowledge is especially difficult due to the segmented nature of the CSPAD detector, which is tiled into 64 application-specific integrated circuits (ASICs). The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor. The sensors are field-serviceable, and may therefore change from Run to Run.

We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:

  • Tile placement in physical space is measured by the beamline operators optically using electron microscopy. This is done at the per-sensor level (2 ASICs per sensor). This is already hard-coded; nothing for the user to do.
  • Relative positions of the quadrants are determined coarsely by considering powder rings.
  • Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.
  • ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.

Quadrant positions

The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space. At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole. The quadrant placement should be assessed for both the forward and back (DS2) detectors.

For thermolysin we examine one of the strong images (maximum composite). Students may use the instructor's files ($USER=nksauter). We first determine that our image has a timestamp that identifies it within cctbx as being from run 5 (2011):

cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle 
 > Detector format version: CXI 5.1
cxi.detector_format_versions "CXI 5.1"
cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle \
 distl.detector_format_version="CXI 5.1" viewer.calibrate_unitcell.d_min=10 \
 viewer.calibrate_unitcell.unitcell=94,94,130.8,90,90,120 viewer.calibrate_unitcell.spacegroup=P6122

The "Settings" GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to "CXI 5.1", namely -3,-1,-1,-5,-13,2,-7,-4. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=-3,-1,-1,-5,-13,2,-7,-4). The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters. It can be seen that the alignment is not quite perfect.

Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:

cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle \
 distl.detector_format_version="CXI 5.1"
> The NEW QUAD translations are: [-4, -4, -1, -7, -13, 1, -7, -6]

Try a few different max-composites from runs 21-24:

The NEW QUAD translations are: [-4, -5, -2, -7, -12, 0, -7, -5]

The NEW QUAD translations are: [-3, -4, -1, -7, -12, 0, -7, -5]

The NEW QUAD translations are: [-3, -3, -4, -6, -12, 0, -7, -5]

The NEW QUAD translations are: [-3, -3, -1, -7, -11, 0, -6, -3]

These can be pasted on to the command line for graphical review:

cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle \
 distl.detector_format_version="CXI 5.1" viewer.calibrate_unitcell.d_min=10 \
 viewer.calibrate_unitcell.unitcell=94,94,130.8,90,90,120 viewer.calibrate_unitcell.spacegroup=P6122 \

This looks slightly better. From the GUI it also appears that distance=176 fits better than distance=171; meaning that the detz_offset for the configuration file should be 576, not 571.

Unit-pixel tile positions

Now we will index the data to derive model lattices. [The configuration file L498-thermolysin-17.cfg names our phil parameter file L498-thermolysin-t000.phil (t000 means trial 0)]. We'll then compare model and observation, from which we can deduce better metrology.

for m in 17 18 19 20; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-17.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 0; done
for m in 21 22 23 24 25 26 27; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 0; done
bkill 0 # stop all jobs; wrong file path

A quick command to count how many integration files there are:

for m in `seq 17 27`; \
do echo $m `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r00$m/000/integration -name "int*.pickle"|wc -l` ; done; \
find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/*/000/integration -name "int*.pickle"|wc -l

Determine whole-pixel translations for all sensors on the CSPAD.

cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r*/000/integration bravais_setting_id=12 max_frames=1000 min_count=25 detector_format_version="CXI 5.1" cxi84914/L498-thermolysin-t000.phil | tee L498-17-t000.unit

List out the new unit translations:

cat L498-17-t000.unit |grep -A21 "Unit translations"

Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, L498-thermolysin-t001.phil. Also in this phil file, for the next integration round we'll increase our integration limits (3 places) to 1.8 Angstroms. After editing the configuration file to use this new phil file, submit the new round of integration jobs.

For the purpose of the tutorial, we'll drop runs 17-20 since they contribute only 1095 lattices compared with >18000 for runs 21-27. Fine-tuning of the metrology for runs 17-20 would have to be performed separately since the detector is at a different distance.

for m in 21 22 23 24 25 26 27; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 1; done

Another round of metrology refinement, this time using trial 001 as the basis:

cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r002[1-7]/001/integration bravais_setting_id=12 max_frames=1000 min_count=25 detector_format_version="CXI 5.1" cxi84914/L498-thermolysin-t001.phil | tee L498-21-t001.unit

…proving we have not yet converged. Take this output and construct trial 002: L498-thermolysin-t002.phil; edit the *.cfg file. Submit another round of integration jobs:

for m in 21 22 23 24 25 26 27; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 2; done

Evaluate metrology again:

cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r002[1-7]/002/integration bravais_setting_id=12 max_frames=1500 min_count=25 detector_format_version="CXI 5.1" cxi84914/L498-thermolysin-t002.phil | tee L498-21-t002.unit

Add sub-pixel corrections

There are negligible changes in the unit-translations (non-zero only at large radius), and the rmsd is now 0.96 pixels. We'll leave the unit-translations exactly where they are now, and add subpixel translations and rotations to the phil file. These are taken from the very end of the log file (L498-21-t002.unit). Incorporate these into L498-thermolysin-t003.phil.

Integrate the data

We're ready for the final integration trial, which will be t003. Again edit the configuration file L498-thermolysin-21.cfg so that it points to the latest phil file, L498-thermolysin-t003.phil. Submit integration jobs:

for m in 21 22 23 24 25 26 27; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 3; done

…19980 lattices indexed and integrated. If the second lattice is desired (about 10% of images have two) set indexing.outlier_detection.switch=True in the phil file, and integrate again under a new trial number (-t 4).

Trial 005: Try first-lattice again, correcting an omission of the mask_pixel_value=-2 phil parameter in trial 003.

…19987 lattices indexed and integrated in trial 005.

Merge the data

on pslogin, download the reference structure 2tli from the pdb (must be done on pslogin, the only outward-facing host). 2tli.pdb will be used for per-image scaling; 2tli.mtz will be used for reporting correlation to isomorphous synchrotron data.

phenix.fetch_pdb --mtz 2tli

back to psana. Get the command file mergethermo.csh.

mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157
cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157

Log file

Better log file from trial 005--using untrusted pixel mask

Solve the structure

Some quick commands to evaluate the data. Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:

cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME
cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME

Always use the "s0" files; "s1" and "s2" are the semi-datasets used only to calculate CC1/2.

phenix.fetch_pdb --mtz 2tli
phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs > triage_noanom.log

Wilson B factor:14.8

phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False

The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.

Obtain the set of R-free-flags used in the Nature Methods paper

wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz

Refine the model

phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \
 xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \
 xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \
 xray_data.r_free_flags.label=R-free-flags \
 main.number_of_macro_cycles=6 optimize_xyz_weight=True \
 optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \
 ordered_solvent=true ordered_solvent.mode=every_macro_cycle

trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom

trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)

Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.

libtbx.python map_height_at_atoms.py \
 001_001.pdb thermoanom_2tli_s0_mark0.mtz \
 input.xray_data.labels=Iobs \
 xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \

Promising results for the Zn and one Ca:

pdb="ZN    ZN A 317 " :   5.97 sigma
pdb="CA    CA A 318 " :   0.93 sigma
pdb="CA    CA A 319 " :   2.74 sigma
pdb="CA    CA A 320 " :   1.08 sigma
pdb="CA    CA A 321 " :   0.20 sigma

Better results from trial 005:

pdb="ZN    ZN A 317 " :   7.66 sigma
pdb="CA    CA A 318 " :   1.10 sigma
pdb="CA    CA A 319 " :   2.52 sigma
pdb="CA    CA A 320 " :   1.40 sigma
pdb="CA    CA A 321 " :   1.01 sigma