about summary refs log tree commit diff
path: root/sourcecodes
AgeCommit message (Collapse)Author
2026-10-03validate the GN2 payload before prep; informative failures throughoutPjotr
Found by an exhaustive small-payload fuzz (test/fuzz_bnw.py): - bn_genenet.php: fail fast with a plain-English problem list for header-only payloads, ragged rows, single variable/sample, all-NA columns and all-NA rows, non-numeric cells and empty payloads; normalize CRLF and squeeze redundant row separators; rename duplicate variable names with a note (prep used to crash on each of these deep inside octave) - runtime_check.php: exe_time no longer fatals ("int + string") when prep did not produce its tables; falls back to a default estimate - execute_bn_gom.php: the FAILED page gains plain-English hints for the recurring octave failure modes - test/bnw_http_tests.py: tests t22-t33 lock the behaviour in - test/fuzz_bnw.py: the parameter-space fuzzer (75 cases)
2026-10-03run.sh: self-locate the C binaries; fix the production run failurePjotr
run.sh cd'ed to /var/lib/genenet/bnw and ran ./network_score etc RELATIVE to that directory -- depending on the activation having copied the binaries there. On production that copy was incomplete (the binaries live in the bnw PACKAGE store item since 00e5b05f removed the vendored ones and build.sh recompiles them), so every structure-learning run died with "./network_score: No such file or directory". run.sh now locates the binaries next to itself: BNW_BIN_DIR=$(dirname $0)/../var_lib_genenet_bnw which in the package is <out>/sourcecodes/../var_lib_genenet_bnw -- provably present in the store item. The per-run working directory stays /var/lib/genenet/bnw.
2026-10-03bn_genenet: sanitize GN2 trait names containing spacesPjotr
GN2 trait display names often contain spaces ("Age at death"), but BNW's file format does not allow them: the octave parsers split on WHITESPACE (strtok), so a spaced name corrupts the header -- the variable count no longer matches the labels and structure learning dies with "A(0,_): subscripts must be either integers 1 to (2^63)-1 or logicals" in mk_adj_mat (observed on production with a real GN2 dataset). bn_genenet.php now sanitizes the NAME ROW of the GN2 payload (content before the first semicolon, i.e. before the comma->tab conversion): whitespace inside a name becomes an underscore. A wrong first attempt applied the sanitization after the conversion and collapsed the tabs as well, merging all names into one variable. New test t21 posts spaced trait names and runs structure learning through to the rendered SVG. Suite: 27/27 (BNW_LOCAL_SOURCE build).
2026-10-03execute_bn_gom: show pipeline failures on the status pagePjotr
runTerminalCommand throws a RuntimeException when run.sh or run_octave fails, and execute_bn_gom.php had no try/catch -- the uncaught exception produced a blank page with no forward and no diagnosis (observed on production with real GeneNetwork datasets). Wrap the structure-learning pipeline in try/catch and render the error on the status page ("Structure learning FAILED: ..." plus a link back to the upload page) instead.
2026-10-03execute_bn_gom: show a status page while structure learning runsPjotr
The runner page used to output NOTHING until the C structure learning and octave runs finished (~12s+); the browser sat on a blank page and only then got the window.open forward to the network diagram. Emit a status page first (flushed before the work starts): Structure learning is running. Forwarding to the network diagram when done... If the diagram does not open, click here. (link to layout_svg_no.php?My_key=...) so users get feedback during the run and a manual fallback if the automatic forward is blocked or fails.
2026-10-03bn_genenet: accept the GN2 template spelling My_GenenetPjotr
GN2's bnw_page.html posts the payload field as "My_Genenet" (one 'n' in Genenet), while BNW historically read "My_Gennenet" -- the two never matched, so GN2's POST arrived empty and BNW showed its default form (the "Loading data from GeneNetwork" hang). Accept both spellings. New test t18b posts My_Genenet through the legacy /sourcecodes/ action path the template uses. Suite with BNW_LOCAL_SOURCE (this checkout): 26/26.
2026-10-01remove vendored javascript and prebuilt binariesPjotr
The guix package replaces all vendored javascript libraries with guix packages (cytoscape, cytoscape-dagre, cytoscape-panzoom, dagre, d3, jquery, font-awesome, lodash, FileSaver, canvas-toBlob) via symlinks at install time; the bundled copies are stale. accordion.js, create_table.js and table.css are BNW's own code and stay. Also drop the prebuilt binaries and Windows-only BNT mex DLLs: build.sh recompiles network_score, structure and the k-best binaries from source and links libRmath from the rmath-standalone package.
2026-09-28container: deployment fixes for the Guix container/VMPjotr
Changes previously carried as bnw-container-paths.patch in guix-bioinformatics, now applied to the source directly: * unify data directories on /var/lib/genenet/bnw (was /tmp/bnw and ./data/ mixed) * make the shell_exec paths __DIR__-relative and the example/octave helper scripts location-independent, so php-fpm can run them from any working directory * use core-octave randn/exp instead of the statistics-package normrnd/normpdf (not available in the container's octave) * nnodes: strtrim before strfind so the node count parses with the container's octave output * python3 instead of a hardcoded /home/jziebart path * add diag.php, a debug page showing the request and data state * bn_genenet.php: serve the GeneNetwork (GN2) handshake server-side; the My_Gennenet POST is converted (commas -> tabs, semicolons -> newlines) in PHP and the prepared-data page is returned in ONE request. This removes the raw-echo of into a JavaScript string (an XSS hole on public deployments) and is backward compatible for GN2 (same POST, better response).
2026-08-24Make all shell scripts executable.Frederick Muriuki Muriithi
The code needs the shell scripts to be executable, otherwise the code will raise an error (Permission Denied).
2026-08-24Use new `runTerminalCommand()` wrapper to run commands.Frederick Muriuki Muriithi
2026-08-24Add a wrapper around `proc_open(...)` to use for terminal commands.Frederick Muriuki Muriithi
2026-08-18Bugfix: Fix path.Frederick Muriuki Muriithi
2026-08-18Bugfix: Check that key exists before use.Frederick Muriuki Muriithi
2026-08-18Bugfix: Move variable closer to usage.Frederick Muriuki Muriithi
Initialise the `$TextFile` variable within the handling of the "POST" request rather than in the global scope.
2026-08-17Fix undefined $TextinFile/$keyval in bn_after_upload_gom.phpClaude Sonnet 5
$TextinFile was passed to move_uploaded_file() as its $to argument, but its assignment (and the $keyval/$sid/$dir it depends on) was commented out, so $TextinFile was always null/undefined here -- an upload through this page could never succeed even on PHP 7.4, and on PHP 8.1+ it also triggers "Passing null to parameter #1 ($to)... is deprecated". $keyval was similarly used (e.g. in the hidden My_key form field) before it was ever assigned, causing an "Undefined variable" warning that could leak into an unquoted HTML attribute if display_errors is on. Unlike bn_file_load_gom.php (a fresh-upload entry point that mints a new random key), this page is only reached via a redirect from modify_structure_learning.php with an existing My_key already in the query string. Restored the commented-out block, adapted to read $keyval from $_GET (matching how the rest of this file already does it further down) instead of generating a new one, so $TextinFile is a real path before the upload block runs. Verified empirically against PHP 8.3.28: simulating an upload request now correctly reaches move_uploaded_file() with a real path and falls into the file's own pre-existing "Sorry, error uploading" handling instead of silently failing on a null argument. Reviewed by: Frederick M Muriithi <fredmanglis@gmail.com>
2026-08-17Guard arithmetic on file/shell-output-derived values against non-numeric stringsClaude Sonnet 5
PHP 8 throws a fatal TypeError for arithmetic (+ - * /) on a non-numeric string ("Unsupported operand types"); PHP 7.4 only warned and treated it as 0. Several files perform arithmetic directly on values parsed from intermediate state files (nnode.txt, nrows.txt, structure_input*.txt) or from `dot -Tplain` output, with no is_numeric() check — safe as long as those files are well-formed, but a crash risk if a file is missing/empty/truncated or a `dot` output line doesn't parse as expected. Affected: runtime_check.php ($node, $nrows), remove_variables.php and create_tiers_gom_part1.php ($maxplist=$node-1), mat_structure.php (matrix cell multiplication), and the four network_layout_{evd,inv}[,_2].php files ($r_index=$node+N and the dot-output-derived $cell arithmetic in the _2 variants). Fix pattern: coalesce to 0 via `is_numeric($x) ? $x : 0` before the arithmetic, matching PHP 7.4's original fallback-to-0 behavior instead of crashing. Verified empirically against PHP 8.3.28 with runtime_check.php and mat_structure.php: previously, a missing/empty source file caused TypeError: Unsupported operand types: string - int (or string * int) after the fix, the same missing-file scenario produces only the pre-existing "undefined array key" warnings (same as PHP 7.4) and the function completes and returns a value instead of crashing. Reviewed by: Frederick M Muriithi <fredmanglis@gmail.com>
2026-08-17Guard fopen() results with a false-check before fwrite/fprintf/fcloseClaude Sonnet 5
On PHP 7.4, calling fwrite()/fprintf()/fclose() with a false handle (a failed fopen(), e.g. from a bad path, missing directory, or permissions issue) just emits a warning and no-ops. On PHP 8.0+, these functions require a resource argument and throw an uncaught TypeError instead, turning what used to be a silent degradation into a fatal crash of the whole request. This patch wraps every fopen()-then-write call site in the codebase (18 files) with an `if ($handle !== false) { ... }` check, matching the existing pattern used elsewhere in the codebase. Where the same $fpvar handle is threaded through shared helper functions (enter_ban_list/banlist/whitelist, duplicated across remove_variables_processing.php, remove_variables_processing_default.php, modify_structure_learning.php and tier_description_processing_gom.php), the guard was added inside those functions too for consistency, even though the call sites are currently dead/commented-out in three of the four files — so the same landmine doesn't reappear if that code is ever re-enabled. Verified empirically against PHP 8.3.28: fopen() on an unwritable path followed by fwrite() on the resulting `false` throws TypeError: fwrite(): Argument #1 ($stream) must be of type resource, false given without the guard; with the guard, the call is skipped instead of crashing. The normal (successful fopen) path was also re-run through mat_structure.php's structure_change() and still produces identical output to before the change. Reviewed by: Frederick M Muriithi <fredmanglis@gmail.com>
2026-08-17Guard valid_keyval()/valid_input() against null input (PHP 8.1 deprecation)Claude Sonnet 5
These two functions are the single most common entry point in the codebase — ~30+ files call them as valid_keyval($_GET["My_key"]) or valid_input($_POST[...]) with no isset() guard at the call site. When the key is absent, PHP passes null straight into trim(), which is a non-nullable string parameter. As of PHP 8.1 this triggers a "Passing null to parameter #1 ($string) ... is deprecated" notice on every one of those call sites, on every request missing the param. Coalescing to '' inside the two functions themselves fixes this once, for every caller, instead of patching every call site individually. Verified empirically against PHP 8.3.28: valid_keyval(null) / valid_input(null) no longer emit the trim() deprecation notice and still return '' as before (same effective behavior as PHP 7.4). Reviewed by: Frederick M Muriithi <fredmanglis@gmail.com>
2026-08-17Remove orphaned fwrite() call in runtime_check.php that crashes on PHP 8Claude Sonnet 5
$fprows and $lc were never defined anywhere in exe_time(). On PHP 7.4 fwrite() with a null resource argument just emitted warnings and returned false. On PHP 8+, fwrite() requires a resource/false is no longer coerced, so this throws an uncaught TypeError on every call, crashing any page that invokes exe_time() (progress-tracking pages). Verified empirically against PHP 8.3.28: before the fix, calling exe_time() throws TypeError: fwrite(): Argument #1 ($stream) must be of type resource, null given after the fix it returns the computed runtime estimate as before. Reviewed by: Frederick M Muriithi <fredmanglis@gmail.com>
2021-10-11Update home.phpziejd2
2021-10-11Update layout_svg_no.phpziejd2
2021-10-11Resolved merge conflictziejd2
2021-10-08Update bn_genenet.phpziejd2
2021-10-08Add files via uploadziejd2
2021-10-08Add files via uploadziejd2
2021-10-08Update network_score.cziejd2
Fixed a potential bug with malloc.
2021-03-16Delete old example filesziejd2
2021-03-16Delete Bqxmap.txtziejd2
2021-03-16Delete Bqxk.txtziejd2
2021-03-16Delete Bqxgraphviz.txtziejd2
2021-03-16Delete standardized_data.txtziejd2
2021-03-16Delete Bqxcontinuous_input.txtziejd2
2021-03-16Delete Bqxban.txtziejd2
2021-03-16Delete sourcecodes/data/example1/old directoryziejd2
2021-03-09Update layout_svg_no.phpziejd2
2021-03-09Update prepareInput.mziejd2
2021-03-09Update upload_structure_file.phpziejd2
2021-03-04Create sample_network.jsonziejd2
2021-03-04Update layout_cyto.phpziejd2
2021-03-02Delete table.css~ziejd2
2021-03-02Delete font-awesome.css~ziejd2
2021-03-02Delete accordion.js~ziejd2
2021-03-02Delete create_table.js~ziejd2
2021-03-02Delete layout_cyto.php~ziejd2
2021-03-02Delete enter_netID.php~ziejd2
2021-03-02Delete .violin_plotly.py.swpziejd2
2021-03-02Delete sourcecodes/data/old directoryziejd2
2021-03-02Delete LRlnetwork.jsonziejd2
2021-03-02Delete net_structure.php.bkziejd2
2021-03-02Delete sourcecodes/localscore directoryziejd2