Skip to content

Commit

Permalink
Merge pull request #491 from marrink-lab/dssp_check
Browse files Browse the repository at this point in the history
check dssp version before running DSSP
  • Loading branch information
fgrunewald authored Dec 2, 2022
2 parents 9192386 + 4e093f3 commit 0d4af35
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vermouth/dssp/dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def read_dssp2(lines):
return secstructs


def run_dssp(system, executable='dssp', savefile=None, defer_writing=True):
def run_dssp(system, executable='dssp', savefile=None, defer_writing=True, version="3.0.0"):
"""
Run DSSP on a system and return the assigned secondary structures.
Expand Down Expand Up @@ -172,6 +172,8 @@ def run_dssp(system, executable='dssp', savefile=None, defer_writing=True):
If set to a path, the output of DSSP is written in that file.
defer_writing: bool
Whether to use :meth:`~vermouth.file_writer.DeferredFileWriter.write` for writing data
version: str
Supported versions for running dssp
Returns
list[str]
Expand All @@ -191,6 +193,12 @@ def run_dssp(system, executable='dssp', savefile=None, defer_writing=True):
read_dssp2
Parse a DSSP output.
"""
# check version
process = subprocess.run(["dssp", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
version_found = process.stdout.decode('UTF8')
if version not in version_found:
raise DSSPError('Vermouth currently only supports DSSP version 3.0.0.')

tmpfile_handle, tmpfile_name = tempfile.mkstemp(suffix='.pdb', text=True,
dir='.', prefix='dssp_in_')
tmpfile_handle = os.fdopen(tmpfile_handle, mode='w')
Expand Down

0 comments on commit 0d4af35

Please sign in to comment.