Skip to content

Instantly share code, notes, and snippets.

@biochem-fan
Created November 28, 2022 11:47
Show Gist options
  • Save biochem-fan/51bedca55b6ab7cd75d103c7ef58376a to your computer and use it in GitHub Desktop.
Save biochem-fan/51bedca55b6ab7cd75d103c7ef58376a to your computer and use it in GitHub Desktop.
MicroED scripts
#!/bin/bash
JOB=$1
for f in */$1/dials.scale.log; do
DIR=`dirname $f | cut -d/ -f1,2`
awk '/cc_ano/ {f=1; b=999; next}
f==1 && $13 > 0.3 {b = $2;}
f==1 && $13 <= 0.3 {printf FILENAME" "b" "; exit}' $f
grep "Best sol" $DIR/dials.cosym.log| tr -d '\n'
grep Unit $DIR/dials.integrate.log
done | grep scale
#!/bin/bash
# The list of files is created by:
# ls images/| cut -d_ -f 3,4 |tee LIST
# Then this script is executed in parallel:
# parallel -P8 --ungroup bash process_P1.sh < LIST
if [ -e $1/P1 ]; then
echo $1 has been already processed
exit
fi
mkdir -p $1/P1
cd $1/P1
rm -fr {indexed,refined,integrated,symmetrized,scaled}.{expt,refl} image.emd
ln -sf "../../images/Camera_Ceta_"*"$1_670_mm.emd" image.emd
dials.import image.emd mask=../../pixels.mask panel.pedestal=-40 distance=618 fast_slow_beam_centre=1050,1002 # image_range=$2
dials.find_spots imported.expt gain=0.1 max_separation=4 nproc=4
#dials.search_beam_position imported.expt strong.refl
#dials.find_rotation_axis optimised.expt strong.refl # just for check
if [ ! -f optimised.expt ]; then
cp imported.expt optimised.expt
fi
dials.index optimised.expt strong.refl detector.fix=distance #space_group=P2 # unit_cell=5,10,20,90,90,90
if [ ! -f indexed.expt ]; then
dials.index optimised.expt strong.refl detector.fix=distance indexing.method=fft1d #space_group=P2 # unit_cell=5,10,20,90,90,90
fi
#if [ ! -f indexed.expt ]; then
# dials.index imported.expt strong.refl detector.fix=distance indexing.method=real_space_grid_search #space_group=P2 # unit_cell=5,10,20,90,90,90
#fi
if [ ! -f indexed.expt ]; then
exit
fi
dials.refine indexed.expt indexed.refl scan_varying=False detector.fix=distance
dials.refine refined.expt refined.refl scan_varying=True detector.fix=distance
dials.integrate refined.expt refined.refl prediction.d_min=0.8 nproc=4
if [ ! -f integrated.expt ]; then
exit
fi
dials.check_indexing_symmetry integrated.{expt,refl} d_min=1.2 d_max=6 grid=2
dials.cosym integrated.expt integrated.refl
dials.scale integrated.expt integrated.refl d_min=0.9 json=scaled.json
cd ..
#!/bin/sh
# Our data layout is:
# PROJECT_NAME/
# navigator items, montage files
# crystal images
# raw/ <--- Verlox writes here (uncompressed EMDs)
# compressed <--- This scripts writes compressed EMDs here
#
# This script is called as:
# while true; do find -name '*.emd*' -mmin +3 | parallel -P16 bash ~/prog/scripts/repack_emd.sh {} ../compressed/\`echo {} \| sed -e 's,\ ,_,g'\`; sleep 10; done&
# -mmin +3 is to prevent processing files being recorded.
# But this might not be necessary, because Verlox locks files anyway...
#
# The compressed files are then retrieved by the processing node.
# while true; do rsync -avuP --exclude raw --exclude '*.tmp' talos-otf:/mnt/falcon/USER/PROJECT_NAME . ; sleep 90; done&
if [ "$#" -ne 2 ]; then
echo "Usage: repack_emd input.emd output.emd"
exit
fi
if [ -f "$2" ]; then
echo "Output file $2 already exists."
exit
fi
rm -fr "$2.tmp"
/home/talos_admin/.local/dials-v3-9-2/conda_base/bin/h5repack -f SHUF -f GZIP=4 "$1" "$2.tmp"
mv "$2.tmp" "$2"
@biochem-fan
Copy link
Author

Please note that further updates to these scripts will be posted to https://github.com/GKLabIPR/MicroED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment