Skip to content

Instantly share code, notes, and snippets.

@cstein
Last active December 20, 2018 07:35
Show Gist options
  • Save cstein/dc3e2fa56c3b4b7dc8f96615bfe819ad to your computer and use it in GitHub Desktop.
Save cstein/dc3e2fa56c3b4b7dc8f96615bfe819ad to your computer and use it in GitHub Desktop.
simple script for maestro to extract QM and MM regions from a single .pdb
from schrodinger import maestro
from schrodinger import structure
import PyQt5
from PyQt5.QtWidgets import QFileDialog
__doc__ = """
Extracts QM region around molecule.
"""
#Name: QM/MM:Extract
#Command: pythonrun qmmm.extract
value = None
pt = maestro.project_table_get()
def extract():
dialog = QFileDialog()
dialog.setFileMode(QFileDialog.DirectoryOnly)
directory = None
if dialog.exec_() == QFileDialog.Accepted:
directory = dialog.selectedFiles()[0]
if directory is None:
maestro.warning("No folder was specified. Aborting.")
return
row_data = [(row.entry_id, row.title) for row in pt.selected_rows]
for k, (entry_id, title) in enumerate(row_data, start=1):
maestro.command('entrywsincludeonly entry {} '.format(entry_id))
maestro.command('workspaceselectionreplace mol.num 1')
maestro.command('workspaceselectionadd fillres within 3.0 atom.selected')
maestro.command('entrywscreate removefromsource=false "tmp" atom.selected')
maestro.command('entryexport files=single format=pdb "{0:s}/qm_{1:s}_{2:d}.pdb"'.format(directory, title, k))
maestro.command('entrydelete')
maestro.command('entrywsincludeonly entry {} '.format(entry_id))
maestro.command('workspaceselectionreplace mol.num 1')
maestro.command('workspaceselectionadd fillres within 3.0 atom.selected')
maestro.command('workspaceselectioninvert all')
maestro.command('entrywscreate removefromsource=false "tmp" atom.selected')
maestro.command('entryexport files=single format=pdb "{0:s}/mm_{1:s}_{2:d}.pdb"'.format(directory, title, k))
maestro.command('entrydelete')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment