Exemplo n.º 1
0
 def render_r3d(self, name, img_format="png"):
     job = Job(self, utils.syspath("render"))
     # render writes normal output to stderr (and nothing to stdout)
     job.out.file_extension = "out"
     job.err.file_extension = "log"
     job.args += ["-"+img_format, "%s.%s" % (name, img_format)]
     job.stdin_file = name+".r3d"
     job.parser = " %s.%s" % (name, img_format)
     return job
Exemplo n.º 2
0
def find_path():
    if os.name == 'nt':
        default_path = "C:/WinCoot/runwincoot.bat"
        if os.path.exists(default_path):
            return default_path
        else:
            utils.put_error("WinCoot not found.")
    else:
        return utils.syspath("coot")
Exemplo n.º 3
0
 def render_r3d(self, name, img_format):
     assert img_format is not None
     job = Job(self, utils.syspath("render"))
     # render writes normal output to stderr (and nothing to stdout)
     job.out.file_extension = "out"
     job.err.file_extension = "log"
     job.args += ["-" + img_format, "%s.%s" % (name, img_format)]
     job.stdin_file = name + ".r3d"
     job.parser = " %s.%s" % (name, img_format)
     return job
Exemplo n.º 4
0
 def render_r3d(self, name, img_format):
     assert img_format is not None
     job = Job(self, utils.syspath('render'))
     # render writes normal output to stderr (and nothing to stdout)
     job.out.file_extension = 'out'
     job.err.file_extension = 'log'
     job.args += ['-'+img_format, '%s.%s' % (name, img_format)]
     job.stdin_file = name + '.r3d'
     job.parser = ' %s.%s' % (name, img_format)
     return job
Exemplo n.º 5
0
    def shelxc(self, scain, cell, symmetry):
        job = Job(self, utils.syspath('shelxc'))
        name = os.path.splitext(scain)[0]
        job.args += [name]

        job.std_input = '\n'.join([
            'SAD %s' % scain,
            'CELL %s %s %s %s %s %s' % cell,
            'SPAG %s' % symmetry,
        ])
        return job
Exemplo n.º 6
0
def find_path():
    if os.name == 'nt':
        for path in [
                "C:/WinCoot/wincoot.bat",  # since WinCoot 0.8.8
                "C:/WinCoot/runwincoot.bat",  # WinCoot prior to 0.8.8
                utils.cbin("coot.bat")
        ]:  # CCP4 script added in 2018
            if os.path.exists(path):
                return path
        utils.comment("\nNote: WinCoot not found.\n")
    else:
        return utils.syspath("coot")
Exemplo n.º 7
0
Arquivo: main.py Projeto: ccp4/dimple
def _check_picture_tools():
    ok = True
    coot_path, coot_ver = coots.find_path_and_version()
    if coot_path:
        if coot_ver is None:
            put_error("coot not working(?), no pictures")
            ok = False
        else:
            if "with python" not in coot_ver:
                put_error("coot with Python support is needed")
                ok = False
            if "\n0.6." in coot_ver:
                put_error("coot 0.7+ is needed (0.6 would crash)")
                ok = False
    else:
        put_error("No coot, no pictures")
        ok = False
    if not utils.syspath("render"):
        put_error("No Raster3d, no pictures")
        ok = False
    return ok
Exemplo n.º 8
0
def _generate_scripts_and_pictures(wf, opt, data, pha=None):
    blobs = data['blobs'] if data else []
    coot_path = coots.find_path()
    if not blobs:
        comment('\nUnmodelled blobs not found.')
    elif opt.img_format:
        if coot_path:
            coot_ver = coots.find_version(coot_path)
            if coot_ver is None:
                put_error('coot not working(?), no pictures')
                opt.img_format = None
            elif 'with python' not in coot_ver:
                put_error('coot with Python support is needed')
                opt.img_format = None
        else:
            put_error('No coot, no pictures')
            opt.img_format = None
        if not utils.syspath('render'):
            put_error('No Raster3d, no pictures')
            opt.img_format = None
        if opt.img_format:
            if len(blobs) == 1:
                comment('\nRendering density blob at (%.1f, %.1f, %.1f)' %
                        blobs[0])
            else:
                comment('\nRendering 2 largest blobs: at (%.1f, %.1f, %.1f) '
                        'and at (%.1f, %.1f, %.1f)' % (blobs[0] + blobs[1]))
    com = data and data.get('center')
    if pha:
        normal_map = False
        refl = pha
        prefix = 'anom-'
    else:
        normal_map = True
        refl = opt.hklout
        prefix = ''

    # run-coot.py centers on the biggest blob. It uses relative paths -
    # it can be run only from the output directory, but is not affected
    # by moving that directory to different location.
    # There are blobN-coot.py scripts generated below with absolute paths.
    # write coot script (apart from pictures) that centers on the biggest blob
    script_path = os.path.join(wf.output_dir, prefix + 'run-coot.py')
    script = coots.basic_script(pdb=opt.xyzout,
                                refl=refl,
                                normal_map=normal_map,
                                center=(blobs and blobs[0]),
                                toward=com,
                                white_bg=opt.white_bg)
    _write_script(script_path, script, executable=True)

    # blob images, for now for not more than two blobs
    d = os.path.abspath(wf.output_dir)
    for n, b in enumerate(blobs[:2]):
        py_path = os.path.join(wf.output_dir,
                               '%sblob%d-coot.py' % (prefix, n + 1))
        content = coots.basic_script(pdb=os.path.join(d, opt.xyzout),
                                     refl=os.path.join(d, refl),
                                     normal_map=normal_map,
                                     center=blobs[n],
                                     toward=com,
                                     white_bg=opt.white_bg)
        _write_script(py_path, content)
    # coot.sh - one-line script for convenience
    if blobs:
        coot_sh_text = '{coot} --no-guano {out}/%sblob1-coot.py\n' % prefix
    else:
        coot_sh_text = '{coot} --no-guano {out}/final.mtz {out}/final.pdb\n'
    coot_sh_path = os.path.join(wf.output_dir, prefix + 'coot.sh')
    _write_script(coot_sh_path,
                  coot_sh_text.format(coot=coot_path or 'coot',
                                      out=wf.output_dir),
                  executable=True)

    if opt.img_format and blobs:
        script = ''
        basenames = []
        # as a workaround for buggy coot the maps are reloaded for each blob
        for n, b in enumerate(blobs[:2]):
            script += coots.basic_script(pdb=opt.xyzout,
                                         refl=refl,
                                         normal_map=normal_map,
                                         center=b,
                                         toward=com,
                                         white_bg=opt.white_bg)
            rs, names = coots.r3d_script(center=b,
                                         toward=com,
                                         blobname='%sblob%s' % (prefix, n + 1))
            script += rs
            basenames += names
        coot_job = wf.coot_py(script)
        try:
            coot_job.run()
        except workflow.JobError:
            # check for a possible cause to hint the user
            # (possible workaround: change $HOME to non-existing directory)
            if utils.silently_run(coot_job.args, cwd=wf.output_dir)[0] != 0:
                put_error('coot fails with options: --no-graphics --python',
                          comment='It happens when scripts in .coot or '
                          '.coot-preferences are not compatible\n'
                          'with the --no-graphics mode.')
            raise
        for n, basename in enumerate(basenames):
            try:
                job = wf.render_r3d(basename, img_format=opt.img_format)
                if n % 3 == 0:
                    job.run()
                else:  # minimal output
                    job.run(show_progress=False, new_line=False)
                wf.delete_files([basename + '.r3d'])
            except workflow.JobError as e:
                # Raster3D may fail saying "increase MAXDET and recompile".
                # This is not critical, so Dimple doesn't stop.
                put_error('Rendering failed, no picture', comment=' ' + e.note)
    return coot_sh_path
Exemplo n.º 9
0
 def find_blobs(self, hklin, xyzin, sigma=1.0):
     # for now search in PATH (which normally includes CBIN)
     job = Job(self, utils.syspath("find-blobs"))
     job.args += ["-c", "-s%g" % sigma, hklin, xyzin]
     job.parser = "_find_blobs_parser"
     return job
Exemplo n.º 10
0
 def find_blobs(self, hklin, xyzin, sigma=1.0):
     # for now search in PATH (which normally includes CBIN)
     job = Job(self, utils.syspath("find-blobs"))
     job.args += ["-c", "-s%g" % sigma, hklin, xyzin]
     job.parser = "_find_blobs_parser"
     return job
Exemplo n.º 11
0
 def anode(self, name):
     job = Job(self, utils.syspath('anode'))
     job.args += [name]
     job.parser = '_anode_parser'
     return job
Exemplo n.º 12
0
 def mtz2sca(self, mtzin, scaout):
     job = Job(self, utils.syspath('mtz2sca'))
     job.args += [mtzin, scaout]
     return job
Exemplo n.º 13
0
 def find_blobs(self, hklin, xyzin, sigma=1.0):
     # for now search in PATH (which normally includes CBIN)
     job = Job(self, utils.syspath('find-blobs'))
     job.args += ['-c', '-s%g' % sigma, hklin, xyzin]
     job.parser = '_find_blobs_parser'
     return job
Exemplo n.º 14
0
def _generate_scripts_and_pictures(wf, opt, data):
    blobs = data["blobs"] if data else []
    coot_path = coots.find_path()
    if not blobs:
        comment("\nUnmodelled blobs not found.")
    elif opt.img_format:
        if coot_path:
            coot_ver = coots.find_version(coot_path)
            if coot_ver is None:
                put_error("coot not working(?), no pictures")
                opt.img_format = None
            elif "with python" not in coot_ver:
                put_error("coot with Python support is needed")
                opt.img_format = None
        else:
            put_error("No coot, no pictures")
            opt.img_format = None
        if not utils.syspath("render"):
            put_error("No Raster3d, no pictures")
            opt.img_format = None
        if opt.img_format:
            if len(blobs) == 1:
                comment("\nRendering density blob at (%.1f, %.1f, %.1f)" %
                        blobs[0])
            else:
                comment("\nRendering 2 largest blobs: at (%.1f, %.1f, %.1f) "
                        "and at (%.1f, %.1f, %.1f)" % (blobs[0]+blobs[1]))
    com = data and data["center"]

    # run-coot.py centers on the biggest blob. It uses relative paths -
    # it can be run only from the output directory, but is not affected
    # by moving that directory to different location.
    # There are blobN-coot.py scripts generated below with absolute paths.
    # write coot script (apart from pictures) that centers on the biggest blob
    script_path = os.path.join(wf.output_dir, "run-coot.py")
    script = coots.basic_script(pdb=opt.xyzout, mtz=opt.hklout,
                                center=(blobs and blobs[0]), toward=com,
                                white_bg=opt.white_bg)
    _write_script(script_path, script, executable=True)

    # blob images, for now for not more than two blobs
    d = os.path.abspath(wf.output_dir)
    for n, b in enumerate(blobs[:2]):
        py_path = os.path.join(wf.output_dir, "blob%d-coot.py" % (n+1))
        content = coots.basic_script(pdb=os.path.join(d, opt.xyzout),
                                     mtz=os.path.join(d, opt.hklout),
                                     center=blobs[n], toward=com,
                                     white_bg=opt.white_bg)
        _write_script(py_path, content)
    # coot.sh - one-line script for convenience
    if blobs:
        coot_sh_text = '{coot} --no-guano {out}/blob1-coot.py\n'
    else:
        coot_sh_text = '{coot} --no-guano {out}/final.mtz {out}/final.pdb\n'
    coot_sh_path = os.path.join(wf.output_dir, "coot.sh")
    _write_script(coot_sh_path, coot_sh_text.format(coot=coot_path or 'coot',
                                                    out=wf.output_dir),
                  executable=True)

    if opt.img_format and blobs:
        script = ''
        basenames = []
        # as a workaround for buggy coot the maps are reloaded for each blob
        for n, b in enumerate(blobs[:2]):
            script += coots.basic_script(pdb=opt.xyzout, mtz=opt.hklout,
                                         center=b, toward=com,
                                         white_bg=opt.white_bg)
            rs, names = coots.r3d_script(center=b, toward=com,
                                         blobname="blob%s" % (n+1))
            script += rs
            basenames += names
        coot_job = wf.coot_py(script)
        try:
            coot_job.run()
        except workflow.JobError:
            # check for a possible cause to hint the user
            # (possible workaround: change $HOME to non-existing directory)
            if utils.silently_run(coot_job.args, cwd=wf.output_dir)[0] != 0:
                put_error("coot fails with options: --no-graphics --python",
                          comment="It happens when scripts in .coot or "
                                  ".coot-preferences are not compatible\n"
                                  "with the --no-graphics mode.")
            raise
        for n, basename in enumerate(basenames):
            job = wf.render_r3d(basename, img_format=opt.img_format)
            if n % 3 == 0:
                job.run()
            else: # minimal output
                job.run(show_progress=False, new_line=False)
        wf.delete_files([name+".r3d" for name in basenames])
    return coot_sh_path