eGPS4Py is a standalone Python wrapper for the eGPS desktop software. It bridges Python to the eGPS Java runtime via JPype, allowing users to launch the eGPS desktop, open visualisation views, and call tree utility functions directly from Python scripts or notebooks.
Its primary runtime model is the installed Windows eGPS package, including the bundled dependency-egps jars and bundled jre. It can still resolve the source-tree layout for development, but normal users should point it at the installed eGPS folder.
The current wrapper exposes three main capabilities:
- launch the eGPS desktop
- open
Modern Tree View - open
Pathway Family Browser
It also provides a tree utility bridge for extracting node names through the Java API.
- Python
>= 3.10 - A working eGPS installation, for example
C:/path/to/eGPS_v2.1_windows_x64_selfTest - The eGPS installation must contain:
dependency-egps/eGPS2.argsjre/bin/server/jvm.dll
- Python packages:
jpype1pandasopenpyxl
From this repository:
cd Py4eGPS
python -m pip install -e .That editable install path was verified in the current workspace.
eGPS4Py accepts any of these as repo_root:
- the installed eGPS root, such as
C:/path/to/eGPS_v2.1_windows_x64_selfTest - the installed
dependency-egpsdirectory inside that root - the source-tree root, for development only
When the runtime points to an installed eGPS package:
- the wrapper reads JVM options from
eGPS2.args - the wrapper builds the classpath from
dependency-egps/*.jar - the wrapper uses the bundled
jre/bin/server/jvm.dllby default
When the runtime points to the source tree:
- the wrapper reads JVM options from
egps-shell/eGPS.args - the wrapper uses the two compiled
out/production/...directories plus bothdependency-egpsdirectories
The recommended explicit setup is:
from eGPS4Py import configure_runtime
configure_runtime(
repo_root="C:/path/to/eGPS_v2.1_windows_x64_selfTest",
)You can also pass the installed dependency directory directly:
configure_runtime(
repo_root="C:/path/to/eGPS_v2.1_windows_x64_selfTest/dependency-egps",
)If jvm_path is omitted for an installed package, eGPS4Py uses:
<install-root>/jre/bin/server/jvm.dll
If nothing has been configured yet and a JVM-backed call is made in an interactive session, eGPS4Py will ask the user to choose the eGPS installation folder and persist the result in:
~/.eGPS4Py/runtime_config.json
If you want to force the package to prompt again, delete that file.
For non-interactive scripts, do not rely on the prompt. Call configure_runtime(...) explicitly before the first GUI or bridge call.
The main public entry points are:
from eGPS4Py import (
configure_runtime,
launch_desktop,
open_modern_tree_view,
open_modern_tree_view_from_config,
open_pathway_family_browser,
open_pathway_family_browser_from_config,
)The tree bridge stays available at:
from eGPS4Py.phylo import evoltreefrom eGPS4Py import configure_runtime, launch_desktop
configure_runtime(
repo_root="C:/path/to/eGPS_v2.1_windows_x64_selfTest",
)
hello = launch_desktop()
print(str(hello))On a healthy runtime this returns a welcome string similar to:
Hello this is eGPS desktop, version: Version: 2.1.97
open_modern_tree_view(...) supports two tree inputs:
tree_path: path to an existing Newick filenewick_text: raw Newick text
Exactly one of them must be provided.
Other supported parameters:
layoutleaf_labeltitlereverse_axisblank_spacenode_visual_config_path
Example with in-memory Newick text:
from eGPS4Py import configure_runtime, open_modern_tree_view
configure_runtime(
repo_root="C:/path/to/eGPS_v2.1_windows_x64_selfTest",
)
open_modern_tree_view(
newick_text="(Human:6.5,Chimp:6.5,Gorilla:8.9);",
layout="CIRCULAR",
leaf_label=True,
title="Great apes",
reverse_axis=False,
blank_space=(20, 40, 80, 40),
)The wrapper will materialize a temporary .nwk file automatically when newick_text is used.
If you already have a prepared VOICE config file, use:
open_modern_tree_view_from_config("C:/path/to/modern_tree.voice")open_pathway_family_browser(...) supports:
tree_pathornewick_textcomponent_countsspecies_infospecies_traitsgallery_pathslayoutleaf_labeltitlereverse_axisblank_spacenode_visual_config_path
Input rules:
component_counts,species_info, andspecies_traitscan be either file paths orpandas.DataFrame- DataFrame inputs must contain a
Namecolumn gallery_pathsmust be real file paths- if a table argument is
None, the generated VOICE config writesFalsefor that field
Example:
import pandas as pd
from eGPS4Py import configure_runtime, open_pathway_family_browser
configure_runtime(
repo_root="C:/path/to/eGPS_v2.1_windows_x64_selfTest",
)
component_counts = pd.DataFrame({
"Name": ["Human", "Chimp"],
"WNT3A": [2, 1],
})
species_info = pd.DataFrame({
"Name": ["Human", "Chimp"],
"Clade": ["Hominini", "Hominini"],
})
species_traits = pd.DataFrame({
"Name": ["Human", "Chimp"],
"Habitat": ["Mixed", "Forest"],
})
open_pathway_family_browser(
tree_path="C:/path/to/species_tree.nwk",
component_counts=component_counts,
species_info=species_info,
species_traits=species_traits,
gallery_paths=[
"C:/path/to/wnt_pathway.pptx",
],
layout="RECTANGULAR",
leaf_label=True,
title="WNT pathway family",
)If you already have a prepared VOICE config file, use:
open_pathway_family_browser_from_config("C:/path/to/pathway_browser.voice")The current tree utility call is:
from eGPS4Py.phylo import evoltree
names = evoltree.get_node_names(
"C:/path/to/species_tree.nwk",
target_htu=None,
get_otu=True,
get_htu=False,
)This now calls the current Java bridge method:
api.rpython.API4R.extractNodeNames(...)
- The GUI runs inside the current Python process. If the script exits immediately, the GUI may disappear immediately as well.
- For quick smoke tests, keep the process alive for a few seconds after opening a window.
open_modern_tree_view(...)andopen_pathway_family_browser(...)do not return rich Python objects. Their purpose is to trigger the Java GUI.launch_desktop()returns the Java welcome string, which can be wrapped withstr(...)before printing.
Example smoke pattern:
import time
from eGPS4Py import configure_runtime, launch_desktop
configure_runtime(
repo_root="C:/path/to/eGPS_v2.1_windows_x64_selfTest",
)
print(str(launch_desktop()))
time.sleep(8)- Make sure
repo_rootpoints to the installed eGPS root or itsdependency-egpsdirectory - Make sure the installed package contains
eGPS2.args,dependency-egps, andjre/bin/server/jvm.dll - Keep the Python process alive for a few seconds after opening the GUI
- That means no persisted runtime is available and no explicit
repo_rootwas provided - In automated scripts, always call
configure_runtime(...)first
- Check that every DataFrame contains a
Namecolumn - Check that
gallery_pathspoints to real files rather than in-memory objects
- Delete
~/.eGPS4Py/runtime_config.json - Or call
configure_runtime(...)again with a differentrepo_root
Unit tests:
cd Py4eGPS
python -m unittest tests.test_runtime_and_guiThe local editable install was also verified with:
python -m pip install -e .