Skip to content

Commit ac74bbc

Browse files
committed
make port settable from CLI
1 parent c2d744f commit ac74bbc

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

directlfq/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ def run(ctx, **kwargs):
177177
click.echo(run.get_help(ctx))
178178

179179
@run.command("gui", help="Start graphical user interface.")
180-
def gui():
180+
@click.option("--port", "-p", type=int, default=None, help="Port to run the GUI server on (default: 41215 or PORT environment variable)")
181+
def gui(port):
181182
import directlfq.gui
182-
directlfq.gui.run()
183+
directlfq.gui.run(port=port)
183184

184185
list_of_format_names = ["alphapept_peptides","fragpipe_precursors","maxquant_evidence","maxquant_peptides","diann_fragion_isotopes","diann_precursors","spectronaut_fragion_isotopes","spectronaut_precursor"]
185186

directlfq/gui.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
github_url,
4444
run_in_background=False,
4545
automatic_close=True,
46+
port=None,
4647
):
4748
self.name = name
4849
self.tab_counter = 0
@@ -61,6 +62,7 @@ def __init__(
6162
)
6263
self.run_in_background = run_in_background
6364
self.automatic_close = automatic_close
65+
self.port = int(port) if port else port
6466

6567
def start_server(self, run_in_background=False):
6668
if self.automatic_close:
@@ -73,7 +75,9 @@ def start_server(self, run_in_background=False):
7375
bokeh_ws_handler.on_close = self.__close_browser_tab(
7476
self.bokeh_server_on_close
7577
)
76-
self.server = self.layout.show(threaded=True, title=self.name)
78+
79+
port_param = {} if self.port is None else {"port": self.port}
80+
self.server = self.layout.show(threaded=True, title=self.name, **port_param)
7781
if not run_in_background:
7882
self.server.join()
7983
elif not self.run_in_background:
@@ -105,10 +109,11 @@ def stop_server(self):
105109

106110
class AlphaQuantGUI(GUI):
107111
# TODO: docstring
108-
def __init__(self, start_server=False):
112+
def __init__(self, start_server=False, port=None):
109113
super().__init__(
110114
name="directLFQ",
111115
github_url='https://github.com/MannLabs/directLFQ',
116+
port=port,
112117
)
113118
self.project_description = """### directLFQ provides ratio-based normalization and protein intensity estimation for small and very large numbers of proteomes."""
114119
self.manual_path = os.path.join(
@@ -136,8 +141,8 @@ def __init__(self, start_server=False):
136141
self.start_server()
137142

138143

139-
def run():
140-
AlphaQuantGUI(start_server=True)
144+
def run(port=None):
145+
AlphaQuantGUI(start_server=True, port=port)
141146

142147

143148
if __name__ == '__main__':

0 commit comments

Comments
 (0)