aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChuck <chuck@cfel-chuck.desy.de>2014-05-23 08:14:40 +0200
committerThomas White <taw@physics.org>2014-05-23 20:46:59 +0200
commitd7f3beb9fdbce11539fe5dec1c7db372d736f4f0 (patch)
treeea182a11257ae6a3d6bc77307ff12f26b4a88e3b /scripts
parentf37b3689a2db84dae3c1a05eca56b92aa57c077a (diff)
Added script for expanding to P1
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen-sfs-expand99
1 files changed, 99 insertions, 0 deletions
diff --git a/scripts/gen-sfs-expand b/scripts/gen-sfs-expand
new file mode 100755
index 00000000..edc3ee1d
--- /dev/null
+++ b/scripts/gen-sfs-expand
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+PDB=$1
+SYMM=$2
+RESOLUTION=$3
+
+if [ "x$PDB" = "x" ]; then
+ echo "Syntax: $0 <PDB file> <space group> [<resolution>]"
+ exit
+fi
+
+if [ "x$SYMM" = "x" ]; then
+ echo "Syntax: $0 <PDB file> <space group> [<resolution>]"
+ exit
+fi
+
+if [ "x$RESOLUTION" = "x" ]; then
+ echo "Resolution not given. Using 3 Angstroms."
+ RESOLUTION=3
+fi
+
+echo "Running sfall to calculate structure factors..."
+sfall XYZIN $PDB HKLOUT ${PDB}.mtz > gen-sfs.html << EOF
+MODE SFCALC XYZIN
+RESOLUTION $RESOLUTION 1000
+FORM NGAUSS 5
+SYMM $SYMM
+END
+EOF
+if [ $? -ne 0 ]; then
+ echo "Failed! Please examine gen-sfs.html for more information."
+ exit 1
+fi
+
+
+echo "Running cad to get the right asymmetric unit..."
+cad HKLIN1 ${PDB}.mtz HKLOUT ${PDB}-sorted.mtz >> gen-sfs.html <<EOF
+TITLE Sorted blah
+LABIN FILE 1 E1=FC E2=PHIC
+CTYPE FILE 1 E1=F E2=P
+EOF
+if [ $? -ne 0 ]; then
+ echo "Failed! Please examine gen-sfs.html for more information."
+ exit 1
+fi
+
+echo "Running sftools to expand reflections to P1..."
+sftools << EOF
+READ ${PDB}-sorted.mtz
+EXPAND
+WRITE ${PDB}-P1.mtz
+STOP
+EOF
+
+echo "Converting structure factors to text..."
+mtz2various hklin ${PDB}-P1.mtz hklout ${PDB}-temp.hkl >> gen-sfs.html <<EOF
+LABIN H=H K=K L=L FC=FC PHIC=PHIC
+OUTPUT USER '(3I6,2F9.1)'
+EOF
+if [ $? -ne 0 ]; then
+ echo "Failed! Please examine gen-sfs.html for more information."
+ exit 1
+fi
+
+rm -f ${PDB}-P1.mtz
+rm -f ${PDB}.mtz
+
+perl < ${PDB}-temp.hkl > ${PDB}.hkl << WIBBLE
+use strict;
+
+my \$line;
+open(FILE, "${PDB}-temp.hkl");
+
+printf(" h k l I phase sigma(I) counts fs/px ss/px\\n");
+
+while ( \$line = <FILE> ) {
+
+ if ( \$line =~ /^\s*([\d\-]+)\s+([\d\-]+)\s+([\d\-]+)\s+([\d\-\.]+)\s+([\d\-\.]+)/ ) {
+
+ my \$h = \$1;
+ my \$k = \$2;
+ my \$l = \$3;
+ my \$intensity = \$4*\$4; # Square to convert F->I
+ my \$phase = \$5;
+
+ printf("%3i %3i %3i %10.2f %8.2f %10.2f %7i %6.1f %6.1f\n",
+ \$h, \$k, \$l, \$intensity, \$phase, 0.0, 1, 0.0, 0.0);
+
+ } else {
+ printf(STDERR "Couldn't understand line '%s'\n", \$line);
+ }
+
+}
+close(FILE);
+printf("End of reflections\n");
+WIBBLE
+exit
+
+rm -f ${PDB}-temp.hkl