"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/pmg_qt/file_dialogs.py" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

file_dialogs.py  (pymol-open-source-2.2.0):file_dialogs.py  (pymol-open-source-2.3.0)
skipping to change at line 31 skipping to change at line 31
''' '''
if '://' not in fname: if '://' not in fname:
parent.initialdir = os.path.dirname(fname) parent.initialdir = os.path.dirname(fname)
parent.recent_filenames_add(fname) parent.recent_filenames_add(fname)
format = pymol.importing.filename_to_format(fname)[2] format = pymol.importing.filename_to_format(fname)[2]
if fname[-4:] in ['.dcd', '.dtr']: if fname[-4:] in ['.dcd', '.dtr']:
load_traj_dialog(parent, fname) load_traj_dialog(parent, fname)
elif format in ('aln', 'fasta'):
load_aln_dialog(parent, fname)
elif format == 'mae': elif format == 'mae':
load_mae_dialog(parent, fname) load_mae_dialog(parent, fname)
elif format == 'ccp4': elif format == 'ccp4':
load_map_dialog(parent, fname, 'ccp4') load_map_dialog(parent, fname, 'ccp4')
elif format == 'brix': elif format == 'brix':
load_map_dialog(parent, fname, 'o') load_map_dialog(parent, fname, 'o')
elif format == 'mtz': elif format == 'mtz':
load_mtz_dialog(parent, fname) load_mtz_dialog(parent, fname)
else: else:
if format in ('pse', 'psw') and not ask_partial(parent, kwargs, fname): if format in ('pse', 'psw') and not ask_partial(parent, kwargs, fname):
skipping to change at line 181 skipping to change at line 183
form.input_reso_min.value(), form.input_reso_min.value(),
form.input_reso_max.value(), form.input_reso_max.value(),
quiet=0) quiet=0)
except BaseException as e: except BaseException as e:
QtWidgets.QMessageBox.critical(parent, "Error", str(e)) QtWidgets.QMessageBox.critical(parent, "Error", str(e))
form._dialog.accepted.connect(run) form._dialog.accepted.connect(run)
form._dialog.setModal(True) form._dialog.setModal(True)
form._dialog.show() form._dialog.show()
def load_aln_dialog(parent, filename):
_self = parent.cmd
import numpy
import difflib
import pymol.seqalign as seqalign
alignment = seqalign.aln_magic_read(filename)
except ValueError:
# fails for fasta files which don't contain alignments
# alignment record ids and PyMOL model names
ids = [rec.id for rec in alignment]
ids_remain = list(ids)
models = _self.get_object_list()
models_remain = list(models)
mapping = {}
N = len(ids)
M = len(models)
# ids -> models similarity matrix
similarity = numpy.zeros((N, M))
for i in range(N):
for j in range(M):
similarity[i, j] = difflib.SequenceMatcher(None,
ids[i], models[j], False).ratio()
# guess mapping
for _ in range(min(N, M)):
i, j = numpy.unravel_index(similarity.argmax(), similarity.shape)
mapping[ids_remain.pop(i)] = models_remain.pop(j)
similarity = numpy.delete(similarity, i, axis=0)
similarity = numpy.delete(similarity, j, axis=1)
form = parent.load_form('load_aln')
comboboxes = {}
# mapping GUI
for row, rec_id in enumerate(ids, 1):
label = QtWidgets.QLabel(rec_id, form._dialog)
combobox = QtWidgets.QComboBox(form._dialog)
combobox.setCurrentText(mapping.get(rec_id, ""))
form.layout_mapping.addWidget(label, row, 0)
form.layout_mapping.addWidget(combobox, row, 1)
comboboxes[rec_id] = combobox
def run():
mapping = dict((rec_id, combobox.currentText())
for (rec_id, combobox) in comboboxes.items())
seqalign.load_aln_multi(filename, mapping=mapping, _self=_self)
# hook up events
def load_mae_dialog(parent, filename): def load_mae_dialog(parent, filename):
form = parent.load_form('load_mae') form = parent.load_form('load_mae')
form.input_object_name.setPlaceholderText( form.input_object_name.setPlaceholderText(
pymol.importing.filename_to_objectname(filename)) pymol.importing.filename_to_objectname(filename))
form.input_object_props.setText(parent.cmd.get('load_object_props_default') or '*') form.input_object_props.setText(parent.cmd.get('load_object_props_default') or '*')
form.input_atom_props.setText(parent.cmd.get('load_atom_props_default') or ' *') form.input_atom_props.setText(parent.cmd.get('load_atom_props_default') or ' *')
def get_command(*args): def get_command(*args):
command = ('load \\\n %s' % (filename)) command = ('load \\\n %s' % (filename))
name = form.input_object_name.text() name = form.input_object_name.text()
if name: if name:
command += ', \\\n ' + name command += ', \\\n ' + name
command += ', \\\n mimic=' + ('1' if form.input_mimic.isChecked() els e '0') command += ', \\\n mimic=' + ('1' if form.input_mimic.isChecked() els e '0')
command += ( command += (
', \\\n object_props=%s' ', \\\n object_props=%s'
', \\\n atom_props=%s' % ( ', \\\n atom_props=%s' % (
form.input_object_props.text(), form.input_object_props.text(),
form.input_atom_props.text())) form.input_atom_props.text()))
multiplex = [-2, 0, 1][form.input_multiplex.currentIndex()]
if multiplex != -2:
command += ', \\\n multiplex={}'.format(multiplex)
return command return command
def update_output_command(*args): def update_output_command(*args):
form.output_command.setText(get_command()) form.output_command.setText(get_command())
def run(): def run():
parent.cmd.do(get_command()) parent.cmd.do(get_command())
form._dialog.close() form._dialog.close()
# hook up events # hook up events
form.input_mimic.stateChanged.connect(update_output_command) form.input_mimic.stateChanged.connect(update_output_command)
form.input_object_name.textChanged.connect(update_output_command) form.input_object_name.textChanged.connect(update_output_command)
form.input_object_props.textChanged.connect(update_output_command) form.input_object_props.textChanged.connect(update_output_command)
form.input_atom_props.textChanged.connect(update_output_command) form.input_atom_props.textChanged.connect(update_output_command)
form.button_ok.clicked.connect(run) form.button_ok.clicked.connect(run)
update_output_command() update_output_command()
form._dialog.setModal(True) form._dialog.setModal(True)
form._dialog.show() form._dialog.show()
skipping to change at line 427 skipping to change at line 498
formats = [ formats = [
'PDBx/mmCIF (*.cif *.cif.gz)', 'PDBx/mmCIF (*.cif *.cif.gz)',
'PDB (*.pdb *.pdb.gz)', 'PDB (*.pdb *.pdb.gz)',
'PQR (*.pqr)', 'PQR (*.pqr)',
'MOL2 (*.mol2)', 'MOL2 (*.mol2)',
'MDL SD (*.sdf *.mol)', 'MDL SD (*.sdf *.mol)',
'Maestro (*.mae)', 'Maestro (*.mae)',
'MacroModel (*.mmd *.mmod *.dat)', 'MacroModel (*.mmd *.mmod *.dat)',
'ChemPy Pickle (*.pkl)', 'ChemPy Pickle (*.pkl)',
'XYZ (*.xyz)', 'XYZ (*.xyz)',
'MMTF (*.mmtf)',
'By Extension (*.*)', 'By Extension (*.*)',
] ]
@PopupOnException.decorator @PopupOnException.decorator
def run(*_): def run(*_):
selection = form.input_selection.currentText() or default_selection selection = form.input_selection.currentText() or default_selection
state = int(form.input_state.currentText().split()[0]) state = int(form.input_state.currentText().split()[0])
parent.cmd.set('pdb_conect_nodup', not form.input_no_pdb_conect_nodup .isChecked()) parent.cmd.set('pdb_conect_nodup', not form.input_no_pdb_conect_nodup .isChecked())
parent.cmd.set('pdb_conect_all', form.input_pdb_conect_all.isCh ecked()) parent.cmd.set('pdb_conect_all', form.input_pdb_conect_all.isCh ecked())
 End of changes. 5 change blocks. 
0 lines changed or deleted 72 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)