Thank Nathaniel.  I am still confused.  Do you intend me to copy and paste the script that you included to a file called score.py.  When I did that I got the following error message

Syntax error: expected "=", found "__future__" (file "score.py", line 1)
Sorry: score.py is not a valid parameter file.

What are the inputs?  I would think that at a minimum I would have to input a pdb file, mtz file, fasta file, and an estimate for the rmsd.

Thanks again,

Jouko


On Fri, Jul 11, 2014 at 6:03 PM, Nathaniel Echols <nechols@lbl.gov> wrote:
On Fri, Jul 11, 2014 at 2:48 PM, Jouko Virtanen <jouko@umich.edu> wrote:
I would like to calculate the maximum-likelihood score given an input structure and an mtz file.  How can I do that?  Thanks in advance.

Do you just want the ML target function value, i.e. what phenix.refine prints out at regular intervals?  In that case, you can use the script appended below (run with phenix.python score.py), which is derived from $PHENIX/cctbx_project/mmtbx/examples/simple_command_line_cc.py.

from __future__ import division
import mmtbx.command_line
import sys

def master_phil () :
  return mmtbx.command_line.generic_simple_input_phil()

def run (args, out=sys.stdout) :
  cmdline = mmtbx.command_line.load_model_and_data(
    update_f_part1_for="map",
    args=args,
    master_phil=master_phil(),
    out=out,
    process_pdb_file=False,
    create_fmodel=True)
  fmodel = cmdline.fmodel
  tf = fmodel.target_functor(compute_gradients=False)
  score = tf_r.target_work()
  print score

if (__name__ == "__main__") :
  run(sys.argv[1:])