-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathresults_database_search.py
More file actions
79 lines (61 loc) · 2.7 KB
/
Copy pathresults_database_search.py
File metadata and controls
79 lines (61 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Database Search (Comet) Results Page."""
import streamlit as st
from pathlib import Path
from src.common.common import page_setup
from src.common.results_helpers import get_workflow_dir
from openms_insight import Table, Heatmap, LinePlot, SequenceView, StateManager
params = page_setup()
st.title("Database Search Results")
st.markdown(
"""
View peptide-spectrum matches (PSMs) identified by **Comet** database search.
Click on a PSM to view the annotated spectrum and peptide sequence.
"""
)
st.info(
"**Score:** The e-value (expectation value) represents the expected number of random PSMs "
"with an equal or better score. Lower values indicate higher confidence identifications."
)
if "workspace" not in st.session_state:
st.warning("Please initialize your workspace first.")
st.stop()
workflow_dir = get_workflow_dir(st.session_state["workspace"])
comet_dir = workflow_dir / "results" / "comet_results"
cache_dir = workflow_dir / "results" / "insight_cache"
if not comet_dir.exists():
st.info("No database search results available yet. Please run the workflow first.")
st.page_link("content/workflow_run.py", label="Go to Run", icon="🚀")
st.stop()
comet_files = sorted(comet_dir.glob("*.idXML"))
if not comet_files:
st.warning("No identification output files found.")
st.stop()
selected_file = st.selectbox(
"Select identification result file",
comet_files,
format_func=lambda x: x.name
)
cache_id_prefix = selected_file.stem
# Check if cache exists
if not (cache_dir / f"table_{cache_id_prefix}").is_dir():
st.warning("Visualization cache not found. Please re-run the workflow.")
st.stop()
# Initialize state manager for cross-component linking
state_manager = StateManager()
# Load components from cache (no data parameter needed)
table = Table(cache_id=f"table_{cache_id_prefix}", cache_path=str(cache_dir))
heatmap = Heatmap(cache_id=f"heatmap_{cache_id_prefix}", cache_path=str(cache_dir))
seq_view = SequenceView(cache_id=f"seqview_{cache_id_prefix}", cache_path=str(cache_dir))
line_plot = LinePlot(cache_id=f"lineplot_{cache_id_prefix}", cache_path=str(cache_dir))
# Render components
st.subheader("PSM Overview")
heatmap(state_manager=state_manager, height=350)
st.subheader("PSM Table")
table(state_manager=state_manager, height=533)
st.subheader("Peptide Sequence")
seq_view(key=f"seqview_{cache_id_prefix}", state_manager=state_manager, height=533)
st.subheader("MS2 Spectrum")
line_plot(key=f"lineplot_{cache_id_prefix}", state_manager=state_manager, height=450, sequence_view_key=f"seqview_{cache_id_prefix}")
st.markdown("---")
st.markdown("**Next step:** View rescoring results")
st.page_link("content/results_rescoring.py", label="Go to Rescoring", icon="📈")