# # Copyright (C) 2013 David Waterman # # This code is distributed under the terms and conditions of the # CCP4 Program Suite Licence Agreement as a CCP4 Application. # A copy of the CCP4 licence can be obtained by writing to the # CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK. # """Initialisation for the CCP4Dispatchers package""" import os, string import tempfile envlist = [('CCP4I_TCLTK', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/bin'), ('CCP4_HELPDIR', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/help/'), ('CHTML', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/html'), ('GFORTRAN_UNBUFFERED_PRECONNECTED', 'Y'), ('CCP4', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0'), ('CLIB', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/lib'), ('CEXAM', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/examples'), ('CCP4I_TOP', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/share/ccp4i'), ('PATH', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/etc:/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/bin:/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/etc:/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/bin:/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/etc:/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/ehl25977/bin'), ('CCP4_OPEN', 'UNKNOWN'), ('CETC', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/etc'), ('CLIBD_MON', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/lib/data/monomers/'), ('SHLVL', '1'), ('CRANK', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/share/ccp4i/crank'), ('CLIBD', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/lib/data'), ('CBIN', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/bin'), ('CINCL', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/include'), ('CCP4_MASTER', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest'), ('MMCIFDIC', '/cvmfs/facilities.gridpp.ac.uk/ccp4/latest/ccp4-7.0/lib/ccp4/cif_mmdic.lib')] prog_to_dispatcher = {'dials.estimate_gain': 'dials_estimate_gain', 'prosmart': 'prosmart', 'ccp4um': 'ccp4um', 'worms': 'worms', 'pdbcur': 'pdbcur', 'extends': 'extends', 'dials.import_xds': 'dials_import_xds', 'lorestr': 'lorestr', 'mini-rsr': 'mini-rsr', 'cython': 'cython', 'ARCIMBOLDO_LITE': 'ARCIMBOLDO_LITE', 'watncs': 'watncs', 'xia2.multi_crystal_analysis': 'xia2_multi_crystal_analysis', 'fsearch': 'fsearch', 'detwin': 'detwin', 'shelx2map': 'shelx2map', 'editra': 'editra', 'coot': 'coot', 'dials.find_hot_pixels': 'dials_find_hot_pixels', 'prosmart_align': 'prosmart_align', 'balls': 'balls', 'xia2.resolutionizer': 'xia2_resolutionizer', 'seqwt': 'seqwt', 'xia2.print': 'xia2_print', 'scaleit': 'scaleit', 'coot-compare-dictionaries': 'coot-compare-dictionaries', 'f2mtz': 'f2mtz', 'almn': 'almn', 'gensym': 'gensym', 'rings3d': 'rings3d', 'spicker': 'spicker', 'cbuccaneer': 'cbuccaneer', 'mtzdiff': 'mtzdiff', 'ccp4iwish': 'ccp4iwish', 'chef': 'chef', 'pmf': 'pmf', 'pywxrc': 'pywxrc', 'cphasematch': 'cphasematch', 'check_cell_sg': 'check_cell_sg', 'ribbon': 'ribbon', 'dials.align_crystal': 'dials_align_crystal', 'mtztona4': 'mtztona4', 'cythonize': 'cythonize', 'dials.plot_scan_varying_crystal': 'dials_plot_scan_varying_crystal', 'pdb2s': 'pdb2s', 'crush': 'crush', 'xia2.show_build_path': 'xia2_show_build_path', 'abs': 'abs', 'prelyscar_ccp4.pl': 'prelyscar_ccp4_pl', 'refindex': 'refindex', 'sortwater': 'sortwater', 'mapreplace': 'mapreplace', 'ccp4i_condorsub': 'ccp4i_condorsub', 'xia2.chef.old': 'xia2_chef_old', 'conkit-precision': 'conkit-precision', 'vectors': 'vectors', 'topdraw': 'topdraw', 'fhscal': 'fhscal', 'othercell': 'othercell', 'pilprint.py': 'pilprint_py', 'rotgen': 'rotgen', 'xia2.html': 'xia2_html', 'asc2p84': 'asc2p84', 'dials.generate_mask': 'dials_generate_mask', 'sftools': 'sftools', 'dials.find_spots_client': 'dials_find_spots_client', 'pdb2to3': 'pdb2to3', 'rst2pseudoxml.py': 'rst2pseudoxml_py', 'anisoanl': 'anisoanl', 'privateer': 'privateer', 'hgen': 'hgen', 'mtzmnf': 'mtzmnf', 'baverage': 'baverage', 'rstpep2html.py': 'rstpep2html_py', 'havecs': 'havecs', 'dials.stereographic_projection': 'dials_stereographic_projection', 'ccp4i2': 'ccp4i2', 'chltofom': 'chltofom', 'zeroed': 'zeroed', 'symconv': 'symconv', 'rst2man.py': 'rst2man_py', 'dials.analyse_background': 'dials_analyse_background', 'dials.show': 'dials_show', 'get_trans': 'get_trans', 'p842asc': 'p842asc', 'rst2odt.py': 'rst2odt_py', 'crossec': 'crossec', 'cecalc': 'cecalc', 'dials.geometry_viewer': 'dials_geometry_viewer', 'cad': 'cad', 'pilconvert.py': 'pilconvert_py', 'xia2.index': 'xia2_index', 'lsqkab': 'lsqkab', 'xia2.wilson_stuff': 'xia2_wilson_stuff', 'cpirate': 'cpirate', 'mapslicer': 'mapslicer', 'printpeaks': 'printpeaks', 'freerflag': 'freerflag', 'rods': 'rods', 'mtzutils': 'mtzutils', 'csm': 'csm', 'cphasecombine': 'cphasecombine', 'solution_check': 'solution_check', 'dimple': 'dimple', 'gcx': 'gcx', 'dials.find_shared_models': 'dials_find_shared_models', 'npo': 'npo', 'libcheck': 'libcheck', 'pplot': 'pplot', 'xia2.documentation': 'xia2_documentation', 'dials.two_theta_offset': 'dials_two_theta_offset', 'img2xpm': 'img2xpm', 'pywrap': 'pywrap', 'aimless': 'aimless', 'xia2.small_molecule': 'xia2_small_molecule', 'ccp4ish': 'ccp4ish', 'gfac2pdb': 'gfac2pdb', 'sc': 'sc', 'dials.model_background': 'dials_model_background', 'cextend': 'cextend', 'fft': 'fft', 'ecalc': 'ecalc', 'cfft': 'cfft', 'pandda.export': 'pandda_export', 'dials.spot_counts_per_image': 'dials_spot_counts_per_image', 'crunch2': 'crunch2', 'theseus': 'theseus', 'dials.integrate': 'dials_integrate', 'conkit-plot': 'conkit-plot', 'nautilus_pipeline': 'nautilus_pipeline', 'refmac5': 'refmac5', 'diffdump': 'diffdump', 'create_docs': 'create_docs', 'wxrc': 'wxrc', 'TMscore': 'TMscore', 'pdb_merge': 'pdb_merge', 'dials.split_experiments': 'dials_split_experiments', 'rstats': 'rstats', 'dials.merge_cbf': 'dials_merge_cbf', 'dials.slice_sweep': 'dials_slice_sweep', 'maprot': 'maprot', 'bltsh24': 'bltsh24', 'helpviewer': 'helpviewer', 'znd_subs': 'znd_subs', 'JLogGraph.jar': 'JLogGraph_jar', 'mapro': 'mapro', 'xia2.to_shelxcde': 'xia2_to_shelxcde', 'rmsdev': 'rmsdev', 'tracer': 'tracer', 'cprodrg': 'cprodrg', 'dyndom': 'dyndom', 'hbond': 'hbond', 'img2py': 'img2py', 'reduce': 'reduce', 'tclsh': 'tclsh', 'doser': 'doser', 'extract': 'extract', 'xia2.ispyb_xml': 'xia2_ispyb_xml', 'dials.combine_experiments': 'dials_combine_experiments', 'alt_sg_list': 'alt_sg_list', 'rwcontents': 'rwcontents', 'ccp4sm': 'ccp4sm', 'dtrek2scala': 'dtrek2scala', 'dials.index': 'dials_index', 'loggraph': 'loggraph', 'xia2.get_image_number': 'xia2_get_image_number', 'oasis': 'oasis', 'symop2mat': 'symop2mat', 'acorn': 'acorn', 'qtpisa': 'qtpisa', 'map2fs': 'map2fs', 'save_seg_id': 'save_seg_id', 'rastep': 'rastep', 'ccp4mg': 'ccp4mg', 'mapexchange': 'mapexchange', 'csloop': 'csloop', 'omit': 'omit', 'mtz2various': 'mtz2various', 'rst2html.py': 'rst2html_py', 'render': 'render', 'comit': 'comit', 'dials.import': 'dials_import', 'helixang': 'helixang', 'areaimol': 'areaimol', 'dials.check_indexing_symmetry': 'dials_check_indexing_symmetry', 'ccp4-python': 'ccp4-python', 'jligand': 'jligand', 'pltdev': 'pltdev', 'dials.goniometer_calibration': 'dials_goniometer_calibration', 'postref': 'postref', 'cygdb': 'cygdb', 'tclsh8.4': 'tclsh8_4', 'symfit': 'symfit', 'csfcalc': 'csfcalc', 'dials.analyse_output': 'dials_analyse_output', 'iotbx.lattice_symmetry': 'iotbx_lattice_symmetry', 'check_file_DB': 'check_file_DB', 'coordconv': 'coordconv', 'giant.strip_conformations': 'giant_strip_conformations', 'coot-make-shelx-restraints': 'coot-make-shelx-restraints', 'mkdssp': 'mkdssp', 'dials.combine_found_spots': 'dials_combine_found_spots', 'solomon': 'solomon', 'xia2.add_free_set': 'xia2_add_free_set', 'ncsmask': 'ncsmask', 'convert2mtz': 'convert2mtz', 'dials.show_dist_paths': 'dials_show_dist_paths', 'xia2.plot_multiplicity': 'xia2_plot_multiplicity', 'csequins': 'csequins', 'prosmart_restrain': 'prosmart_restrain', 'bulking': 'bulking', 'prasa': 'prasa', 'OpenAstexViewer.jar': 'OpenAstexViewer_jar', 'rotmat': 'rotmat', 'wilson': 'wilson', 'mtz2sca': 'mtz2sca', 'coot-available-comp-id': 'coot-available-comp-id', 'rantan': 'rantan', 'cparrot': 'cparrot', 'dials.reindex': 'dials_reindex', 'xia2.rescale': 'xia2_rescale', 'tffc': 'tffc', 'binsort': 'binsort', 'rfcorr': 'rfcorr', 'combat': 'combat', 'mkdssp-2.1': 'mkdssp-2_1', 'xia2.npp': 'xia2_npp', 'phaser': 'phaser', 'get_chain': 'get_chain', 'sapi': 'sapi', 'coot-fix-nomenclature-errors': 'coot-fix-nomenclature-errors', 'stereo': 'stereo', 'pdbhtf': 'pdbhtf', 'rst2latex.py': 'rst2latex_py', 'dials.stills_process': 'dials_stills_process', 'stereo3d': 'stereo3d', 'blend': 'blend', 'dials.reflection_viewer': 'dials_reflection_viewer', 'dials.python': 'dials_python', 'probe': 'probe', 'pisa': 'pisa', 'dials.import_stream': 'dials_import_stream', 'mapmask': 'mapmask', 'rebatch': 'rebatch', 'header2matr': 'header2matr', 'dials.predict': 'dials_predict', 'hklplot': 'hklplot', 'dials.two_theta_refine': 'dials_two_theta_refine', 'qtrview': 'qtrview', 'rotamer': 'rotamer', 'dm': 'dm', 'ncont': 'ncont', 'bltwish24': 'bltwish24', 'sigmaa': 'sigmaa', 'xplot84driver': 'xplot84driver', 'ccontacts': 'ccontacts', 'subvertpy-fast-export': 'subvertpy-fast-export', 'ffjoin': 'ffjoin', 'cctbx.python': 'cctbx_python', 'buccaneer_pipeline': 'buccaneer_pipeline', 'rapper': 'rapper', 'polarrfn': 'polarrfn', 'astex_viewer': 'astex_viewer', 'xia2.setup': 'xia2_setup', 'xrced': 'xrced', 'pilfont.py': 'pilfont_py', 'coot-density-score-by-residue': 'coot-density-score-by-residue', 'dials.refine_bravais_settings': 'dials_refine_bravais_settings', 'pdbdiff': 'pdbdiff', 'conkit-convert': 'conkit-convert', 'cifdic_to_symtab': 'cifdic_to_symtab', 'dials.rs_mapper': 'dials_rs_mapper', 'ARCIMBOLDO_SHREDDER': 'ARCIMBOLDO_SHREDDER', 'sortmtz': 'sortmtz', 'phaser.sculptor': 'phaser_sculptor', 'find-blobs': 'find-blobs', 'cnautilus': 'cnautilus', 'automask': 'automask', 'xia2.report': 'xia2_report', 'tlsextract': 'tlsextract', 'gesamt': 'gesamt', 'dials.image_viewer': 'dials_image_viewer', 'rst2xetex.py': 'rst2xetex_py', 'pyrogen': 'pyrogen', 'toplist': 'toplist', 'amore': 'amore', 'cavenv': 'cavenv', 'molrep': 'molrep', 'del_heavy': 'del_heavy', 'pdb_pack': 'pdb_pack', 'pdb_extract_sf': 'pdb_extract_sf', 'proclean': 'proclean', 'mtz2hkl': 'mtz2hkl', 'pildriver.py': 'pildriver_py', 'na4tomtz': 'na4tomtz', 'dials.rl_png': 'dials_rl_png', 'scalepack2mtz': 'scalepack2mtz', 'conkit-predict': 'conkit-predict', 'stgrid': 'stgrid', 'pycrust': 'pycrust', 'bltwish': 'bltwish', 'phistats': 'phistats', 'wish8.4': 'wish8_4', 'viewhkl': 'viewhkl', 'xia2.overload': 'xia2_overload', 'balbes': 'balbes', 'dmmulti': 'dmmulti', 'xia2.old': 'xia2_old', 'lidia': 'lidia', 'hklview': 'hklview', 'mplot': 'mplot', 'tplot': 'tplot', 'dials.refine': 'dials_refine', 'mrbump': 'mrbump', 'vecsum': 'vecsum', 'dials.report': 'dials_report', 'watertidy': 'watertidy', 'anglen': 'anglen', 'peakmax': 'peakmax', 'difres': 'difres', 'angles': 'angles', 'mtz2cif': 'mtz2cif', 'getax': 'getax', 'avs2ps': 'avs2ps', 'giant.score_model': 'giant_score_model', 'spicker_omp': 'spicker_omp', 'dials.modify_geometry': 'dials_modify_geometry', 'pyshell': 'pyshell', 'dials.shadow_plot': 'dials_shadow_plot', 'rst2s5.py': 'rst2s5_py', 'privateer-validate': 'privateer-validate', 'csymmatch': 'csymmatch', 'dials.export': 'dials_export', 'normal3d': 'normal3d', 'bones2pdb': 'bones2pdb', 'tlsanl': 'tlsanl', 'dials.show_build_path': 'dials_show_build_path', 'surface': 'surface', 'idiffdisp': 'idiffdisp', 'search_DB': 'search_DB', 'dtrek2mtz': 'dtrek2mtz', 'mtzdump': 'mtzdump', 'img2png': 'img2png', 'pyrvapi': 'pyrvapi', 'stnet': 'stnet', 'domain2chain': 'domain2chain', 'dials.spot_resolution_shells': 'dials_spot_resolution_shells', 'xia2.rogues_gallery': 'xia2_rogues_gallery', 'mapdump': 'mapdump', 'dials.version': 'dials_version', 'topp': 'topp', 'xia2': 'xia2', 'cmakereference': 'cmakereference', 'superpose': 'superpose', 'xia2.strategy': 'xia2_strategy', 'dials.detect_blanks': 'dials_detect_blanks', 'cmtzjoin': 'cmtzjoin', 'contact': 'contact', 'xia2.show_dist_paths': 'xia2_show_dist_paths', 'edstats': 'edstats', 'edstats.pl': 'edstats_pl', 'xia2.bugreport': 'xia2_bugreport', 'nb': 'nb', 'mapdiff': 'mapdiff', 'mat2symop': 'mat2symop', 'pandda.inspect': 'pandda_inspect', 'distang': 'distang', 'reindex': 'reindex', 'rst2xml.py': 'rst2xml_py', 'axissearch': 'axissearch', 'phaser.ensembler': 'phaser_ensembler', 'afro': 'afro', 'cmapcoeff': 'cmapcoeff', 'makedict': 'makedict', 'coot-mini-rsr': 'coot-mini-rsr', 'coot-bfactan': 'coot-bfactan', 'get_heavy': 'get_heavy', 'bp3': 'bp3', 'dials.batch_analysis': 'dials_batch_analysis', 'wxrc-3.0': 'wxrc-3_0', 'rst2odt_prepstyles.py': 'rst2odt_prepstyles_py', 'mapsig': 'mapsig', 'ample': 'ample', 'cpatterson': 'cpatterson', 'chooch': 'chooch', 'libg': 'libg', 'chainsaw': 'chainsaw', 'get-residue-stats.pl': 'get-residue-stats_pl', 'unique': 'unique', 'align_DB': 'align_DB', 'cif2mtz': 'cif2mtz', 'geomcalc': 'geomcalc', 'xia2.python': 'xia2_python', 'xia2.ispyb_json': 'xia2_ispyb_json', 'dials.find_spots_server': 'dials_find_spots_server', 'mtzfix': 'mtzfix', 'r500': 'r500', 'wx-config': 'wx-config', 'findwaters': 'findwaters', 'get_structure_DB': 'get_structure_DB', 'cross_validate': 'cross_validate', 'zanuda': 'zanuda', 'vecref': 'vecref', 'cif2xml': 'cif2xml', 'truncate': 'truncate', 'scala': 'scala', 'icoefl': 'icoefl', 'feckless': 'feckless', 'dials.apply_mask': 'dials_apply_mask', 'cmaplocal': 'cmaplocal', 'secstr': 'secstr', 'ARCIMBOLDO_BORGES': 'ARCIMBOLDO_BORGES', 'add_heavy': 'add_heavy', 'sfcheck': 'sfcheck', 'dials.calc_rmsds': 'dials_calc_rmsds', 'cmapcut': 'cmapcut', 'ctruncate': 'ctruncate', 'cmtzsplit': 'cmtzsplit', 'giant.create_occupancy_params': 'giant_create_occupancy_params', 'check_zero_res.py': 'check_zero_res_py', 'dials.compare_orientation_matrices': 'dials_compare_orientation_matrices', 'apidemo': 'apidemo', 'percent-rank.pl': 'percent-rank_pl', 'mtzinfo': 'mtzinfo', 'maptona4': 'maptona4', 'act': 'act', 'revise': 'revise', 'dials.create_profile_model': 'dials_create_profile_model', 'sfall': 'sfall', 'pdbset': 'pdbset', 'bltsh': 'bltsh', 'overlapmap': 'overlapmap', 'multicomb': 'multicomb', 'pandda.analyse': 'pandda_analyse', 'pointless': 'pointless', 'pyalacarte': 'pyalacarte', 'prep_bulk': 'prep_bulk', 'mtzMADmod': 'mtzMADmod', 'reforigin': 'reforigin', 'cmodeltoseq': 'cmodeltoseq', 'cncsfrommodel': 'cncsfrommodel', 'caniso': 'caniso', 'compar': 'compar', 'dials.plot_reflections': 'dials_plot_reflections', 'cinvfft': 'cinvfft', 'volume': 'volume', 'conkit-msatool': 'conkit-msatool', 'crank': 'crank', 'dials.tutorial': 'dials_tutorial', 'f2cif': 'f2cif', 'ccp4_pipeline_simple': 'ccp4_pipeline_simple', 'diff2jpeg': 'diff2jpeg', 'wish': 'wish', 'matthews_coef': 'matthews_coef', 'imosflm': 'imosflm', 'logview': 'logview', 'xia2.to_shelx': 'xia2_to_shelx', 'PdbView': 'PdbView', 'giant.quick_refine': 'giant_quick_refine', 'pyalamode': 'pyalamode', 'dials.reciprocal_lattice_viewer': 'dials_reciprocal_lattice_viewer', 'TMalign': 'TMalign', 'xia2.delta_cc_half': 'xia2_delta_cc_half', 'xia2.integrate': 'xia2_integrate', 'professs': 'professs', 'dials.export_bitmaps': 'dials_export_bitmaps', 'fffear': 'fffear', 'ccp4i': 'ccp4i', 'acedrg': 'acedrg', 'dials.find_spots': 'dials_find_spots', 'ipmosflm': 'ipmosflm', 'rsps': 'rsps', 'igraph': 'igraph', 'findligand': 'findligand', 'pilfile.py': 'pilfile_py', 'csigmaa': 'csigmaa', 'findncs': 'findncs', 'r500ccp4': 'r500ccp4', 'dials.background': 'dials_background', 'xia2.chef': 'xia2_chef', 'dials.discover_better_experimental_model': 'dials_discover_better_experimental_model', 'mama2ccp4': 'mama2ccp4', 'watpeak': 'watpeak', 'pdb_extract': 'pdb_extract', 'mlphare': 'mlphare', 'probplot': 'probplot', 'coord_format': 'coord_format'} def dispatcher_builder(program, cmd_args = None, keywords = None, capture_streams = True, stdout = None, stderr = None): """Convenience factory function to set up and return a dispatcher in one line, using the original program name""" try: modulename = prog_to_dispatcher[program] except KeyError: msg = program + " is not found in the mapping to dispatchers" raise KeyError, msg _temp = __import__(modulename, globals(), locals(), ["Dispatcher"], -1) Dispatch = _temp.Dispatcher(capture_streams, stdout, stderr) if cmd_args: Dispatch.set_cmd_args(cmd_args) if keywords: Dispatch.set_keywords(keywords) return Dispatch def call_here(program, key, cmdline, workingDIR, function=""): """Convenience function to set up and call a dispatcher in one line, writing output to files, principally for MrBump""" logfile = os.path.join(workingDIR, "%s%s.log" % (program, function)) errfile = os.path.join(workingDIR, "%s%s.err" % (program, function)) # Generate a shell script for this job if os.name != "nt": scriptfile = os.path.join(workingDIR, "%s%s.script" % (program, function)) s = open(scriptfile,"w") s.write("#!/bin/sh\n") s.write(program + " " + cmdline + " <