Skip to content

Commit

Permalink
Qt: Do not run when empty file dir as flag inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
niklases committed Oct 21, 2024
1 parent 34b5888 commit ab0389c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ A rudimentary graphical user interface (GUI) can be installed using the gui_setu

(Windows PowerShell)
```powershell
Invoke-WebRequest https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/dev/gui_setup.bat -OutFile gui_setup.bat
Invoke-WebRequest https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/dev/gui/qt_window.py -OutFile ( New-Item -Path ".\gui\qt_window.py" -Force )
Invoke-WebRequest https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/main/gui_setup.bat -OutFile gui_setup.bat
Invoke-WebRequest https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/main/gui/qt_window.py -OutFile ( New-Item -Path ".\gui\qt_window.py" -Force )
.\gui_setup.bat
```

(Linux)
```bash
wget https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/dev/gui_setup.sh -O gui_setup.sh
mkdir -p ./gui/ && wget https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/dev/gui/qt_window.py -O ./gui/qt_window.py
wget https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/main/gui_setup.sh -O gui_setup.sh
mkdir -p ./gui/ && wget https://raw.githubusercontent.com/niklases/PyPEF/refs/heads/main/gui/qt_window.py -O ./gui/qt_window.py
chmod a+x ./gui_setup.sh && ./gui_setup.sh
```

Expand Down
25 changes: 17 additions & 8 deletions gui/qt_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def capture(command):
QPushButton:pressed {
background-color: rgb(35, 40, 49);
border: 2px solid rgb(43, 50, 61);
}"""
}
QPushButton:disabled {
background-color: grey;
}
"""

text_style = """
QLabel {
Expand Down Expand Up @@ -178,51 +182,56 @@ def __init__(
def on_readyReadStandardOutput(self):
text = self.process.readAllStandardOutput().data().decode()
self.c += 1
print(text)
self.textedit_out.append(text.strip())

@QtCore.Slot()
def pypef_mklsts(self):
self.version_text.setText("Running MKLSTS...")
wt_fasta_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select WT FASTA File")[0]
csv_variant_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select variant CSV File")[0]
self.exec_pypef(f'mklsts --wt {wt_fasta_file} --input {csv_variant_file}')
if wt_fasta_file and csv_variant_file:
self.exec_pypef(f'mklsts --wt {wt_fasta_file} --input {csv_variant_file}')

@QtCore.Slot()
def pypef_gremlin(self):
self.version_text.setText("Running GREMLIN (DCA) optimization on MSA...")
wt_fasta_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select WT FASTA File")[0]
msa_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select Multiple Sequence Alignment (MSA) file (in FASTA or A2M format)")[0]
self.exec_pypef(f'param_inference --wt {wt_fasta_file} --msa {msa_file}') # --opt_iter 100
if wt_fasta_file and msa_file:
self.exec_pypef(f'param_inference --wt {wt_fasta_file} --msa {msa_file}') # --opt_iter 100

@QtCore.Slot()
def pypef_gremlin_dca_test(self):
self.version_text.setText("Testing GREMLIN (DCA) performance on provided test set...")
test_set_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select Test Set File in \"FASL\" format")[0]
params_pkl_file = QtWidgets.QFileDialog.getOpenFileName(self, "GREMLIN parameter Pickle file")[0]
self.exec_pypef(f'hybrid --ts {test_set_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100
if test_set_file and params_pkl_file:
self.exec_pypef(f'hybrid --ts {test_set_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100

@QtCore.Slot()
def pypef_gremlin_dca_predict(self):
self.version_text.setText("Predicting using the GREMLIN (DCA) model on provided prediction set...")
prediction_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select Prediction Set File in FASTA format")[0]
params_pkl_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select GREMLIN parameter Pickle file")[0]
self.exec_pypef(f'hybrid --ps {prediction_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100
if prediction_file and params_pkl_file:
self.exec_pypef(f'hybrid --ps {prediction_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100

@QtCore.Slot()
def pypef_gremlin_hybrid_train(self):
self.version_text.setText("Hybrid (DCA-supervised) model training...")
training_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select Training Set File in \"FASL\" format")[0]
params_pkl_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select GREMLIN parameter Pickle file")[0]
self.exec_pypef(f'hybrid --ls {training_file} --ts {training_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100
if training_file and params_pkl_file:
self.exec_pypef(f'hybrid --ls {training_file} --ts {training_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100

@QtCore.Slot()
def pypef_gremlin_hybrid_train_test(self):
self.version_text.setText("...")
training_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select Training Set File in \"FASL\" format")[0]
test_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select Test Set File in \"FASL\" format")[0]
params_pkl_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select GREMLIN parameter Pickle file")[0]
self.exec_pypef(f'hybrid --ls {training_file} --ts {test_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100
if training_file and test_file and params_pkl_file:
self.exec_pypef(f'hybrid --ls {training_file} --ts {test_file} -m {params_pkl_file} --params {params_pkl_file}') # --opt_iter 100

def exec_pypef(self, cmd):
self.process.start(f'python', ['-u', f'{self.pypef_root}/run.py'] + cmd.split(' '))
Expand Down

0 comments on commit ab0389c

Please sign in to comment.