Source code for schrodinger.ui.sequencealignment.align_gui

"""
Alignment settings dialog.

Copyright Schrodinger, LLC. All rights reserved.
"""

# Contributors: Piotr Rotkiewicz

from schrodinger.Qt import QtGui
from schrodinger.Qt import QtWidgets

from . import constants  # noqa: F401

_ALIGNMENT_SETTINGS_DIALOG = None


[docs]class AlignmentSettingsDialog(QtWidgets.QDialog): """ This class implements the "Alignment Settings" dialog. """
[docs] def __init__(self, parent): # Initialize base class. QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle("Pairwise Alignment Settings") #: Custom matrix push button. self.button_custom = QtWidgets.QPushButton(self) self.button_custom.setText( "Create Substitution Matrix from the Alignment") self.button_custom.clicked.connect(self.createMatrix) self.button_ok = QtWidgets.QPushButton(self) self.button_ok.setText("OK") self.button_ok.setDefault(True) self.button_ok.clicked.connect(self.accept) self.layout = QtWidgets.QVBoxLayout(self) self.matrix_choice = QtWidgets.QComboBox(self) self.matrices = [ "PAM250", "BLOSUM45", "BLOSUM62", "BLOSUM80", "GONNET", "Custom" ] for matrix in self.matrices: self.matrix_choice.addItem(matrix) self.matrix_choice.currentIndexChanged.connect(self.similarityMatrix) self.matrix_choice.setCurrentIndex(2) self.layout.addWidget(self.matrix_choice) #: Gap Opening Penalty label = QtWidgets.QLabel("Gap Opening Penalty") self.gap_open_input = QtWidgets.QLineEdit() self.gap_open_input.setText("-10.0") self.gap_open_input.setValidator( QtGui.QDoubleValidator(-100.0, 100.0, 1, self.gap_open_input)) gap_layout = QtWidgets.QHBoxLayout() gap_layout.addWidget(label) gap_layout.addWidget(self.gap_open_input) self.layout.addLayout(gap_layout) #: Gap Extension Penalty label = QtWidgets.QLabel("Gap Extension Penalty") self.gap_extend_input = QtWidgets.QLineEdit() self.gap_extend_input.setText("-1.0") self.gap_extend_input.setValidator( QtGui.QDoubleValidator(-100.0, 100.0, 1, self.gap_extend_input)) gap_layout = QtWidgets.QHBoxLayout() gap_layout.addWidget(label) gap_layout.addWidget(self.gap_extend_input) self.layout.addLayout(gap_layout) self.allow_ssa_gaps = QtWidgets.QCheckBox( "Allow gaps in secondary structure elements") self.allow_ssa_gaps.setChecked(True) self.layout.addWidget(self.allow_ssa_gaps) spacer = QtWidgets.QWidget() spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.button_layout = QtWidgets.QHBoxLayout() self.button_layout.addWidget(self.button_custom) self.button_layout.addWidget(spacer) self.button_layout.addWidget(self.button_ok) self.layout.addLayout(self.button_layout) self.sizePolicy().setVerticalPolicy(QtWidgets.QSizePolicy.Maximum) self.group = None
[docs] def similarityMatrix(self, index): global constants constants.SIMILARITY_MATRIX = constants.BLOSUM62 if self.matrices[index] == "BLOSUM80": constants.SIMILARITY_MATRIX = constants.BLOSUM80 elif self.matrices[index] == "BLOSUM45": constants.SIMILARITY_MATRIX = constants.BLOSUM45 elif self.matrices[index] == "GONNET": constants.SIMILARITY_MATRIX = constants.GONNET elif self.matrices[index] == "PAM250": constants.SIMILARITY_MATRIX = constants.PAM250
[docs] def createMatrix(self): """ Creates a new mutation matrix. """ self.group.calculateMatrix()
[docs] def gapPenalties(self): """ Returns alignment gap penalties. """ return (float(self.gap_open_input.text()), float(self.gap_extend_input.text()))
[docs] def allowSSGaps(self): """ Returns gaps in SSE status. """ return self.allow_ssa_gaps.isChecked()