Skip to content

Commit 7dcd091

Browse files
committed
Update GUI
1 parent e33ccef commit 7dcd091

File tree

3 files changed

+188
-111
lines changed

3 files changed

+188
-111
lines changed

beams/gui.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,21 +259,14 @@ def add_databases(self):
259259
keys = inp.readline().strip().split("\t")
260260
for line in inp:
261261
line = line.split("\t")
262-
if os.path.isfile(os.path.join(path, line[keys.index("filename_sqlite")])):
263-
list_databases[line[keys.index("filename_sqlite")]] = line[keys.index("description")]
264-
conn = sqlite3.connect(os.path.join(path, list_databases.keys()[0]))
265-
cursor = conn.cursor()
266-
cursor.execute("""SELECT name FROM sqlite_master where type='table'""")
267-
db_names = [str(name[0]) for name in cursor.fetchall()]
268-
for i, db in enumerate(list_databases.keys()[1:]):
269-
cursor.execute("ATTACH DATABASE ? AS db?", (os.path.join(path, dbs[i+1]), i, ))
270-
cursor.execute("""SELECT name FROM db?.sqlite_master where type='table'""", (i, ))
271-
db_names.extend([str(name[0]) for name in cursor.fetchall()])
262+
if os.path.isfile(os.path.join(path, line[keys.index("database_name")] + ".sql.gz")):
263+
list_databases[line[keys.index("database_name")]] = line[keys.index("description")]
264+
272265
self.listWidget_databases.setSelectionMode(QtWidgets.QListWidget.MultiSelection)
273266
for description in list_databases.values():
274267
item = QtWidgets.QListWidgetItem(description)
275268
self.listWidget_databases.addItem(item)
276-
return dict((v, k) for k, v in list_databases.iteritems())
269+
return dict((v, k) for k, v in list_databases.items())
277270

278271
def run(self):
279272

@@ -342,7 +335,7 @@ def run(self):
342335
else:
343336
QtWidgets.QMessageBox.critical(None, "Select file", "Provide a valid filename for adducts or 'Use default'", QtWidgets.QMessageBox.Ok)
344337

345-
annotation.annotate_adducts(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_ppm_error.value(), lib=lib)
338+
annotation.annotate_adducts(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_pp_ppm_error.value(), lib=lib)
346339
print("Done")
347340

348341
if self.checkBox_isotopes.isChecked():
@@ -356,7 +349,7 @@ def run(self):
356349
lib = in_out.read_isotopes(self.lineEdit_isotopes.text(), lib_ion_mode[self.comboBox_ion_mode.currentText()])
357350
else:
358351
QtWidgets.QMessageBox.critical(None, "Select file", "Provide a valid filename for isotopes or 'Use default'", QtWidgets.QMessageBox.Ok)
359-
annotation.annotate_isotopes(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_ppm_error.value(), lib=lib)
352+
annotation.annotate_isotopes(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_pp_ppm_error.value(), lib=lib)
360353
print("Done")
361354

362355
if self.checkBox_multiple_charged.isChecked():
@@ -369,7 +362,7 @@ def run(self):
369362
lib = in_out.read_multiple_charged_ions(self.lineEdit_multiple_charged.text(), lib_ion_mode[self.comboBox_ion_mode.currentText()])
370363
else:
371364
QtWidgets.QMessageBox.critical(None, "Select file", "Provide a valid filename for multiple charged ions or 'Use default'", QtWidgets.QMessageBox.Ok)
372-
annotation.annotate_multiple_charged_ions(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_ppm_error.value(), lib=lib)
365+
annotation.annotate_multiple_charged_ions(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_pp_ppm_error.value(), lib=lib)
373366
print("Done")
374367

375368
if self.checkBox_oligomers.isChecked():
@@ -388,7 +381,7 @@ def run(self):
388381
else:
389382
QtWidgets.QMessageBox.critical(None, "Select file", "Provide a valid filename for adducts", QtWidgets.QMessageBox.Ok)
390383
inp = in_out.combine_peaklist_matrix(self.lineEdit_peaklist.text(), self.lineEdit_intensity_matrix.text())
391-
annotation.annotate_oligomers(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_ppm_error.value(), lib=lib, maximum=self.spinBox_max_monomer_units.value())
384+
annotation.annotate_oligomers(inp, db_out=self.lineEdit_sql_database.text(), ppm=self.doubleSpinBox_pp_ppm_error.value(), lib=lib, maximum=self.spinBox_max_monomer_units.value())
392385
print("Done")
393386
print
394387

@@ -420,7 +413,7 @@ def run(self):
420413

421414
annotation.annotate_molecular_formulae(df,
422415
lib_adducts=lib,
423-
ppm=self.doubleSpinBox_ppm_error.value(),
416+
ppm=self.doubleSpinBox_mf_ppm_error.value(),
424417
db_out=self.lineEdit_sql_database.text(),
425418
db_in=db_in,
426419
rules=rules,
@@ -446,12 +439,12 @@ def run(self):
446439
QtWidgets.QMessageBox.critical(None, "Select file", "Provide a valid filename for adducts", QtWidgets.QMessageBox.Ok)
447440

448441
if self.checkBox_filename_reference.isChecked():
449-
annotation.annotate_compounds(df, lib_adducts=lib, ppm=self.doubleSpinBox_ppm_error.value(),
442+
annotation.annotate_compounds(df, lib_adducts=lib, ppm=self.doubleSpinBox_cpds_ppm_error.value(),
450443
db_out=self.lineEdit_sql_database.text(), db_name=None, db_in=self.lineEdit_filename_reference.text())
451444
else:
452445
for db_name in self.listWidget_databases.selectedItems():
453-
annotation.annotate_compounds(df, lib_adducts=lib, ppm=self.doubleSpinBox_ppm_error.value(),
454-
db_out=self.lineEdit_sql_database.text(), db_name=self.db_names[db_name.text()].strip(".sqlite"))
446+
annotation.annotate_compounds(df, lib_adducts=lib, ppm=self.doubleSpinBox_cpds_ppm_error.value(),
447+
db_out=self.lineEdit_sql_database.text(), db_name=self.db_names[db_name.text()])
455448
print("Done")
456449
print
457450

0 commit comments

Comments
 (0)