#!/bin/bash # Automated ShelxC/D/E for experimental phasing with unknown space group # Author: Petr Kolenko # Mail: petr.kolenko@fjfi.cvut.cz # Web: http://kmlinux.fjfi.cvut.cz/~kolenpe1/baSHELiXir # baSHELiXir depends on: Shelx C/D/E, gnuplot, bash # Please cite: P. Kolenko (2019). baSHELiXir: A Bash Script for Automated Experimental Phasing Using Shelx C/D/E. Chemicke listy, 113, 610-614. # Please cite: I. Uson & G.M. Sheldrick (2018), "An introduction to experimental phasing of macromolecules illustrated by SHELX; new autotracing features" Acta Cryst. D74, 106-116 (Open Access) if SHELXE proves useful. # Data for testing of the script were taken from tutorial and talks of Andrea Thorn: # http://shelx.uni-ac.gwdg.de/~athorn # http://shelx.uni-ac.gwdg.de/~athorn/data/shelxcde_tutorial.zip # Further data were taken from PHENIX tutorial for experimental phasing: # https://www.phenix-online.org/ screen=N wavelength=0.98 solmin=20 solmax=80 solnow=20 solstep=5 act=1 nproc=4 wdir=`pwd .` sfac=Se ntry=100 find=20 finished=N prefix=foo Epar="-a5 -m5 -h" curres= podo=0 PARAMS=$# NUM=$# if [ $NUM = 0 ]; then echo " +-+-+-+-+-+-+-+-+-+-+-+-+---+ |b|a|S|H|E|L|i|X|i|r| |v|1.9| +-+-+-+-+-+-+-+-+-+-+-+-+---+ " echo "Usage: $0 [params...]" echo "Params:" #Definition of input files: echo -e "\t-prefix foo \t\t\t Sets prefix as foo" echo -e "\t-output-dir path \t\t Sets output directory (must be created before)" echo -e "\t-podo \t\t\t\t Sets PODO color sequence for GNUplot (requires v.5)" echo -e "\t-sad foo.hkl \t\t\t Sets foo.hkl as a SAD dataset" echo -e "\t-nat foo.hkl \t\t\t Sets foo.hkl as a native dataset" echo -e "\t-peak foo.hkl \t\t\t Sets foo.hkl as a peak dataset" echo -e "\t-infl foo.hkl \t\t\t Sets foo.hkl as an inflection dataset" echo -e "\t-hrem foo.hkl \t\t\t Sets foo.hkl as a high remote dataset" echo -e "\t-lrem foo.hkl \t\t\t Sets foo.hkl as a low remote dataset" echo -e "\t-before foo.hkl \t\t Sets 'native' dataset for RIP phasing" echo -e "\t-after foo.hkl \t\t\t Sets dataset collected after the radiation damage" echo -e "\t-sira foo.hkl \t\t\t Sets SIRAS dataset" echo -e "\t-nproc N \t\t\t Sets N parallel processes in ShelxE routine" #Definition of ShelxC parameters echo -e "\t-sfac X \t\t\t Sets heavy element" echo -e "\t-find N \t\t\t Sets number of searched atoms" echo -e "\t-ntry N \t\t\t Sets number of trials to search for substructure" echo -e "\t--cell [a] [b] [c] ... \t Sets unit cell parameters: unit cell dimensions" echo -e "\t ... [alpha] [beta] [gamma] \t\t ... and angles" echo -e "\t-wavelength X \t\t\t Sets wavelength in Angstroms" echo -e "\t-res X Y \t\t\t Sets the low and the high resolution for phasing" echo -e "\t-dsul N \t\t\t Sets number disufides at lower resolution" echo -e "\t-mind \"X Y\" \t\t\t Sets the parameters for MIND" echo -e "\t-dsca X \t\t\t Sets the DSCA parameter for RIP or RIPAS" echo -e "\t-Epar \"par1 par2 ...\" \t\t Sets the ShelxE parameters (DO NOT FORGET \"\"!)" echo -e "\t------------------------------------------------------------------------------------------" echo -e "\t\t SCREENING AND PARALLELIZATION PARAMETERS" echo -e "\t-bravais xX \t\t\t Sets the Bravais-type (e.g. tP)" echo -e '\t-list "SG1 SG2 ..." \t\t Sets list of space groups to be examined' echo -e "\t-solv x X s \t\t\t Sets the minimal, maximal and with fraction steps" echo -e "\t\t\t\t\t\t(e.g. -solv 27 81 2)" echo -e "\t-solv_auto \t\t\t Screens the sol. cont. from 20% to 80% with 5% step width" echo -e "\t-fix_low X \t\t\t Sets the low resolution for the high-resolution screening" echo -e "\t-screen_high \"X Y Z ...\" \t Sets the high resolution limits for screening" echo -e "\t-fix_high X \t\t\t Sets the high resolution for the low-resolution screening" echo -e "\t-screen_low \"X Y Z ...\" \t Sets the low resolution limits for screening" echo -e "\t------------------------------------------------------------------------------------------" echo -e "\t\t Most frequent ShelxE parameters:" echo -e "\t\t-h \t\t heavy atoms are included in the native structure" echo -e "\t\t-hN \t\t when the nummber N of heavy atoms is known" echo -e "\t\t-aN \t\t runs N cycles of auto-tracing" echo -e "\t\t-q \t\t explicit search for helices" echo -e "\t\t-s[x] \t\t sets fraction of solvent content (e.g. -s0.45)" echo -e "\t\t-e \t\t runs free lunch algorithm (e.g. -e1.2)" echo -e "\t\t-z \t\t optimizes the heavy atom substructure before the density modif." echo -e "\t\t-mN \t\t N iterations of density modification per global cycle (e.g. -m5)" echo -e "################################################################################################" echo "Bravais-types (according to the XDS notation):" echo "aP: P1" echo "mP: P2, P21" echo "mC: C2" echo "oP: P222, P2221, P21212, P212121" echo "oC: C222, C2221" echo "oF: F222" echo "oI: I222, I212121" echo "tP: P4, P41, P42, P43, P422, P4212, P4122, P41212, P4222, P42212, P4322, P43212" echo "tI: I4, I41, I422, I4122" echo "hP: P3, P31, P32, P312, P321, P3112, P3121, P3212, P3221," echo -e " P6, P61, P65, P62, P64, P63, P622, P6122, P6522, P6222, P6422, P6322" echo "hR: R3, R32" echo "cP: P23, P213, P432, P4232, P4332, P4132" echo "cF: F23, F432, F4132" echo "cI: I23, I213, I432, I4132" echo "" echo "Alternative:" echo -e "\t -list \"SG1 SG2 ...\" \t sets list of space groups to be used in automated phasing" echo -e "################################################################################################" exit -1 fi if [ -z "$(which realpath 2>/dev/null)" ]; then realpath() { f=$@; if [ -d "$f" ]; then base=""; dir="$f"; else base="/$(basename "$f")"; dir=$(dirname "$f"); fi; dir=$(cd "$dir" && /bin/pwd); echo "$dir$base" } fi echo "Command: baSHELiXir $@" full_command=$@ while (($NUM > 0)); do case $1 in -prefix) prefix=$2 shift 1 ;; -output-dir) wdir=`realpath $2` shift 1 ;; -podo) podo=1 ;; -sad) sad=`realpath $2` shift 1 ;; -nat) nat=`realpath $2` shift 1 ;; -peak) peak=`realpath $2` shift 1 ;; -infl) infl=`realpath $2` shift 1 ;; -hrem) hrem=`realpath $2` shift 1 ;; -lrem) lrem=`realpath $2` shift 1 ;; -before) before=`realpath $2` shift 1 ;; -after) after=`realpath $2` shift 1 ;; -sira) sira=`realpath $2` shift 1 ;; -sfac) sfac=$2 shift 1 ;; -find) find=$2 shift 1 ;; -ntry) ntry=$2 shift 1 ;; --cell) cell_manual="$2 $3 $4 $5 $6 $7" shift 6 ;; -wavelength) wavelength_manual=$2 shift 1 ;; -res) resM=$2 resm=$3 shift 2 ;; -dsul) dsul=$2 shift 1 ;; -mind) mind=$2 shift 1 ;; -dsca) dsca=$2 shift 1 ;; -bravais) bravais_type=$2 shift 1 ;; -list) list=$2 shift 1 ;; -Epar) Epar=$2 shift 1 ;; -solv_auto) screen=Y ;; -solv) solmin=$2 solmax=$3 solstep=$4 screen=Y solnow=$solmin shift 3 ;; -fix_low) fix_low=$2 shift 1 ;; -screen_high) screen_high=$2 shift 1 ;; -fix_high) fix_high=$2 shift 1 ;; -screen_low) screen_low=$2 shift 1 ;; -nproc) nproc=$2 shift 1 ;; *) if [ -z "$1" ]; then : #echo "All parameters seem to be set." else echo "Parametr $(($PARAMS-$NUM+1)) unknown: $1" fi # exit ;; esac NUM=$(($NUM-1)); shift 1 done echo " +-+-+-+-+-+-+-+-+-+-+-+-+---+ |b|a|S|H|E|L|i|X|i|r| |v|1.9| +-+-+-+-+-+-+-+-+-+-+-+-+---+ " path_to_executable=$(which shelxc) #Check if executables are available if [ -x "$path_to_executable" ] ; then : else echo "########################################" echo "Binaries for Shelx are not in your path settings." exit fi path_to_gnuplot=$(which gnuplot) #Check if GNUplot is available if [ -x "$path_to_gnuplot" ] ; then : else echo "########################################" echo "GNUplot is not available." exit fi if [ -x "$wdir" ] ; then #Check if working directory exists. echo "Using directory: $wdir" else echo "########################################" echo "Working directory does not exist." echo "Please, create the directory. Exiting ..." exit fi if [ ! -z $sad ]; then if [[ $sad == *.sca ]]; then cell_all=`awk 'NR==3 {print $1 " " $2 " " $3 " " $4 " " $5 " " $6}' $sad` else cell_all=`grep UNIT_CELL_CONSTANTS $sad | awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $7}'` wavelength=`grep X-RAY_WAVELENGTH $sad | awk '{print $2}'` fi fi #for MAD if [ ! -z $peak ]; then if [[ $peak == *.sca ]]; then cell_all=`awk 'NR==3 {print $1 " " $2 " " $3 " " $4 " " $5 " " $6}' $peak` wavelength=$wavelength_manual else cell_all=`grep UNIT_CELL_CONSTANTS $peak | awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $7}'` wavelength=`grep X-RAY_WAVELENGTH $peak | awk '{print $2}'` fi fi #for RIP if [ ! -z $before ]; then if [[ $before == *.sca ]]; then cell_all=`awk 'NR==3 {print $1 " " $2 " " $3 " " $4 " " $5 " " $6}' $before` wavelength=$wavelength_manual else cell_all=`grep UNIT_CELL_CONSTANTS $before | awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $7}'` wavelength=`grep X-RAY_WAVELENGTH $before | awk '{print $2}'` fi fi #for SIRAS if [ ! -z $sira ]; then if [[ $sira == *.sca ]]; then cell_all=`awk 'NR==3 {print $1 " " $2 " " $3 " " $4 " " $5 " " $6}' $sira` wavelength=$wavelength_manual else cell_all=`grep UNIT_CELL_CONSTANTS $sira | awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $7}'` wavelength=`grep X-RAY_WAVELENGTH $sira | awk '{print $2}'` fi fi #for manual cell input if [[ ! -z $cell_manual ]]; then cell_all=$cell_manual wavelength=$wavelength_manual fi if [[ ! -z $wavelength_manual ]]; then wavelength=$wavelength_manual fi if [ -z $wavelength ]; then echo 'The wavelength is not set. The script needs your input, use parameter "-wavelength".' exit fi if [ -d "$wdir/results_$prefix" ]; #Check if results with the same prefix are already in the working directory. then echo "Directory results_$prefix already exists in directory $wdir . Change the prefix or delete the old files." echo "Exiting ..." exit fi #Reading out the unit cell parameters #for SAD function list_gen () { if [ "$bravais_type" == "aP" ]; then list="P1" elif [ "$bravais_type" == "mP" ]; then list="P2 P21" elif [ "$bravais_type" == "mC" ]; then list="C2" elif [ "$bravais_type" == "oP" ]; then list="P222 P2221 P2212 P2122 P21212 P21221 P22121 P212121" elif [ "$bravais_type" == "oC" ]; then list="C222 C2221" elif [ "$bravais_type" == "oF" ]; then list="F222" elif [ "$bravais_type" == "oI" ]; then list="I222 I212121" elif [ "$bravais_type" == "tP" ]; then list="P4 P41 P42 P43 P422 P4212 P4122 P41212 P4222 P42212 P4322 P43212" elif [ "$bravais_type" == "tI" ]; then list="I4 I41 I422 I4122" elif [ "$bravais_type" == "hP" ]; then list="P3 P31 P32 P312 P321 P3112 P3121 P3212 P3221 P6 P61 P65 P62 P64 P63 P622 P6122 P6522 P6222 P6422 P6322" elif [ "$bravais_type" == "hR" ]; then list="R3 R32" elif [ "$bravais_type" == "cP" ]; then list="P23 P213 P432 P4232 P4332 P4132" elif [ "$bravais_type" == "cF" ]; then list="F23 F432 F4132" elif [ "$bravais_type" == "cI" ]; then list="I23 I213 I432 I4132" fi } function shelx_c () { echo "Running ShelxC in $space_group" #cd $wdir/results_$prefix/$space_group shelxc `echo $space_group`_$prefix < `echo $space_group`_shelxc.inp > `echo $space_group`_`echo $prefix`_shelxc.log #curres= curres=`grep SHEL "$space_group"_"$prefix"_fa.ins | cut -c5-` echo "Current resolution is: $curres" #cd $wdir/results_$prefix } function file_prep () { if [ ! -z $sad ]; then echo "SAD `basename $sad`" >> $wdir/results_$prefix/files.txt cp $sad $wdir/results_$prefix/ fi if [ ! -z $nat ]; then echo "NAT `basename $nat`" >> $wdir/results_$prefix/files.txt cp $nat $wdir/results_$prefix/ fi if [ ! -z $peak ]; then echo "PEAK `basename $peak`" >> $wdir/results_$prefix/files.txt cp $peak $wdir/results_$prefix/ fi if [ ! -z $infl ]; then echo "INFL `basename $infl`" >> $wdir/results_$prefix/files.txt cp $infl $wdir/results_$prefix/ fi if [ ! -z $hrem ]; then echo "HREM `basename $hrem`" >> $wdir/results_$prefix/files.txt cp $hrem $wdir/results_$prefix/ fi if [ ! -z $lrem ]; then echo "LREM `basename $lrem`" >> $wdir/results_$prefix/files.txt cp $lrem $wdir/results_$prefix/ fi if [ ! -z $before ]; then echo "BEFORE `basename $before`" >> $wdir/results_$prefix/files.txt cp $before $wdir/results_$prefix/ fi if [ ! -z $after ]; then echo "AFTER `basename $after`" >> $wdir/results_$prefix/files.txt cp $after $wdir/results_$prefix/ fi if [ ! -z $sira ]; then echo "SIRA `basename $sira`" >> $wdir/results_$prefix/files.txt cp $sira $wdir/results_$prefix/ fi #Here is a check for a conflict in file names cut -f 2- -d ' ' files.txt > files-work1.txt sort files-work1.txt | uniq -c > files-work2.txt if [[ `grep -c "" files.txt` == `grep -c "" files-work2.txt` ]] then #echo "No conflict in file names" rm files-work1.txt files-work2.txt else echo "Conflict in files. Please supply files with different names. Exiting ... " rm files-work1.txt files-work2.txt exit fi } function c_prep () { echo "Running in space group $space_group ..." # mkdir $wdir/results_$prefix/$space_group cp files.txt $wdir/results_$prefix/`echo $space_group`_shelxc.inp echo "CELL $wavelength $cell_all " >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp echo "SPAG $space_group" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp # file_prep echo "FIND $find" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp echo "NTRY $ntry" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp echo "SFAC $sfac" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp if [ ! -z $mind ]; then echo "MIND $mind" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp fi if [ ! -z $dsul ]; then echo "DSUL $dsul" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp fi if [ ! -z $resm ]; then echo "SHEL $resM $resm" >> $wdir/results_$prefix/`echo $space_group`_shelxc.inp fi } #function c_clean () { # cd $wdir/results_$prefix/$space_group # for delete in $sad $peak $infl $hrem $lrem $nat $before $after $sira # do # rm `basename $delete` # done # cd $wdir/results_$prefix #} function c_graph () { # cd $wdir/results_$prefix/$space_group echo "set xrange [] reverse" > `echo $space_group`_`echo $prefix`_shelxc.gnuplot if [ $podo -ge 1 ]; then echo "set colorsequence podo" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo "set yrange [0:]" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot echo "set title ' vs. Resolution' font ',15'" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot echo "set terminal png size 800,400" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot echo "set output '"`echo $space_group`"_shelxc.png'" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot echo "set xlabel 'Resolution'" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot if [ ! -z $before ]; then echo "set ylabel ''" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot else echo "set ylabel ''" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo "plot " >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot for file in SAD PEAK INFL HREM LREM RIP SIRA; do if grep -q "from $file file" `echo $space_group`_`echo $prefix`_shelxc.log; then grep -A 10 "from $file file" `echo $space_group`_`echo $prefix`_shelxc.log | grep Resl | cut -c14- > `echo $prefix`_shelxc_`echo $file`_res.dat grep -A 12 "from $file file" `echo $space_group`_`echo $prefix`_shelxc.log | grep " `echo $prefix`_shelxc_`echo $file`_dif.dat fmt -1 `echo $prefix`_shelxc_`echo $file`_res.dat > `echo $prefix`_shelxc_`echo $file`_res.col fmt -1 `echo $prefix`_shelxc_`echo $file`_dif.dat > `echo $prefix`_shelxc_`echo $file`_dif.col paste `echo $prefix`_shelxc_`echo $file`_res.col `echo $prefix`_shelxc_`echo $file`_dif.col > `echo $prefix`_shelxc_`echo $file`_graph.dat sed -i '$ s/$/ '"'`echo $prefix`_shelxc_`echo $file`_graph.dat'"' using 1:2 with linespoints lw 2 ps 1 title '"'$file'"', /' `echo $space_group`_`echo $prefix`_shelxc.gnuplot rm *_res.* *_dif.* # New addition of removal of non-important things else : fi done sed -i '$ s/$/ 1 lw 2/' `echo $space_group`_`echo $prefix`_shelxc.gnuplot gnuplot < `echo $space_group`_`echo $prefix`_shelxc.gnuplot # cd $wdir/results_$prefix } function shelx_d () { # cd $wdir/results_$prefix/$space_group echo "Running ShelxD in $space_group" shelxd `echo $space_group`_`echo $prefix`_fa > `echo $space_group`_`echo $prefix`_shelxd.log #best=`grep SHEL "$prefix"_fa.ins | cut -c5-` best=`grep best "$space_group"_"$prefix"_shelxd.log | tail -1 | cut -c61- | awk '{print $1}'` echo "Best solution is: $best" grep Try `echo $space_group`_`echo $prefix`_shelxd.log | cut -c5- > `echo $space_group`_`echo $prefix`_shelxd.dat cat `echo $space_group`_`echo $prefix`_shelxd.dat | awk '{ print substr( $0, 28, 5 ) }' > ccall.dat cat `echo $space_group`_`echo $prefix`_shelxd.dat | awk '{ print substr( $0, 35, 5 ) }' > ccweak.dat cat `echo $space_group`_`echo $prefix`_shelxd.dat | awk '{ print substr( $0, 70, 7 ) }' > patfom.dat paste ccall.dat ccweak.dat patfom.dat > `echo $space_group`_shelxd.dat echo "set terminal png size 800,400" > `echo $space_group`_shelxd.gnuplot if [ $podo -ge 1 ]; then echo "set colorsequence podo" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo 'set title "CCall vs. CCweak" font ",15"' >> `echo $space_group`_shelxd.gnuplot echo "set output '"`echo $space_group`"_shelxd.png'" >> `echo $space_group`_shelxd.gnuplot echo "set xlabel 'CCweak'" >> `echo $space_group`_shelxd.gnuplot echo "set ylabel 'CCall'" >> `echo $space_group`_shelxd.gnuplot echo "plot '"`echo $space_group`"_shelxd.dat' using 2:1 with points ps 1.5 notitle" >> `echo $space_group`_shelxd.gnuplot echo "set output '"`echo $space_group`"_patfomVSccall.png'" >> `echo $space_group`_shelxd.gnuplot echo 'set title "PATFOM vs. CCall" font ",15"' >> `echo $space_group`_shelxd.gnuplot echo "set ylabel 'PATFOM'" >> `echo $space_group`_shelxd.gnuplot echo "set xlabel 'CCall'" >> `echo $space_group`_shelxd.gnuplot echo "plot '"`echo $space_group`"_shelxd.dat' using 3:1 with points ps 1.5 notitle" >> `echo $space_group`_shelxd.gnuplot gnuplot < `echo $space_group`_shelxd.gnuplot grep HETATM `echo $space_group`_`echo $prefix`_fa.pdb > `echo $space_group`_sites_only.pdb echo "set terminal png size 800,400" > `echo $space_group`_shelxd_sites.gnuplot if [ $podo -ge 1 ]; then echo "set colorsequence podo" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo 'set title "Sites occupancy vs. site number" font ",15"' >> `echo $space_group`_shelxd_sites.gnuplot echo "set xlabel 'Site number'" >> `echo $space_group`_shelxd_sites.gnuplot echo "set ylabel 'Site occupancy'" >> `echo $space_group`_shelxd_sites.gnuplot echo "set output '"`echo $space_group`"_shelxd_occupancy.png'" >> `echo $space_group`_shelxd_sites.gnuplot echo "plot '"`echo $space_group`"_sites_only.pdb' using 2:9 with linespoints lw 2 ps 1 notitle" >> `echo $space_group`_shelxd_sites.gnuplot gnuplot < `echo $space_group`_shelxd_sites.gnuplot # cd $wdir/results_$prefix } function html_shelxe_prep () { if [ -f `echo $html_space_group`_`echo $prefix`.pdb ]; then cp `echo $html_space_group`_`echo $prefix`.pdb `echo $html_space_group`_original.pdb else touch `echo $html_space_group`_original.pdb fi if [ -f `echo $html_space_group`_`echo $prefix`_i.pdb ]; then cp `echo $html_space_group`_`echo $prefix`_i.pdb `echo $html_space_group`_inverted.pdb else touch `echo $html_space_group`_inverted.pdb fi echo "original: " > `echo $html_space_group`_textik grep -c "AT" `echo $html_space_group`_original.pdb >> `echo $html_space_group`_textik echo "inverted: " >> `echo $html_space_group`_textik grep -c "AT" `echo $html_space_group`_inverted.pdb >> `echo $html_space_group`_textik } function shelx_e_screen () { echo "Running ShelxE in $space_group" echo "Screening in various solvent fractions ..." while [ $solnow -le $solmax ] do while [ $act -le $nproc ]; #parallelization of original hand do if [ $solnow -le $solmax ]; then ln -s `echo $space_group`_`echo $prefix`.hkl `echo $space_group`_solvent_$solnow.hkl shelxe `echo $space_group`_solvent_$solnow `echo $space_group`_`echo $prefix`_fa $Epar -s0.$solnow > `echo $space_group`_`echo $prefix`_shelxe-orig-solvent0.$solnow.log & fi solnow=$[$solnow+$solstep] act=$[$act+1] done act=1 wait done solnow=$solmin #prepares the value of solnow for the inverted hand ShelxE calculations while [ $solnow -le $solmax ]; do while [ $act -le $nproc ]; #parallelization of inverted hand do if [ $solnow -le $solmax ]; #check for the maximal solvent value then shelxe `echo $space_group`_solvent_$solnow `echo $space_group`_`echo $prefix`_fa -i $Epar -s0.$solnow > `echo $space_group`_`echo $prefix`_shelxe-inv-solvent0.$solnow.log & fi solnow=$[$solnow+$solstep] act=$[$act+1] done act=1 wait done solnow=$solmin echo "Run in $space_group finished." } function shelx_e_graph () { while [ $solnow -le $solmax ]; do if [ ! -f `echo $space_group`_solvent_`echo $solnow`.pdb ]; #check if output exists then touch `echo $space_group`_solvent_`echo $solnow`.pdb fi if [ ! -f `echo $space_group`_solvent_`echo $solnow`.phs ]; then touch `echo $space_group`_solvent_`echo $solnow`.phs fi if [ ! -f `echo $space_group`_solvent_`echo $solnow`_i.pdb ]; then touch `echo $space_group`_solvent_`echo $solnow`_i.pdb fi if [ ! -f `echo $space_group`_solvent_`echo $solnow`_i.phs ]; then touch `echo $space_group`_solvent_`echo $solnow`.phs fi #preparing for graphical output grep "" `echo $space_group`_`echo $prefix`_shelxe-orig-solvent0.$solnow.log | grep cycle | awk '{print $6}' | tail -1 >> `echo $space_group`_solvent-orig.dat grep "" `echo $space_group`_`echo $prefix`_shelxe-inv-solvent0.$solnow.log | grep cycle | awk '{print $6}' | tail -1 >> `echo $space_group`_solvent-inv.dat grep -c AT `echo $space_group`_solvent_`echo $solnow`.pdb >> `echo $space_group`_solvent-atoms-orig.dat grep -c AT `echo $space_group`_solvent_`echo $solnow`_i.pdb >> `echo $space_group`_solvent-atoms-inv.dat echo $solnow >> `echo $space_group`_solvent-values.dat solnow=$[$solnow+$solstep] done solnow=$solmin paste `echo $space_group`_solvent-values.dat `echo $space_group`_solvent-orig.dat > `echo $space_group`_solvent-orig-final.dat paste `echo $space_group`_solvent-values.dat `echo $space_group`_solvent-inv.dat > `echo $space_group`_solvent-inv-final.dat echo "set terminal png size 800,400" > `echo $space_group`_screen.gnuplot if [ $podo -ge 1 ]; then echo "set colorsequence podo" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo "set xrange [0:100]" >> `echo $space_group`_screen.gnuplot echo "set yrange [0:1]" >> `echo $space_group`_screen.gnuplot echo "set output '"`echo $space_group`"_screen_solvent.png'" >> `echo $space_group`_screen.gnuplot echo 'set title "Contrast vs. solvent content" font ",15"' >> `echo $space_group`_screen.gnuplot echo "set xlabel 'Solvent content'" >> `echo $space_group`_screen.gnuplot echo "set ylabel 'Contrast'" >> `echo $space_group`_screen.gnuplot echo "set key left" >> `echo $space_group`_screen.gnuplot echo "plot '"`echo $space_group`"_solvent-orig-final.dat' using 1:2 with linespoints lw 2 ps 1 title 'original', '"`echo $space_group`"_solvent-inv-final.dat' using 1:2 with linespoints lw 2 ps 1 title 'inverted'" >> `echo $space_group`_screen.gnuplot gnuplot < `echo $space_group`_screen.gnuplot paste `echo $space_group`_solvent-values.dat `echo $space_group`_solvent-atoms-orig.dat > `echo $space_group`_solvent-atoms-orig-final.dat paste `echo $space_group`_solvent-values.dat `echo $space_group`_solvent-atoms-inv.dat > `echo $space_group`_solvent-atoms-inv-final.dat echo "set terminal png size 800,400" > `echo $space_group`_screen-atoms.gnuplot if [ $podo -ge 1 ]; then echo "set colorsequence podo" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo "set xrange [0:100]" >> `echo $space_group`_screen-atoms.gnuplot echo "set yrange [0:]" >> `echo $space_group`_screen-atoms.gnuplot echo "set output '"`echo $space_group`"_screen_atoms.png'" >> `echo $space_group`_screen-atoms.gnuplot echo 'set title "Atoms built vs. solvent content" font ",15"' >> `echo $space_group`_screen-atoms.gnuplot echo "set xlabel 'Solvent content'" >> `echo $space_group`_screen-atoms.gnuplot echo "set ylabel 'No. of atoms built'" >> `echo $space_group`_screen-atoms.gnuplot echo "set key left" >> `echo $space_group`_screen-atoms.gnuplot echo "plot '"`echo $space_group`"_solvent-atoms-orig-final.dat' using 1:2 with linespoints lw 2 ps 1 title 'original', '"`echo $space_group`"_solvent-atoms-inv-final.dat' using 1:2 with linespoints lw 2 ps 1 title 'inverted'" >> `echo $space_group`_screen-atoms.gnuplot gnuplot < `echo $space_group`_screen-atoms.gnuplot } function shelx_e_standard () { echo "Running ShelxE in $space_group" shelxe `echo $space_group`_$prefix `echo $space_group`_`echo $prefix`_fa $Epar > `echo $space_group`_`echo $prefix`_shelxe-orig.log & shelxe `echo $space_group`_$prefix `echo $space_group`_`echo $prefix`_fa -i $Epar > `echo $space_group`_`echo $prefix`_shelxe-inv.log & wait #Graph for Shelx E preparation grep "" `echo $space_group`_`echo $prefix`_shelxe-orig.log | grep "cycle" > `echo $space_group`_plot-orig.dat grep "" `echo $space_group`_`echo $prefix`_shelxe-inv.log | grep "cycle" > `echo $space_group`_plot-inv.dat echo "set terminal png size 800,400" > `echo $space_group`_shelxe.gnuplot if [ $podo -ge 1 ]; then echo "set colorsequence podo" >> `echo $space_group`_`echo $prefix`_shelxc.gnuplot fi echo "set output '"`echo $space_group`"_shelxe.png'" >> `echo $space_group`_shelxe.gnuplot echo 'set title "Contrast vs. cycle" font ",15"' >> `echo $space_group`_shelxe.gnuplot echo "set xlabel 'Cycle'" >> `echo $space_group`_shelxe.gnuplot echo "set ylabel 'Contrast'" >> `echo $space_group`_shelxe.gnuplot echo "set yrange [0:1]" >> `echo $space_group`_shelxe.gnuplot echo "set key left" >> `echo $space_group`_shelxe.gnuplot echo "plot '"`echo $space_group`"_plot-orig.dat' using 6 with linespoints lw 2 ps 1 title 'original', '"`echo $space_group`"_plot-inv.dat' using 6 with linespoints lw 2 ps 1 title 'inverted'" >> `echo $space_group`_shelxe.gnuplot echo 'set title "Connectivity vs. cycle" font ",15"' >> `echo $space_group`_shelxe.gnuplot echo "set ylabel 'Connectivity'" >> `echo $space_group`_shelxe.gnuplot echo "set output '"`echo $space_group`"_shelxe-connectivity.png'" >> `echo $space_group`_shelxe.gnuplot echo "plot '"`echo $space_group`"_plot-orig.dat' using 9 with linespoints lw 2 ps 1 title 'original', '"`echo $space_group`"_plot-inv.dat' using 9 with linespoints lw 2 ps 1 title 'inverted'" >> `echo $space_group`_shelxe.gnuplot gnuplot < `echo $space_group`_shelxe.gnuplot echo "Run in $space_group finished." } function make_html () { echo '' > results_`echo $prefix`.html echo '' >> results_`echo $prefix`.html echo '' >> results_`echo $prefix`.html if [ $finished == N ]; then echo '' >> results_`echo $prefix`.html fi echo ''"$prefix"'

'"$prefix"' - Experimental phasing with ShelX - '"$method"'

' >> results_`echo $prefix`.html echo "

Settings:

" >> results_`echo $prefix`.html echo "" >> results_`echo $prefix`.html if [ $finished == N ]; then echo " " >> results_`echo $prefix`.html else echo " " >> results_`echo $prefix`.html fi echo " " >> results_`echo $prefix`.html echo " " >> results_`echo $prefix`.html echo "" >> results_`echo $prefix`.html echo "" >> results_`echo $prefix`.html echo "" >> results_`echo $prefix`.html echo "" >> results_`echo $prefix`.html echo "" >> results_`echo $prefix`.html if [ $screen == "Y" ]; then echo "" >> results_`echo $prefix`.html fi echo "
Status: running ...
Status: finished.
Input files: $sad $peak $infl $hrem $lrem $before $after $sira
Bravais type: $bravais_type
Unit cell parameters: $cell_all
Wavelength: $wavelength
Atoms to be found: $find $sfac
Number of trials: $ntry
ShelxE parameters: \" $Epar \"
Screening solvent: min $solmin, max $solmax, steps $solstep
" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html for html_space_group in $list do echo '- '$html_space_group' -' >> results_`echo $prefix`.html done echo "

" >> results_`echo $prefix`.html for html_space_group in $list #Tady na tom pracuju!!! do echo "
" >> results_`echo $prefix`.html echo "

Trial in space group $html_space_group

" >> results_`echo $prefix`.html if [ -f `echo $html_space_group`_`echo $prefix`_shelxc.log ]; then echo "

ShelxC

" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html echo "ShelxC input file - " >> results_`echo $prefix`.html echo "ShelxC logfile
" >> results_`echo $prefix`.html echo "
" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html fi if [ -f `echo $html_space_group`_`echo $prefix`_fa.ins ]; then echo "

" >> results_`echo $prefix`.html echo "Current resolution is: " >> results_`echo $prefix`.html grep SHEL `echo $html_space_group`_`echo $prefix`_fa.ins | cut -c5- >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html fi if [ -f `echo $html_space_group`_`echo $prefix`_shelxd.log ]; then echo "

ShelxD

" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html echo "ShelxD input file - " >> results_`echo $prefix`.html echo "ShelxD logfile
" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html fi if [ -f `echo $html_space_group`_shelxd_occupancy.png ]; then echo "

" >> results_`echo $prefix`.html echo "
" >> results_`echo $prefix`.html echo "Graph PATFOM vs. CCall
" >> results_`echo $prefix`.html echo "
" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html fi if [ $screen == "Y" ]; then if [ -f `echo $html_space_group`_screen_solvent.png ]; then echo "

ShelxE - screening the solvent content

" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html echo "
" >> results_`echo $prefix`.html echo "
" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html fi else if [ -f `echo $html_space_group`_`echo $prefix`_shelxe-inv.log ]; then echo "

ShelxE

" >> results_`echo $prefix`.html echo "

" >> results_`echo $prefix`.html echo "shelxe-orig logfile - " >> results_`echo $prefix`.html echo "shelxe-inv logfile
" >> results_`echo $prefix`.html fi if [ -f `echo $html_space_group`_shelxe-connectivity.png ]; then echo "
" >> results_`echo $prefix`.html echo "Graph connectivity vs. cycle
" >> results_`echo $prefix`.html fi html_shelxe_prep if [ -f $wdir/results_$prefix/`echo $html_space_group`_textik ]; then echo "Number of atoms built: " >> results_`echo $prefix`.html cat `echo $html_space_group`_textik >> results_`echo $prefix`.html rm $wdir/results_$prefix/`echo $html_space_group`_textik echo "

" >> results_`echo $prefix`.html fi fi echo "
" >> results_`echo $prefix`.html echo "
" >> results_`echo $prefix`.html done echo "

References

" >> results_`echo $prefix`.html echo "

P. Kolenko (2019). baSHELiXir: A Bash Script for Automated Experimental Phasing Using Shelx C/D/E. Chemicke listy, 113, 610-614.

" >> results_`echo $prefix`.html echo '

Please cite: I. Uson & G.M. Sheldrick (2018), "An introduction to experimental phasing of macromolecules illustrated by SHELX; new autotracing features" Acta Cryst. D74, 106-116 (Open Access) if SHELXE proves useful.

' >> results_`echo $prefix`.html echo ' ' >> results_`echo $prefix`.html mv results_`echo $prefix`.html index.html } list_gen #Test if Space group entered if [ -z $list ]; then echo "No space group entered. Exiting ... " exit fi ############################# # HIGH RESOLUTION SCREENING # ############################# if [ ! -z "$screen_high" ]; then if [ -z "$fix_low" ]; then echo "Low resolution not set. Exiting ... " exit fi cd $wdir echo "Screening for optimal high resolution limit ..." echo "\#\!/bin/bash" > run-file for resscreen in $screen_high; do echo -n "baSHELiXir -prefix `echo $prefix`-$resscreen -output-dir $wdir " >> run-file if [ ! -z "$sad" ]; then echo -n " -sad $sad " >> run-file fi if [ ! -z "$nat" ]; then echo -n "-nat $nat " >> run-file fi if [ ! -z "$peak" ]; then echo -n "-peak $peak " >> run-file fi if [ ! -z "$infl" ]; then echo -n "-infl $infl " >> run-file fi if [ ! -z "$hrem" ]; then echo -n "-hrem $hrem " >> run-file fi if [ ! -z "$lrem" ]; then echo -n "-lrem $lrem " >> run-file fi if [ ! -z "$before" ]; then echo -n "-before $before " >> run-file fi if [ ! -z "$after" ]; then echo -n "-after $after " >> run-file fi if [ ! -z "$sira" ]; then echo -n "-sira $sira " >> run-file fi echo -n "-nproc $nproc " >> run-file echo -n "-sfac $sfac " >> run-file echo -n "-find $find " >> run-file echo -n "-ntry $ntry " >> run-file echo -n "-wavelength $wavelength " >> run-file echo -n "--cell $cell_all " >> run-file echo -n "-res $fix_low $resscreen " >> run-file if [ ! -z "$dsul" ]; then echo -n "-dsul $dsul " >> run-file fi if [ ! -z "$mind" ]; then echo -n "-mind \" $mind \" " >> run-file fi if [ ! -z "$dsca" ]; then echo -n "-dsca $dsca " >> run-file fi echo -n "-Epar \" $Epar \" " >> run-file echo -n "-list \" $list \" " >> run-file if [ $screen == "Y" ]; then echo -n "-solv $solmin $solmax $solstep " >> run-file fi echo " " >> run-file done sh run-file rm run-file exit fi ############################ # LOW RESOLUTION SCREENING # ############################ if [ ! -z "$screen_low" ]; then if [ -z "$fix_high" ]; then echo "High resolution not set. Exiting ... " exit fi cd $wdir echo "Screening for optimal low resolution limit ..." echo "\#\!/bin/bash" > run-file for resscreen in $screen_low; do echo -n "baSHELiXir -prefix `echo $prefix`-$resscreen -output-dir $wdir " >> run-file if [ ! -z "$sad" ]; then echo -n " -sad $sad " >> run-file fi if [ ! -z "$nat" ]; then echo -n "-nat $nat " >> run-file fi if [ ! -z "$peak" ]; then echo -n "-peak $peak " >> run-file fi if [ ! -z "$infl" ]; then echo -n "-infl $infl " >> run-file fi if [ ! -z "$hrem" ]; then echo -n "-hrem $hrem " >> run-file fi if [ ! -z "$lrem" ]; then echo -n "-lrem $lrem " >> run-file fi if [ ! -z "$before" ]; then echo -n "-before $before " >> run-file fi if [ ! -z "$after" ]; then echo -n "-after $after " >> run-file fi if [ ! -z "$sira" ]; then echo -n "-sira $sira " >> run-file fi echo -n "-nproc $nproc " >> run-file echo -n "-sfac $sfac " >> run-file echo -n "-find $find " >> run-file echo -n "-ntry $ntry " >> run-file echo -n "-wavelength $wavelength " >> run-file echo -n "--cell $cell_all " >> run-file echo -n "-res $resscreen $fix_high " >> run-file if [ ! -z "$dsul" ]; then echo -n "-dsul $dsul " >> run-file fi if [ ! -z "$mind" ]; then echo -n "-mind \" $mind \" " >> run-file fi if [ ! -z "$dsca" ]; then echo -n "-dsca $dsca " >> run-file fi echo -n "-Epar \" $Epar \" " >> run-file echo -n "-list \" $list \" " >> run-file if [ $screen == "Y" ]; then echo -n "-solv $solmin $solmax $solstep " >> run-file fi echo " " >> run-file done sh run-file rm run-file exit fi #Real start of the routine. echo "Running ..." mkdir $wdir/results_`echo $prefix` cd $wdir/results_`echo $prefix` file_prep if [ -f "$wdir/results_$prefix/files.txt" ] then : else echo "No input files have been selected. Exiting ... " exit fi make_html #-------------------------------------------------------------------------- #Definition of FOR cycle for space_group in $list do c_prep #Running command ShelxC shelx_c make_html # c_clean c_graph make_html shelx_d make_html if [ $screen == Y ]; then shelx_e_screen shelx_e_graph else shelx_e_standard fi make_html done chmod a+rwx * #it allows most of the browser to make the files visible. finished=Y make_html # final HTML generation echo "Calculations finished..."