pg-sui 1.0.2.1__py3-none-any.whl → 1.6.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pg-sui might be problematic. Click here for more details.

Files changed (112) hide show
  1. {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/METADATA +51 -70
  2. pg_sui-1.6.8.dist-info/RECORD +78 -0
  3. {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/WHEEL +1 -1
  4. pg_sui-1.6.8.dist-info/entry_points.txt +4 -0
  5. pg_sui-1.6.8.dist-info/top_level.txt +1 -0
  6. pgsui/__init__.py +35 -54
  7. pgsui/_version.py +34 -0
  8. pgsui/cli.py +635 -0
  9. pgsui/data_processing/config.py +576 -0
  10. pgsui/data_processing/containers.py +1782 -0
  11. pgsui/data_processing/transformers.py +121 -1103
  12. pgsui/electron/app/__main__.py +5 -0
  13. pgsui/electron/app/icons/icons/1024x1024.png +0 -0
  14. pgsui/electron/app/icons/icons/128x128.png +0 -0
  15. pgsui/electron/app/icons/icons/16x16.png +0 -0
  16. pgsui/electron/app/icons/icons/24x24.png +0 -0
  17. pgsui/electron/app/icons/icons/256x256.png +0 -0
  18. pgsui/electron/app/icons/icons/32x32.png +0 -0
  19. pgsui/electron/app/icons/icons/48x48.png +0 -0
  20. pgsui/electron/app/icons/icons/512x512.png +0 -0
  21. pgsui/electron/app/icons/icons/64x64.png +0 -0
  22. pgsui/electron/app/icons/icons/icon.icns +0 -0
  23. pgsui/electron/app/icons/icons/icon.ico +0 -0
  24. pgsui/electron/app/main.js +189 -0
  25. pgsui/electron/app/package-lock.json +6893 -0
  26. pgsui/electron/app/package.json +50 -0
  27. pgsui/electron/app/preload.js +15 -0
  28. pgsui/electron/app/server.py +146 -0
  29. pgsui/electron/app/ui/logo.png +0 -0
  30. pgsui/electron/app/ui/renderer.js +130 -0
  31. pgsui/electron/app/ui/styles.css +59 -0
  32. pgsui/electron/app/ui/ui_shim.js +72 -0
  33. pgsui/electron/bootstrap.py +43 -0
  34. pgsui/electron/launch.py +59 -0
  35. pgsui/electron/package.json +14 -0
  36. pgsui/example_data/popmaps/{test.popmap → phylogen_nomx.popmap} +185 -99
  37. pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz +0 -0
  38. pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz.tbi +0 -0
  39. pgsui/impute/deterministic/imputers/allele_freq.py +691 -0
  40. pgsui/impute/deterministic/imputers/mode.py +679 -0
  41. pgsui/impute/deterministic/imputers/nmf.py +221 -0
  42. pgsui/impute/deterministic/imputers/phylo.py +971 -0
  43. pgsui/impute/deterministic/imputers/ref_allele.py +530 -0
  44. pgsui/impute/supervised/base.py +339 -0
  45. pgsui/impute/supervised/imputers/hist_gradient_boosting.py +293 -0
  46. pgsui/impute/supervised/imputers/random_forest.py +287 -0
  47. pgsui/impute/unsupervised/base.py +924 -0
  48. pgsui/impute/unsupervised/callbacks.py +89 -263
  49. pgsui/impute/unsupervised/imputers/autoencoder.py +972 -0
  50. pgsui/impute/unsupervised/imputers/nlpca.py +1264 -0
  51. pgsui/impute/unsupervised/imputers/ubp.py +1288 -0
  52. pgsui/impute/unsupervised/imputers/vae.py +957 -0
  53. pgsui/impute/unsupervised/loss_functions.py +158 -0
  54. pgsui/impute/unsupervised/models/autoencoder_model.py +208 -558
  55. pgsui/impute/unsupervised/models/nlpca_model.py +149 -468
  56. pgsui/impute/unsupervised/models/ubp_model.py +198 -1317
  57. pgsui/impute/unsupervised/models/vae_model.py +259 -618
  58. pgsui/impute/unsupervised/nn_scorers.py +215 -0
  59. pgsui/utils/classification_viz.py +591 -0
  60. pgsui/utils/misc.py +35 -480
  61. pgsui/utils/plotting.py +514 -824
  62. pgsui/utils/scorers.py +212 -438
  63. pg_sui-1.0.2.1.dist-info/RECORD +0 -75
  64. pg_sui-1.0.2.1.dist-info/top_level.txt +0 -3
  65. pgsui/example_data/phylip_files/test_n10.phy +0 -118
  66. pgsui/example_data/phylip_files/test_n100.phy +0 -118
  67. pgsui/example_data/phylip_files/test_n2.phy +0 -118
  68. pgsui/example_data/phylip_files/test_n500.phy +0 -118
  69. pgsui/example_data/structure_files/test.nopops.1row.10sites.str +0 -117
  70. pgsui/example_data/structure_files/test.nopops.2row.100sites.str +0 -234
  71. pgsui/example_data/structure_files/test.nopops.2row.10sites.str +0 -234
  72. pgsui/example_data/structure_files/test.nopops.2row.30sites.str +0 -234
  73. pgsui/example_data/structure_files/test.nopops.2row.allsites.str +0 -234
  74. pgsui/example_data/structure_files/test.pops.1row.10sites.str +0 -117
  75. pgsui/example_data/structure_files/test.pops.2row.10sites.str +0 -234
  76. pgsui/example_data/trees/test.iqtree +0 -376
  77. pgsui/example_data/trees/test.qmat +0 -5
  78. pgsui/example_data/trees/test.rate +0 -2033
  79. pgsui/example_data/trees/test.tre +0 -1
  80. pgsui/example_data/trees/test_n10.rate +0 -19
  81. pgsui/example_data/trees/test_n100.rate +0 -109
  82. pgsui/example_data/trees/test_n500.rate +0 -509
  83. pgsui/example_data/trees/test_siterates.txt +0 -2024
  84. pgsui/example_data/trees/test_siterates_n10.txt +0 -10
  85. pgsui/example_data/trees/test_siterates_n100.txt +0 -100
  86. pgsui/example_data/trees/test_siterates_n500.txt +0 -500
  87. pgsui/example_data/vcf_files/test.vcf +0 -244
  88. pgsui/example_data/vcf_files/test.vcf.gz +0 -0
  89. pgsui/example_data/vcf_files/test.vcf.gz.tbi +0 -0
  90. pgsui/impute/estimators.py +0 -735
  91. pgsui/impute/impute.py +0 -1486
  92. pgsui/impute/simple_imputers.py +0 -1439
  93. pgsui/impute/supervised/iterative_imputer_fixedparams.py +0 -785
  94. pgsui/impute/supervised/iterative_imputer_gridsearch.py +0 -1027
  95. pgsui/impute/unsupervised/keras_classifiers.py +0 -702
  96. pgsui/impute/unsupervised/models/in_development/cnn_model.py +0 -486
  97. pgsui/impute/unsupervised/neural_network_imputers.py +0 -1424
  98. pgsui/impute/unsupervised/neural_network_methods.py +0 -1549
  99. pgsui/pg_sui.py +0 -261
  100. pgsui/utils/sequence_tools.py +0 -407
  101. simulation/sim_benchmarks.py +0 -333
  102. simulation/sim_treeparams.py +0 -475
  103. test/__init__.py +0 -0
  104. test/pg_sui_simtest.py +0 -215
  105. test/pg_sui_testing.py +0 -523
  106. test/test.py +0 -297
  107. test/test_pgsui.py +0 -374
  108. test/test_tkc.py +0 -214
  109. {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info/licenses}/LICENSE +0 -0
  110. /pgsui/{example_data/trees → electron/app}/__init__.py +0 -0
  111. /pgsui/impute/{unsupervised/models/in_development → supervised/imputers}/__init__.py +0 -0
  112. {simulation → pgsui/impute/unsupervised/imputers}/__init__.py +0 -0
@@ -0,0 +1,5 @@
1
+ import uvicorn
2
+
3
+ from .server import app
4
+
5
+ uvicorn.run(app, host="0.0.0.0", port=8765, log_level="info")
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,189 @@
1
+ const { app, BrowserWindow, ipcMain, dialog } = require('electron');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const { spawn } = require('child_process');
5
+ const readline = require('readline');
6
+
7
+ app.disableHardwareAcceleration();
8
+ app.commandLine.appendSwitch('disable-gpu');
9
+
10
+ let win = null;
11
+ let currentChild = null;
12
+
13
+ function createWindow() {
14
+ win = new BrowserWindow({
15
+ width: 1200,
16
+ height: 880,
17
+ backgroundColor: '#0b0f14',
18
+ titleBarStyle: process.platform === 'darwin' ? 'hiddenInset' : 'default',
19
+ webPreferences: {
20
+ preload: path.join(__dirname, 'preload.js'),
21
+ contextIsolation: true,
22
+ sandbox: true,
23
+ nodeIntegration: false,
24
+ webSecurity: true,
25
+ backgroundThrottling: false
26
+ }
27
+ });
28
+ win.loadFile(path.join(__dirname, 'ui', 'index.html'));
29
+ }
30
+
31
+ const gotLock = app.requestSingleInstanceLock();
32
+ if (!gotLock) app.quit();
33
+ else {
34
+ app.whenReady().then(() => {
35
+ createWindow();
36
+ app.on('activate', () => {
37
+ if (BrowserWindow.getAllWindows().length === 0) createWindow();
38
+ });
39
+ });
40
+ }
41
+ app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
42
+
43
+ function buildArgs(p) {
44
+ const a = [];
45
+ const kv = (f, v) => { if (v !== undefined && v !== null && String(v).trim() !== '') a.push(f, String(v)); };
46
+ const fl = (f, c) => { if (c) a.push(f); };
47
+ kv('--input', p.inputPath);
48
+ kv('--format', p.format);
49
+ kv('--popmap', p.popmapPath);
50
+ kv('--prefix', p.prefix);
51
+ kv('--config', p.yamlPath);
52
+ kv('--dump-config', p.dumpConfigPath);
53
+ kv('--preset', p.preset || 'fast');
54
+ if (Array.isArray(p.models) && p.models.length) a.push('--models', ...p.models);
55
+ if (Array.isArray(p.includePops) && p.includePops.length) a.push('--include-pops', ...p.includePops);
56
+ fl('--tune', !!p.tune);
57
+ if (p.tuneNTrials) kv('--tune-n-trials', p.tuneNTrials);
58
+ kv('--batch-size', p.batchSize ?? 64);
59
+ if (['cpu','cuda','mps'].includes(p.device || '')) kv('--device', p.device);
60
+ if (p.nJobs) kv('--n-jobs', p.nJobs);
61
+ if (['png','pdf','svg'].includes(p.plotFormat || '')) kv('--plot-format', p.plotFormat);
62
+ if (p.seed) kv('--seed', p.seed);
63
+ fl('--verbose', !!p.verbose);
64
+ if (p.logFile) kv('--log-file', p.logFile);
65
+ fl('--force-popmap', !!p.forcePopmap);
66
+ fl('--dry-run', !!p.dryRun);
67
+ (p.setPairs || []).forEach(s => { if (s && s.includes('=')) a.push('--set', s); });
68
+ return a;
69
+ }
70
+
71
+ function checkCmd(cmd, args = ['--version']) {
72
+ return new Promise((resolve) => {
73
+ try {
74
+ const p = spawn(cmd, args, { env: process.env });
75
+ let seen = false;
76
+ p.stdout.on('data', () => { seen = true; });
77
+ p.stderr.on('data', () => { seen = true; });
78
+ p.on('error', () => resolve(false));
79
+ p.on('close', () => resolve(seen));
80
+ } catch { resolve(false); }
81
+ });
82
+ }
83
+
84
+ // ---- IPC: always reply using event.sender; never use win.webContents ----
85
+ ipcMain.handle('detect:pgsui', async () => ({ ok: await checkCmd('pg-sui') }));
86
+
87
+ ipcMain.handle('pgsui:start', async (evt, payload) => {
88
+ const send = (ch, m) => { try { evt?.sender?.send(ch, m); } catch {} };
89
+
90
+ if (currentChild) return { ok: false, error: 'Process already running.' };
91
+ if (!payload?.cwd || !String(payload.cwd).trim()) return { ok: false, error: 'Working directory is required.' };
92
+
93
+ const args = buildArgs(payload);
94
+ const cwd = payload.cwd;
95
+
96
+ let fullArgv;
97
+ if (payload.usePgSui === true) { // you likely removed this path; keeping for safety
98
+ const cmd = 'pg-sui';
99
+ fullArgv = [cmd, ...args];
100
+ currentChild = spawn(cmd, args, { cwd, env: process.env });
101
+ } else {
102
+ const pythonExe = payload.pythonPath || 'python3';
103
+ let cliPath = payload.cliPath;
104
+ if (!cliPath) {
105
+ const r = await resolveDefaultCli();
106
+ if (r.ok) cliPath = r.path;
107
+ }
108
+ if (!cliPath || !fs.existsSync(cliPath)) return { ok: false, error: `cli.py not found at ${cliPath || '<auto>'}` };
109
+ fullArgv = [pythonExe, cliPath, ...args];
110
+ currentChild = spawn(pythonExe, [cliPath, ...args], { cwd, env: process.env });
111
+ }
112
+
113
+ // wire streams BEFORE returning
114
+ const rlOut = readline.createInterface({ input: currentChild.stdout });
115
+ rlOut.on('line', line => send('pgsui:log', { stream: 'stdout', line }));
116
+ const rlErr = readline.createInterface({ input: currentChild.stderr });
117
+ rlErr.on('line', line => send('pgsui:log', { stream: 'stderr', line }));
118
+
119
+ currentChild.on('close', code => { send('pgsui:exit', { code }); currentChild = null; });
120
+ currentChild.on('error', err => { send('pgsui:error', { message: String(err) }); currentChild = null; });
121
+
122
+ send('pgsui:started', { argv: fullArgv, cwd });
123
+ return { ok: true };
124
+ });
125
+
126
+ ipcMain.handle('pgsui:stop', async () => {
127
+ if (!currentChild) return { ok: false, error: 'No process running.' };
128
+ return new Promise((resolve) => {
129
+ const child = currentChild; currentChild = null;
130
+ const done = (ok, error) => resolve(ok ? { ok: true } : { ok: false, error });
131
+ try {
132
+ if (process.platform === 'win32') {
133
+ const killer = spawn('taskkill', ['/PID', String(child.pid), '/T', '/F']);
134
+ killer.on('close', (code) => done(code === 0));
135
+ } else {
136
+ child.once('close', () => done(true));
137
+ child.kill('SIGTERM');
138
+ setTimeout(() => { try { child.kill('SIGKILL'); } catch {} }, 5000);
139
+ }
140
+ } catch (e) { done(false, String(e)); }
141
+ });
142
+ });
143
+
144
+ function resolveDefaultCliPathCandidates() {
145
+ return [
146
+ path.resolve(process.cwd(), '..', 'pgsui', 'cli.py'),
147
+ path.resolve(__dirname, '..', '..', '..', 'pgsui', 'cli.py'),
148
+ path.join(process.resourcesPath, 'pgsui', 'cli.py'),
149
+ ];
150
+ }
151
+
152
+ async function resolveDefaultCli() {
153
+ const envp = process.env.PGSUI_CLI_DEFAULT;
154
+ if (envp && fs.existsSync(envp)) return { ok: true, path: envp };
155
+ for (const pth of resolveDefaultCliPathCandidates()) {
156
+ if (fs.existsSync(pth)) return { ok: true, path: pth };
157
+ }
158
+ return { ok: false };
159
+ }
160
+
161
+
162
+ // simple single-flight guard
163
+ let dialogBusy = false;
164
+ async function withDialogMutex(fn) {
165
+ if (dialogBusy) return null;
166
+ dialogBusy = true;
167
+ try { return await fn(); }
168
+ finally { dialogBusy = false; }
169
+ }
170
+
171
+ ipcMain.handle('pick:dir', async () => withDialogMutex(async () => {
172
+ const res = await dialog.showOpenDialog({ properties: ['openDirectory'] });
173
+ return (!res.canceled && res.filePaths[0]) ? res.filePaths[0] : null;
174
+ }));
175
+
176
+ ipcMain.handle('pick:file', async (_evt, { filters }) => withDialogMutex(async () => {
177
+ const res = await dialog.showOpenDialog({
178
+ properties: ['openFile'],
179
+ filters: Array.isArray(filters) && filters.length ? filters : [{ name: 'All Files', extensions: ['*'] }],
180
+ });
181
+ return (!res.canceled && res.filePaths[0]) ? res.filePaths[0] : null;
182
+ }));
183
+
184
+ ipcMain.handle('pick:save', async (_evt, { defaultPath }) => withDialogMutex(async () => {
185
+ const res = await dialog.showSaveDialog({ defaultPath });
186
+ return (!res.canceled && res.filePath) ? res.filePath : null;
187
+ }));
188
+
189
+ ipcMain.handle('default:cli', async () => resolveDefaultCli());