bp3 hklin TS03_12287.mtz hklout TS03_phased.mtz << eof
xtal X12287
atom se
xyz   0.053260   0.392121   0.473668
occu 0.5
biso 20.0
atom se
xyz   0.034806   0.580366   0.394437
occu 0.5
biso 20.0
atom se
xyz   0.107747   0.646315   0.200347
occu 0.5
biso 20.0
atom se
xyz   0.209915   0.217955   0.683720
occu 0.5
biso 20.0
atom se
xyz   0.089826   0.720611   0.155398
occu 0.5
biso 20.0
atom se
xyz  -0.003167   0.439764   0.430688
occu 0.5
biso 20.0
atom se
xyz   0.087264   0.861623   0.477592
occu 0.5
biso 20.0
atom se
xyz   0.037744   0.918034   0.144400
occu 0.5
biso 20.0
atom se
xyz   0.078359   0.917910   0.125991
occu 0.5
biso 20.0

dname INFL
column F+=F(+)_INFL SF+=SIGF(+)_INFL F-=F(-)_INFL SF-=SIGF(-)_INFL 
form se FP=-9.9 FPP=3.9
dname LREM
column F+=F(+)_LREM SF+=SIGF(+)_LREM F-=F(-)_LREM SF-=SIGF(-)_LREM 
form se FP=-3.3 FPP=0.5

phase
eof

# for running dm after this...
# note that a free R column is needed...

dm hklin TS03_phased_free.mtz hklout TS03_phased_improved_dm.mtz << eof
solc 0.526
mode solv hist mult
ncyc auto
scheme all
labin FP=FPHASED SIGFP=SIGFPHASED FOMO=FOM HLA=HLA HLB=HLB HLC=HLC HLD=HLD
labout PHIDM=PHIDM FOMDM=FOMDM
eof

# according to the documentation this is how we prepare data for shelxd
 
revise hklin TS03_12287.mtz hklout TS03_12287_prepare.mtz << eof
labin -
FPH1=F_INFL SIGFPH1=SIGF_INFL DPH1=DANO_INFL SIGDPH1=SIGDANO_INFL -
FPH2=F_LREM SIGFPH2=SIGF_LREM DPH2=DANO_LREM SIGDPH2=SIGDANO_LREM 
labout -
FPH1=F_INFL_mod SIGFPH1=SIGF_INFL_mod -
DPH1=DANO_INFL_mod SIGDPH1=SIGDANO_INFL_mod -
FPH1=F_LREM_mod SIGFPH1=SIGF_LREM_mod -
DPH1=DANO_LREM_mod SIGDPH1=SIGDANO_LREM_mod -
FM=FM SIGFM=SIGFM
wave 1 lam 0.97966 fpr -9.9 fdp 3.9
wave 2 lam 1.00000 fpr -3.3 fdp 0.5
end
eof

mtz2various hklin TS03_12287_prepare.mtz hklout TS03_12287.hkl << eof
output shelxd
labin FP=FM SIGFP=SIGFM
end

# hyss isn't happy with it though...
# however it will work with the original data...

phenix.hyss TS03_12287.mtz 9 se

# here is a script which works very nicely for the TS03 data and gives
# a nice map (e.g. this actually works from start to finish...)

# find the sites
phenix.hyss TS03_12287.mtz 9 se --space_group=p43212

# begin composing the bp3 input file - note well that the 
# input crystal id must be a string!
echo 'xtal X12287' > bp3.in

# transmogrify the coordinates from hyss to a form helpful for bp3
python ~/CVR/SS/lib/Jiffy.py TS03*consensus*.pdb >> bp3.in

# add in the correct BISO values - see output from above 
cat bp3.in | sed 's/BISO/20.0/' > bp3.tmp
mv bp3.tmp bp3.in

# fill in the column and f', f'' information
cat >> bp3.in << eof

dname INFL
column F+=F(+)_INFL SF+=SIGF(+)_INFL F-=F(-)_INFL SF-=SIGF(-)_INFL 
form se FP=-9.9 FPP=3.9
dname LREM
column F+=F(+)_LREM SF+=SIGF(+)_LREM F-=F(-)_LREM SF-=SIGF(-)_LREM 
form se FP=-3.3 FPP=0.5
phase

eof

# run bp3 with the sites and phasing information
bp3 hklin TS03_12287.mtz hklout TS03_12287_phased.mtz < bp3.in

# add in the original columns from the reduced data - this will
# give the FreeR_flag and F, SIGF's
cad hklin1 TS03_12287.mtz hklin2 TS03_12287_phased.mtz \
hklout TS03_12287_phased_all.mtz << eof
labin file 1 all
labin file 2 all
eof

# run some density modification to make the very nice map - note using
# F, SIGF output from bp3 - since I am still working on those phases
dm hklin TS03_12287_phased_all.mtz hklout TS03_12287_improved.mtz << eof
solc 0.526
mode solv hist mult
ncyc auto
scheme all
labin FP=FPHASED SIGFPHASED=SIGFP FOMO=FOM FREE=FreeR_flag -
HLA=HLA HLB=HLB HLC=HLC HLD=HLD
labout PHIDM=PHIDM FOMDM=FOMDM
eof

# next I could run arp/warp, in which case I would give the F, SIGF from 
# the low remote...
