Skip to content

Commit bc23d71

Browse files
committed
add nuitka build (dev)
1 parent e0b9c7e commit bc23d71

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

build_with_nuitka.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
python -m pip install -U nuitka
3+
conda install libpython-static
4+
sudo apt install patchelf
5+
python -m nuitka gui/qt_window.py \
6+
--mode=standalone \
7+
--enable-plugin=pyside6 \
8+
--include-data-dir=pypef/ml/AAindex=pypef/ml/. \
9+
#--include-distribution-metadata \
10+
#--onefile

gui/qt_window.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from PySide6 import QtCore, QtWidgets
77
from PySide6.QtCore import QSize
88
pypef_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
9+
from pypef.main import run_main
10+
11+
12+
EXEC_API_OR_CLI = ['api', 'cli'][0]
913

1014

1115
def capture(command):
@@ -322,6 +326,7 @@ def pypef_mklsts(self):
322326
csv_variant_file = QtWidgets.QFileDialog.getOpenFileName(self, "Select variant CSV File")[0]
323327
if wt_fasta_file and csv_variant_file:
324328
self.version_text.setText("Running MKLSTS...")
329+
#self.exec_pypef_cli(f'mklsts --wt {wt_fasta_file} --input {csv_variant_file}')
325330
self.exec_pypef(f'mklsts --wt {wt_fasta_file} --input {csv_variant_file}')
326331

327332

@@ -441,15 +446,25 @@ def pypef_onehot_supervised_train_test(self):
441446
self.version_text.setText("Hybrid (DCA-supervised) model training and testing...")
442447
self.exec_pypef(f'ml --encoding onehot --ls {training_file} --ts {test_file} '
443448
f'--threads {self.n_cores} --regressor {self.regression_model}')
444-
445449

446450
def exec_pypef(self, cmd):
451+
if EXEC_API_OR_CLI == 'api':
452+
return self.exec_pypef_api(cmd)
453+
elif EXEC_API_OR_CLI == 'cli':
454+
return self.exec_pypef(cmd)
455+
else:
456+
raise SystemError("Choose between 'api' or 'cli'!")
457+
458+
def exec_pypef_cli(self, cmd):
447459
print(cmd) # TODO remove
448460
self.process.start(f'python', ['-u', f'{self.pypef_root}/run.py'] + cmd.split(' '))
449461
self.process.finished.connect(self.process_finished)
450462
if self.c > 0:
451463
self.textedit_out.append("=" * 104 + "\n")
452464

465+
def exec_pypef_api(self, cmd):
466+
run_main(argv=cmd)
467+
pass
453468

454469
def process_finished(self):
455470
self.version_text.setText("Finished...")

pypef/hybrid/hybrid_model.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,13 +1193,14 @@ def performance_ls_ts(
11931193
f"{len(test_variants)} (after removing substitutions "
11941194
f"at gap positions)."
11951195
)
1196-
if llm.lower().startswith('esm'):
1197-
llm_dict = esm_setup(train_sequences)
1198-
x_llm_test = llm_embedder(llm_dict, test_sequences)
1199-
elif llm.lower() == 'prosst':
1200-
llm_dict = prosst_setup(
1201-
wt_seq, pdb_file, sequences=train_sequences)
1202-
x_llm_test = llm_embedder(llm_dict, test_sequences)
1196+
if llm is not None:
1197+
if llm.lower().startswith('esm'):
1198+
llm_dict = esm_setup(train_sequences)
1199+
x_llm_test = llm_embedder(llm_dict, test_sequences)
1200+
elif llm.lower() == 'prosst':
1201+
llm_dict = prosst_setup(
1202+
wt_seq, pdb_file, sequences=train_sequences)
1203+
x_llm_test = llm_embedder(llm_dict, test_sequences)
12031204
else:
12041205
llm_dict = None
12051206
x_llm_test = None

pypef/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ def validate(args):
414414
exit(e)
415415

416416

417-
def run_main():
417+
def run_main(argv=None):
418418
"""
419419
Entry point for pip-installed version.
420420
Arguments are created from Docstring using docopt that
421421
creates an argument dict.
422422
"""
423-
arguments = docopt(__doc__, version=__version__)
423+
arguments = docopt(__doc__, argv=argv, version=__version__)
424424
start_time = time.time()
425425
logger.debug(f'main.py __name__: {__name__}, version: {__version__}')
426426
logger.debug(str(argv)[1:-1].replace("\'", "").replace(",", ""))

0 commit comments

Comments
 (0)