schrodinger.application.matsci.polymer_gui module

Shared GUI components for polymer builder panels.

This module provides shared classes and functions used by both polymer_builder_gui.py and semi_crystal_builder_gui.py.

Monomer templates are located in polymer_builder_gui_dir/, which is accessed via the polymer_builder_gui script module.

schrodinger.application.matsci.polymer_gui.get_polymer_builder_gui_path()

Get the path to polymer_builder_gui.py script.

Uses lazy import to avoid circular dependency (polymer_builder_gui imports this module, so we can’t import it at module level).

Return type:

str

Returns:

absolute path to polymer_builder_gui.py

schrodinger.application.matsci.polymer_gui.check_struct_type(ws_struct, is_all_atom)

Check whether the structure satisfies the all-atom / coarse-grained requirement.

Parameters:
  • ws_struct (Structure) – the structure to check against

  • is_all_atom (bool) – require the struct to be all-atom if True

Return type:

str

Returns:

The error message if the structure doesn’t satisfy the requirement, or empty str if the structure satisfies it.

schrodinger.application.matsci.polymer_gui.get_monomer_categories()

Reads the file that contains the categories of the built-in monomer templates. Note that this function uses caching so that the file is read once per import.

Return dict(dict(bool)):

A nested dictionary whose keys are the monomer names and whose values are subdictionaries. The subdictionaries’ keys are the categories and the values are Booleans, which indicate whether the corresponding monomer falls under the corresponding category.

schrodinger.application.matsci.polymer_gui.get_unique_monomer_categories()

Reads all the monomer categories in our file and returns all unique, listed categories. Note that this function uses caching so that the file is read once per import.

Return type:

set(str)

Returns:

All the categories listed in our monomer category file

class schrodinger.application.matsci.polymer_gui.MonomerListWidgetItem(text, *args, **kwargs)

Bases: QListWidgetItem

Custom QListWidgetItem that is associated with a specific template

CATEGORY_PREFIX = 'is_'
__init__(text, *args, **kwargs)
Parameters:

text (str) – The name of the monomer

class schrodinger.application.matsci.polymer_gui.MonomerTemplateSelectorFilterListPopUp(parent, autowidth=True)

Bases: TemplateSelectorFilterListPopUp

A pop up widget that allows for dynamic filtering and selection of monomer templates

ITEM_TYPE = 'monomer'
class schrodinger.application.matsci.polymer_gui.MonomerTemplateSelectorFilterListToolButton(parent)

Bases: TemplateSelectorFilterListToolButton

Custom tool button with a selector filter list pop up for monomer templates

POP_UP_CLASS

alias of MonomerTemplateSelectorFilterListPopUp

class schrodinger.application.matsci.polymer_gui.MonomerTemplateSelector(*args, **kwargs)

Bases: TemplateSelector

A frame that allows the user to specify a monomer template from a pop up list.

TOOL_BUTTON_CLASS

alias of MonomerTemplateSelectorFilterListToolButton

__init__(*args, **kwargs)

Initialize the MonomerTemplateSelector.

class schrodinger.application.matsci.polymer_gui.EndGroupRow(master, row_layout, item_type, **kwargs)

Bases: ItemRowWithTemplates

A base ItemRowWithTemplates class with a few defaults common to all rows

SKETCHER_CLASS = 'sketcher_class'
__init__(master, row_layout, item_type, **kwargs)

See parent class for argument documentation

class schrodinger.application.matsci.polymer_gui.SingleRxBondMixin

Bases: object

A mixin for SketcherBox classes that enforces correct marker bonding

validateRAtomStructure(struct, rx_atoms, max_x)

Structure-based check that the user has indicated Rx atoms properly

Parameters:
  • struct (Structure) – the structure with Rx atoms

  • rx_atoms (dict) – keys are Rx x values and values are lists of atom indexes marked with that Rx value

  • max_x (int) – The maximum value of the keys in rx_atoms

Return type:

bool

Returns:

True if valid, False if not

class schrodinger.application.matsci.polymer_gui.MonomerSketcher(*args, **kwargs)

Bases: SingleRxBondMixin, SketcherBox

Sketcher widget for drawing and validating polymer monomers.

Supports standard (R1/R2 head-tail) and ladder (R1–R4) monomer types. Validates Rx atom assignments before the structure is accepted.

MONOMER_SKETCHER = 'Monomer Sketcher'
LADDER_MONOMER_SKETCHER = 'Ladder Monomer Sketcher'
NAMES = {'All-atom': 'Monomer Sketcher', 'Ladder': 'Ladder Monomer Sketcher'}
__init__(*args, **kwargs)

See the parent class for documentation

setName(monomer_type)

Set the name of the sketcher.

Parameters:

monomer_type (str) – monomer type

validateRAtomIdentity(rx_atoms, max_x)

Check that the user has indicated Rx atoms properly

Parameters:
  • rx_atoms (dict) – keys are Rx x values and values are lists of atom indexes marked with that Rx value

  • max_x (int) – The maximum value of the keys in rx_atoms

Return type:

bool

Returns:

True if valid, False if not

validateLadderRAtomIdentity(rx_atoms, max_x)

Check that the user has indicated Rx atoms properly for ladder monomer.

Parameters:
  • rx_atoms (dict) – keys are Rx x values and values are lists of atom indexes marked with that Rx value

  • max_x (int) – The maximum value of the keys in rx_atoms

Return type:

bool

Returns:

True if valid, False if not

validateRAtomStructure(struct, rx_atoms, max_x)

Check that the R1 and R2 atoms are end groups with > 1 atom connecting them.

Parameters:
  • struct (Structure) – the structure with Rx transmuted to Temp Element

  • rx_atoms (dict) – keys are Rx x values and values are lists of atom indexes marked with that Rx value

  • max_x (int) – The maximum value of the keys in rx_atoms

Return type:

bool

Returns:

True if valid, False if not

readWorkspaceStructure(struct, rx_atoms)

Read the structure into the sketcher

Parameters:
  • struct (Structure) – a monomer structure

  • rx_atoms (dict) – keys are Rx x values and values are lists of atom indexes marked with that Rx value

class schrodinger.application.matsci.polymer_gui.MarkHeadTailPanel(parent, is_all_atom=True)

Bases: MarkHeadTailPanel

Extended head/tail marking panel that also supports capping atom picking.

Adds a pick-type radio button group (monomer head/tail vs capping atoms) and tracks capping atom markers per entry.

PICK_TYPE = 'Pick type'
HEAD_TAIL_ATOM = 'Monomer head and tail atoms'
CAPPING_ATOM = 'Capping atoms'
PICK_CAPPING_TEXT = 'Pick head capping atom then tail capping atom'
HEADTAIL_CAPPERS = ['head_capper', 'tail_capper']
ADD_CAPPING_PROPS = False
__init__(parent, is_all_atom=True)
Parameters:
  • parent (Qt Widgets) – parent Qt widget

  • is_all_atom (bool) – the structure in workspace should be all-atom, if True

Convert a panel to subpanel with dialog style.

layOut()

Only allow WORKSPACE mode for monomer definition.

pickTypeChange()

React to the change of atom pick type.

atomPicked(index)

React to an atom being picked in the Workspace

Parameters:

index (int) – The index of the atom in the Workspace structure that was picked

getAttachedAtomIndex(atom, element='any', skip_atom_ids=None)

Find the index of a random atom of the element attached to this atom

Parameters:
  • atom (schrodinger.structure._StructureAtom) – The atom to look for H neighbors of

  • element (str) – atom element str or ‘any’

  • skip_atom_ids (None or list of int) – a set of atom ids to skip

Return type:

int or None

Returns:

The atom index of an attached hydrogen, or None if there are no hydrogen atoms attached

setHeadTail(struct)

Set the head and tail properties on struct

Parameters:

struct (Structure) – The structure to create properties on

Return type:

str or None

Returns:

A message desribing any error that occured, or None if no error occurred.

resetHeadTail(update_label=True)

Reset the head and tail list

Parameters:

update_label (bool) – If True, update the label to reflect the reset

getCappedAndCappingAtoms(atom, is_capping_atom=False)

Find the index of the (head or tail) atom and the capping atom.

Parameters:
  • atom (schrodinger.structure._StructureAtom) – The atom to look for H neighbors of

  • is_capping_atom (bool) – If True, the input atom is a terminating atom. If False, the hydrogen attached to the input atom is the capping atom.

Return type:

tuple

Returns:

The capped atom and the capping atom.

Raises:

TypeError – Cannot find a proper atom pair.

setAndSaveMonomer(struct=None, silent=False)

Set the struct, validate the loaded model, and save to the master panel. This is useful when using this panel without clicking the start button. (e.g. in response to entry change)

Parameters:
  • struct (Structure) – the structure to be loaded

  • silent (bool) – if False, allow error dialog to pop up

saveAndClose()

Save the monomer to the parent panel. Note that one validator sets the structure and thus the start button can directly save the struct.

setAndvalidateModel(struct=None, silent=None)

Load the struct and validate the loaded model.

Parameters:
  • struct (Structure) – the structure to be loaded

  • silent (bool or None) – If True, no error dialog pops; if silent = None and the mark head tail panel is not visible, skip this validation.

Returns:

passed, warning, or error

Return type:

bool or (bool, msg)

setStruct(struct)

Set the structure for this panel.

Parameters:

struct (Structure) – the struct to be set as the loaded structure. If None, try to get one from the entry

Raises:

RuntimeError – if no included entry

validateStruct(struct=None)

Validate the structure.

Parameters:

struct (Structure) – the struct to be validated.

Raises:

ValueError, TypeError – if struct doesn’t satisfy any criteria

saveToMonomerRow()

Save the struct to the monomer row. (e.g. sketcher as well for all-atom)

cancelAndClose()

Add a cancel button for mac dialog. (MATSCI-5800)

getRxAtomIndexes(struct)

Get Rx atoms from workspace. R1 caps polymer head atom and R2 caps polymer tail atom.

Parameters:

struct (Structure) – the structure with head and tail atom marked

Rtype rx_atoms:

dict

Return rx_atoms:

keys are Rx x values and values are lists of atom indexes marked with that Rx value

setBackboneProperty(struct)

Set the backbone property on the structure.

Parameters:

struct (Structure) – structure whose backbone atoms will be marked

pickStateChanged()

Overwrite the parent method to remove capping markers.

addCappingMarker(atom, **kwargs)

Add a marker for the a capping atom and record the marker by entry.

Parameters:

atom (schrodinger.structure._StructureAtom) – The capping atom

removeAllCappingMarkers()

Remove all capping markers.

removeAllCappingMarkersForEntry(eid)

Remove all capping markers for specific entry id.

Parameters:

eid (str) – The entry id to remove markers for

entriesExcluded(eids)

React to one or more entries being excluded.

Parameters:

eids (list of str) – List of entry ids that have become excluded.