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.
- {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/METADATA +51 -70
- pg_sui-1.6.8.dist-info/RECORD +78 -0
- {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/WHEEL +1 -1
- pg_sui-1.6.8.dist-info/entry_points.txt +4 -0
- pg_sui-1.6.8.dist-info/top_level.txt +1 -0
- pgsui/__init__.py +35 -54
- pgsui/_version.py +34 -0
- pgsui/cli.py +635 -0
- pgsui/data_processing/config.py +576 -0
- pgsui/data_processing/containers.py +1782 -0
- pgsui/data_processing/transformers.py +121 -1103
- pgsui/electron/app/__main__.py +5 -0
- pgsui/electron/app/icons/icons/1024x1024.png +0 -0
- pgsui/electron/app/icons/icons/128x128.png +0 -0
- pgsui/electron/app/icons/icons/16x16.png +0 -0
- pgsui/electron/app/icons/icons/24x24.png +0 -0
- pgsui/electron/app/icons/icons/256x256.png +0 -0
- pgsui/electron/app/icons/icons/32x32.png +0 -0
- pgsui/electron/app/icons/icons/48x48.png +0 -0
- pgsui/electron/app/icons/icons/512x512.png +0 -0
- pgsui/electron/app/icons/icons/64x64.png +0 -0
- pgsui/electron/app/icons/icons/icon.icns +0 -0
- pgsui/electron/app/icons/icons/icon.ico +0 -0
- pgsui/electron/app/main.js +189 -0
- pgsui/electron/app/package-lock.json +6893 -0
- pgsui/electron/app/package.json +50 -0
- pgsui/electron/app/preload.js +15 -0
- pgsui/electron/app/server.py +146 -0
- pgsui/electron/app/ui/logo.png +0 -0
- pgsui/electron/app/ui/renderer.js +130 -0
- pgsui/electron/app/ui/styles.css +59 -0
- pgsui/electron/app/ui/ui_shim.js +72 -0
- pgsui/electron/bootstrap.py +43 -0
- pgsui/electron/launch.py +59 -0
- pgsui/electron/package.json +14 -0
- pgsui/example_data/popmaps/{test.popmap → phylogen_nomx.popmap} +185 -99
- pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz +0 -0
- pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz.tbi +0 -0
- pgsui/impute/deterministic/imputers/allele_freq.py +691 -0
- pgsui/impute/deterministic/imputers/mode.py +679 -0
- pgsui/impute/deterministic/imputers/nmf.py +221 -0
- pgsui/impute/deterministic/imputers/phylo.py +971 -0
- pgsui/impute/deterministic/imputers/ref_allele.py +530 -0
- pgsui/impute/supervised/base.py +339 -0
- pgsui/impute/supervised/imputers/hist_gradient_boosting.py +293 -0
- pgsui/impute/supervised/imputers/random_forest.py +287 -0
- pgsui/impute/unsupervised/base.py +924 -0
- pgsui/impute/unsupervised/callbacks.py +89 -263
- pgsui/impute/unsupervised/imputers/autoencoder.py +972 -0
- pgsui/impute/unsupervised/imputers/nlpca.py +1264 -0
- pgsui/impute/unsupervised/imputers/ubp.py +1288 -0
- pgsui/impute/unsupervised/imputers/vae.py +957 -0
- pgsui/impute/unsupervised/loss_functions.py +158 -0
- pgsui/impute/unsupervised/models/autoencoder_model.py +208 -558
- pgsui/impute/unsupervised/models/nlpca_model.py +149 -468
- pgsui/impute/unsupervised/models/ubp_model.py +198 -1317
- pgsui/impute/unsupervised/models/vae_model.py +259 -618
- pgsui/impute/unsupervised/nn_scorers.py +215 -0
- pgsui/utils/classification_viz.py +591 -0
- pgsui/utils/misc.py +35 -480
- pgsui/utils/plotting.py +514 -824
- pgsui/utils/scorers.py +212 -438
- pg_sui-1.0.2.1.dist-info/RECORD +0 -75
- pg_sui-1.0.2.1.dist-info/top_level.txt +0 -3
- pgsui/example_data/phylip_files/test_n10.phy +0 -118
- pgsui/example_data/phylip_files/test_n100.phy +0 -118
- pgsui/example_data/phylip_files/test_n2.phy +0 -118
- pgsui/example_data/phylip_files/test_n500.phy +0 -118
- pgsui/example_data/structure_files/test.nopops.1row.10sites.str +0 -117
- pgsui/example_data/structure_files/test.nopops.2row.100sites.str +0 -234
- pgsui/example_data/structure_files/test.nopops.2row.10sites.str +0 -234
- pgsui/example_data/structure_files/test.nopops.2row.30sites.str +0 -234
- pgsui/example_data/structure_files/test.nopops.2row.allsites.str +0 -234
- pgsui/example_data/structure_files/test.pops.1row.10sites.str +0 -117
- pgsui/example_data/structure_files/test.pops.2row.10sites.str +0 -234
- pgsui/example_data/trees/test.iqtree +0 -376
- pgsui/example_data/trees/test.qmat +0 -5
- pgsui/example_data/trees/test.rate +0 -2033
- pgsui/example_data/trees/test.tre +0 -1
- pgsui/example_data/trees/test_n10.rate +0 -19
- pgsui/example_data/trees/test_n100.rate +0 -109
- pgsui/example_data/trees/test_n500.rate +0 -509
- pgsui/example_data/trees/test_siterates.txt +0 -2024
- pgsui/example_data/trees/test_siterates_n10.txt +0 -10
- pgsui/example_data/trees/test_siterates_n100.txt +0 -100
- pgsui/example_data/trees/test_siterates_n500.txt +0 -500
- pgsui/example_data/vcf_files/test.vcf +0 -244
- pgsui/example_data/vcf_files/test.vcf.gz +0 -0
- pgsui/example_data/vcf_files/test.vcf.gz.tbi +0 -0
- pgsui/impute/estimators.py +0 -735
- pgsui/impute/impute.py +0 -1486
- pgsui/impute/simple_imputers.py +0 -1439
- pgsui/impute/supervised/iterative_imputer_fixedparams.py +0 -785
- pgsui/impute/supervised/iterative_imputer_gridsearch.py +0 -1027
- pgsui/impute/unsupervised/keras_classifiers.py +0 -702
- pgsui/impute/unsupervised/models/in_development/cnn_model.py +0 -486
- pgsui/impute/unsupervised/neural_network_imputers.py +0 -1424
- pgsui/impute/unsupervised/neural_network_methods.py +0 -1549
- pgsui/pg_sui.py +0 -261
- pgsui/utils/sequence_tools.py +0 -407
- simulation/sim_benchmarks.py +0 -333
- simulation/sim_treeparams.py +0 -475
- test/__init__.py +0 -0
- test/pg_sui_simtest.py +0 -215
- test/pg_sui_testing.py +0 -523
- test/test.py +0 -297
- test/test_pgsui.py +0 -374
- test/test_tkc.py +0 -214
- {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info/licenses}/LICENSE +0 -0
- /pgsui/{example_data/trees → electron/app}/__init__.py +0 -0
- /pgsui/impute/{unsupervised/models/in_development → supervised/imputers}/__init__.py +0 -0
- {simulation → pgsui/impute/unsupervised/imputers}/__init__.py +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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());
|