diff --git a/modules/bindings/pymod/dssp.py b/modules/bindings/pymod/dssp.py index 56f78bd059a60e73977ef918614c6945d030c989..6e60c1c8ddb7dcfa2a4c626da030fa9de7e6da56 100644 --- a/modules/bindings/pymod/dssp.py +++ b/modules/bindings/pymod/dssp.py @@ -44,12 +44,17 @@ def _Cleanup(pdb_path, temp_path, entity_saved): if os.path.exists(temp_path): os.remove(temp_path) -def _ExecuteDSSP(path, temp_dir=None): +def _ExecuteDSSP(path, dssp_bin, temp_dir=None): # use of mktemp is a safty problem (use mkstemp and provide file handle to # subsequent process temp_dssp_path=tempfile.mktemp(suffix=".out",prefix="dssp", dir=temp_dir) - dssp_abs_path=settings.Locate('dssp', env_name='DSSP_EXECUTABLE') - assert os.path.exists(path) + dssp_abs_path=settings.Locate('dssp', env_name='DSSP_EXECUTABLE', + explicit_file_name=dssp_bin) + if os.path.isdir(dssp_abs_path): + raise RuntimeError('"%s" is a directory. Specify path to DSSP binary' % dssp_abs_path) + if not os.access(dssp_abs_path, os.X_OK): + raise RuntimeError('"%s" is not executable' % dssp_abs_path) + ps=subprocess.Popen([dssp_abs_path, path, temp_dssp_path], stderr=subprocess.PIPE) err_lines=ps.stderr.readlines() @@ -72,7 +77,8 @@ def _CalcRelativeSA(residue_type, absolute_sa): return rel -def AssignDSSP(ent, pdb_path="", extract_burial_status=False, tmp_dir=None): +def AssignDSSP(ent, pdb_path="", extract_burial_status=False, tmp_dir=None, + dssp_bin=None): """ Assign secondary structure states to peptide residues in the structure. This function uses the DSSP command line program. @@ -85,9 +91,10 @@ def AssignDSSP(ent, pdb_path="", extract_burial_status=False, tmp_dir=None): :param extract_burial_status: If true, also extract burial status :param tmp_dir: If set, overrides the default tmp directory of the operating system - + :param dssp_bin: The path to the DSSP executable :raises: :class:`~ost.settings.FileNotFound` if the dssp executable is not in the path. + :raises: :class:`RuntimeError` when dssp is executed with errors """ entity_saved = False # use of mktemp is a safty problem (use mkstemp and provide file handle to @@ -99,8 +106,9 @@ def AssignDSSP(ent, pdb_path="", extract_burial_status=False, tmp_dir=None): #TODO: exception handling (currently errors occuring here # are handled in the parser LoadDSSP) - temp_dssp_path=_ExecuteDSSP(pdb_path) - + temp_dssp_path=_ExecuteDSSP(pdb_path, dssp_bin) + if not os.path.exists(temp_dssp_path): + raise RuntimeEror('DSSP output file does not exist.') # assign DSSP to entity try: LoadDSSP(temp_dssp_path, ent, extract_burial_status,