Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OptiMHC

**An optimum rescoring pipeline for immunopeptidomics data that significantly enhances peptide identification performance.**
**An optimized rescoring pipeline for immunopeptidomics data that significantly enhances peptide identification performance.**

OptiMHC integrates multiple rescoring features with machine learning-based rescoring to maximize the number of confidently identified peptides from mass spectrometry experiments.

Expand Down Expand Up @@ -240,12 +240,6 @@ Here are some examples:

</details>

### GUI (Experimental)

```bash
optimhc gui
```

### Full CLI Help

```bash
Expand Down
6 changes: 0 additions & 6 deletions docs/api/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
options:
members: true

## Logging

::: optimhc.core.logging_helper
options:
members: true

## Utilities

::: optimhc.utils
Expand Down
18 changes: 9 additions & 9 deletions docs/api/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@

## Base Class

::: optimhc.feature_generator.base_feature_generator
::: optimhc.feature.base_feature_generator
options:
members: true

## Basic

::: optimhc.feature_generator.basic
::: optimhc.feature.basic
options:
members: true

## Spectral Similarity

::: optimhc.feature_generator.spectral_similarity
::: optimhc.feature.spectral_similarity
options:
members: true

## DeepLC

::: optimhc.feature_generator.DeepLC
::: optimhc.feature.deeplc
options:
members: true

## Overlapping Peptide

::: optimhc.feature_generator.overlapping_peptide
::: optimhc.feature.overlapping_peptide
options:
members: true

## PWM

::: optimhc.feature_generator.PWM
::: optimhc.feature.pwm
options:
members: true

## MHCflurry

::: optimhc.feature_generator.mhcflurry
::: optimhc.feature.mhcflurry
options:
members: true

## NetMHCpan

::: optimhc.feature_generator.netMHCpan
::: optimhc.feature.netmhcpan
options:
members: true

## NetMHCIIpan

::: optimhc.feature_generator.netMHCIIpan
::: optimhc.feature.netmhciipan
options:
members: true
4 changes: 2 additions & 2 deletions docs/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ uv sync --locked --group dev
Alternatively, using pip:

```bash
pip install -e ".[gui]"
pip install -e .
pip install pytest ruff pre-commit
```

Expand All @@ -42,7 +42,7 @@ uv run ruff format . # Format
uv run ruff format --check . # Check without modifying
```

Configuration: `line-length = 99`, rules `["E", "F", "I"]` (pycodestyle errors, pyflakes, isort). `E501` (line too long) is ignored. Ruff excludes `docs/`, `examples/`, and `optimhc/gui/`.
Configuration: `line-length = 99`, rules `["E", "F", "I"]` (pycodestyle errors, pyflakes, isort). `E501` (line too long) is ignored. Ruff excludes `docs/` and `examples/`.

## Pre-commit Hooks

Expand Down
5 changes: 1 addition & 4 deletions docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,4 @@ netMHCIIpan -v # Should print the version number
optimhc --help
```

You should see the available commands: `pipeline`, `experiment`, and `gui`.

!!! note "GUI"
The Streamlit GUI is currently under development. <!-- todo -->
You should see the available commands: `pipeline` and `experiment`.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OptiMHC

**An optimum rescoring pipeline for immunopeptidomics data that significantly enhances peptide identification performance.**
**An optimized rescoring pipeline for immunopeptidomics data that significantly enhances peptide identification performance.**

OptiMHC integrates multiple rescoring features with machine learning-based rescoring to maximize the number of confidently identified peptides from mass spectrometry experiments.

Expand Down
117 changes: 43 additions & 74 deletions optimhc/cli.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
import importlib.util
import json
import logging
import os
import sys

import click

from optimhc import __version__
from optimhc.core import Pipeline
from optimhc.core.config import Config

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
handlers=[logging.StreamHandler()],
)

logger = logging.getLogger(__name__)

LOG_MAPPING = {
"DEBUG": logging.DEBUG,
"INFO": logging.INFO,
"WARNING": logging.WARNING,
"ERROR": logging.ERROR,
"CRITICAL": logging.CRITICAL,
}


def setup_logging(level: str = "INFO") -> None:
if level not in LOG_MAPPING:
raise ValueError(f"Invalid log level: {level}")
logging.basicConfig(
level=LOG_MAPPING[level],
format="%(asctime)s [%(levelname)s] %(name)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
force=True,
)

# mhctools attaches its own INFO-level handlers to its loggers
# https://github.com/openvax/mhctools/blob/master/mhctools/logging.conf
for name in [
"mhctools",
"mhctools.base_commandline_predictor",
"mhctools.netmhc",
"mhctools.netmhciipan",
"mhctools.process_helpers",
"mhctools.cleanup_context",
]:
lg = logging.getLogger(name)
lg.handlers.clear()
lg.disabled = True
lg.propagate = False
lg.setLevel(logging.CRITICAL)


@click.group()
@click.version_option(version=__version__, prog_name="optimhc")
def cli():
"""
optiMHC - A high-performance rescoring pipeline for immunopeptidomics data.
OptiMHC - A optimized rescoring pipeline for immunopeptidomics data.
"""
pass

Expand Down Expand Up @@ -106,13 +134,8 @@ def pipeline(
model,
):
"""Run the optiMHC pipeline with the specified configuration."""
# Load configuration
if config:
pipeline_config = Config(config)
else:
pipeline_config = Config()
pipeline_config = Config(config) if config else Config()

# Override with command-line parameters
if inputtype:
pipeline_config["inputType"] = inputtype
if inputfile:
Expand Down Expand Up @@ -143,10 +166,9 @@ def pipeline(
if model:
pipeline_config["rescore"]["model"] = model

# Run pipeline
setup_logging(pipeline_config["logLevel"])
pipeline_config.validate()
pipeline = Pipeline(pipeline_config)
pipeline.run()
Pipeline(pipeline_config).run()


@cli.command()
Expand All @@ -158,63 +180,10 @@ def pipeline(
)
def experiment(config):
"""Run multiple experiments with different feature combinations."""
# Load configuration
pipeline_config = Config(config)
setup_logging(pipeline_config["logLevel"])

# Run experiments
pipeline = Pipeline(pipeline_config)
pipeline.run_experiments()


@cli.command()
def gui():
"""Launch the optiMHC GUI."""
if importlib.util.find_spec("streamlit") is None:
print("Error: Streamlit is not installed. Install GUI dependencies with:")
print("pip install optimhc[gui]")
return

import subprocess

# Get the path to the GUI app
gui_path = os.path.join(os.path.dirname(__file__), "gui", "app.py")

if not os.path.exists(gui_path):
print(f"Error: GUI application not found at {gui_path}")
return

# Create a temporary launcher script that uses the correct imports
import tempfile

launcher_content = """
import os
import sys
import streamlit

# Add the root directory to the path
sys.path.insert(0, '{}')

# Import the app module properly
from optimhc.gui.app import main

if __name__ == "__main__":
main()
""".format(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

fd, temp_path = tempfile.mkstemp(suffix=".py")
with os.fdopen(fd, "w") as f:
f.write(launcher_content)

# Launch Streamlit with the temporary script
print("Starting optiMHC GUI...")
try:
subprocess.run([sys.executable, "-m", "streamlit", "run", temp_path])
finally:
# Clean up the temporary file
try:
os.unlink(temp_path)
except OSError:
pass
Pipeline(pipeline_config).run_experiments()


if __name__ == "__main__":
Expand Down
12 changes: 8 additions & 4 deletions optimhc/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ def load_config(config_path):
Load and parse a configuration file using YAML.
Merges loaded config with default configuration.

Parameters:
config_path (str): Path to the YAML configuration file.
Parameters
----------
config_path : str
Path to the YAML configuration file.

Returns:
dict: A dictionary containing all configurations.
Returns
-------
dict
A dictionary containing all configurations.
"""
logger.info(f"Loading configuration from {config_path}")
with open(config_path, "r") as f:
Expand Down
Loading
Loading