aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen-sfs-ano
blob: 522e0a6dce533313a2dcf62744b79ba91b956af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh

PDB=$1
SYMM=$2
PG=$3
WAVEL=$4
RESOLUTION=$5

function show_help()
{
	echo -n "Syntax: $0 <PDB file> <space group> <point group>"
	echo "<wavelength in Angstroms> [<resolution>]"
	echo
	echo "The space group and point group must be consistent, it's just"
	echo "that I don't know how to convert the space group to a point"
	echo "group."
}

if [ "x$PDB" = "x" ]; then
	show_help
	exit
fi

if [ "x$SYMM" = "x" ]; then
	show_help
	exit
fi

if [ "x$RESOLUTION" = "x" ]; then
	echo "Resolution not given.  Using 3 Angstroms."
	RESOLUTION=3
fi

echo "Running ano_sfall.com to calculate structure factors..."
ano_sfall.com ${PDB} ${RESOLUTION}A wave=${WAVEL}
if [ $? -ne 0 ]; then exit 1; fi

echo "Converting structure factors to text..."
mtz2various hklin ideal_ano.mtz hklout ${PDB}-temp1.hkl >> gen-sfs.html <<EOF
LABIN H=H K=K L=L DUM1=Fplus DUM2=Fminus
OUTPUT USER '(3I4,2F9.1)'
EOF
if [ $? -ne 0 ]; then exit 1; fi
rm -f ${PDB}.mtz
perl > ${PDB}-temp2.hkl << WIBBLE
use strict;

my \$line;
open(FILE, "${PDB}-temp1.hkl");

printf("  h   k   l          I    phase   sigma(I)  1/d(nm^-1)  ".
       "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 \$iplus = \$4*\$4;  # Square to convert F->I
                my \$iminus = \$5*\$5;

                printf("%3i %3i %3i %10.2f -     0.0  %s %7i %6.1f %6.1f\n",
                       \$h, \$k, \$l, \$iplus, "         -", 1, 0.0, 0.0);

                printf("%3i %3i %3i %10.2f -     0.0  %s %7i %6.1f %6.1f\n",
                       -\$h, -\$k, -\$l, \$iminus, "         -", 1, 0.0, 0.0);

        } else {
        	printf(STDERR "Couldn't understand line '%s'\n", \$line);
        }

}
close(FILE);
printf("End of reflections\n");
WIBBLE

get_hkl -i ${PDB}-temp2.hkl -o ${PDB}.hkl -p ${PDB} -y ${PG} --trim-centrics

rm -f ${PDB}-temp1.hkl
rm -f ${PDB}-temp2.hkl