Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simkin modular merge #11

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion PMO_Builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import streamlit as st
from src.format_page import render_header


def main():
render_header()
# Introduction Section
Expand Down
16 changes: 11 additions & 5 deletions conf/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
"alternatives": {
"target_id": [
"locus",
"amplicon"
"amplicon",
"mip_id"
],
"forward_primers": [
"fwd_primers"
"fwd_primers",
"extension_arm"
],
"reverse_primers": [
"rev_primers"
"rev_primers",
"ligation_arm"
]
}
},
Expand Down Expand Up @@ -130,7 +133,8 @@
"locus",
"marker_id",
"amplicon",
"locus_id"
"locus_id",
"p_targetName"
],
"asv": [
"amplicon_sequence_variant",
Expand All @@ -144,7 +148,9 @@
"reads": [
"read_count",
"sequence_reads",
"read_depth"
"read_depth",
"c_barcodeCnt",
"c_readCnt"
]
}
},
Expand Down
1 change: 0 additions & 1 deletion pages/1_Panel_Information.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from src.format_page import render_header
from src.utils import load_schema


class PanelManager:
def __init__(self, save_dir):
self.save_dir = save_dir
Expand Down
186 changes: 104 additions & 82 deletions pages/8_Create_Final_PMO.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,116 @@
import os
from src.format_page import render_header

current_directory = os.getcwd() # Get the current working directory
SAVE_DIR = os.path.join(current_directory, "PMO")
os.makedirs(SAVE_DIR, exist_ok=True)
def check_panel_info():
# PANEL INFO
if "panel_info" in st.session_state:
panel_info = st.session_state["panel_info"]
panel_id = ', '.join(panel_info["panel_info"].keys())
st.write("**Current Panel Information:**", panel_id)
else:
st.error(
"No panel information found. Please go to the Panel Information tab before proceeding.")
return panel_info, panel_id

render_header()
st.subheader("Create Final PMO", divider="gray")
def check_specimen_info():
# SPECIMEN INFO
if "specimen_info" in st.session_state:
spec_samples = ', '.join(
list(st.session_state["specimen_info"].keys())[:10])
st.write("**Current Specimen Information for samples (showing first 10):** ",
spec_samples, '...')
else:
st.error(
"No specimen information found. Please go to the Specimen Information tab before proceeding.")

st.subheader("Components")
# PANEL INFO
if "panel_info" in st.session_state:
panel_info = st.session_state["panel_info"]
panel_id = ', '.join(panel_info["panel_info"].keys())
st.write("**Current Panel Information:**", panel_id)
else:
st.error(
"No panel information found. Please go to the Panel Information tab before proceeding.")
def check_experiment_info():
# EXPERIMENT INFO
if "experiment_info" in st.session_state:
experiment_samples = ', '.join(
list(st.session_state["experiment_info"].keys())[:10])
st.write("**Current Experiment Information for samples (showing first 10):** ",
experiment_samples, '...')
else:
st.error(
"No experiment information found. Please go to the Experiment Information tab before proceeding.")

# SPECIMEN INFO
if "specimen_info" in st.session_state:
spec_samples = ', '.join(
list(st.session_state["specimen_info"].keys())[:10])
st.write("**Current Specimen Information for samples (showing first 10):** ",
spec_samples, '...')
else:
st.error(
"No specimen information found. Please go to the Specimen Information tab before proceeding.")
def check_microhaplotype_info():
# MICROHAPLOTYPE INFO
if "mhap_data" in st.session_state:
bioinfo_id = ', '.join(st.session_state["mhap_data"]["microhaplotypes_detected"].keys()
)
st.write(
"**Current Microhaplotype Information from bioinformatics run:**", bioinfo_id)
else:
st.error(
"No microhaplotype information found. Please go to the Microhaplotype Information tab before proceeding.")
return bioinfo_id

# EXPERIMENT INFO
if "experiment_info" in st.session_state:
experiment_samples = ', '.join(
list(st.session_state["experiment_info"].keys())[:10])
st.write("**Current Experiment Information for samples (showing first 10):** ",
experiment_samples, '...')
else:
st.error(
"No experiment information found. Please go to the Experiment Information tab before proceeding.")
def check_demultiplexed_info():
# DEMULTIPLEXED INFO
if "demultiplexed_data" in st.session_state:
# demultiplexed_data = st.session_state["demultiplexed_data"]
demultiplexed_bioinfo_id = st.session_state["demultiplexed_data"].keys()
st.write("**Current Demultiplexed Information from bioinformatics run:**",
', '.join(demultiplexed_bioinfo_id))
else:
st.error(
"No demultiplexed information found. Please go to the Demultiplexed Samples tab before proceeding.")

# MICROHAPLOTYPE INFO
if "mhap_data" in st.session_state:
bioinfo_id = ', '.join(st.session_state["mhap_data"]["microhaplotypes_detected"].keys()
)
st.write(
"**Current Microhaplotype Information from bioinformatics run:**", bioinfo_id)
else:
st.error(
"No microhaplotype information found. Please go to the Microhaplotype Information tab before proceeding.")
def check_sequencing_info():
# SEQUENCING INFO
if "seq_info" in st.session_state:
seq_info_id = st.session_state["seq_info"].keys(
)
st.write("**Current Sequencing Information had ID:**",
', '.join(seq_info_id))
else:
st.error(
"No sequencing information found. Please go to the Sequencing Information tab before proceeding.")

# DEMULTIPLEXED INFO
if "demultiplexed_data" in st.session_state:
# demultiplexed_data = st.session_state["demultiplexed_data"]
demultiplexed_bioinfo_id = st.session_state["demultiplexed_data"].keys()
st.write("**Current Demultiplexed Information from bioinformatics run:**",
', '.join(demultiplexed_bioinfo_id))
else:
st.error(
"No demultiplexed information found. Please go to the Demultiplexed Samples tab before proceeding.")
def check_bioinformatics_info():
# BIOINFORMATICS INFO
if "bioinfo_infos" in st.session_state:
bioinfo_info_id = st.session_state["bioinfo_infos"]["tar_amp_bioinformatics_info_id"]
st.write("**Current Bioinformatics Information had ID:**", bioinfo_info_id)
else:
st.error(
"No bioinformatics information found. Please go to the Bioinformatics Information tab before proceeding.")

# SEQUENCING INFO
if "seq_info" in st.session_state:
seq_info_id = st.session_state["seq_info"].keys(
)
st.write("**Current Sequencing Information had ID:**",
', '.join(seq_info_id))
else:
st.error(
"No sequencing information found. Please go to the Sequencing Information tab before proceeding.")
def merge_data(panel_info, panel_id, bioinfo_id):
# MERGE DATA
st.subheader("Merge Components to Final PMO")
if st.button("Merge Data"):
formatted_pmo = {
"experiment_infos": st.session_state["experiment_info"],
"sequencing_infos": st.session_state["seq_info"],
"specimen_infos": st.session_state["specimen_info"],
"taramp_bioinformatics_infos": st.session_state["bioinfo_infos"],
**st.session_state["mhap_data"],
**panel_info,
**st.session_state["demultiplexed_data"],
}
output_path = os.path.join(SAVE_DIR, f"{panel_id}_{bioinfo_id}.json")
with open(output_path, "w") as f:
json.dump(formatted_pmo, f, indent=4)
st.success(f"Your PMO has been saved! It can be found here: {output_path}")

# BIOINFORMATICS INFO
if "bioinfo_infos" in st.session_state:
bioinfo_info_id = st.session_state["bioinfo_infos"]["tar_amp_bioinformatics_info_id"]
st.write("**Current Bioinformatics Information had ID:**", bioinfo_info_id)
else:
st.error(
"No bioinformatics information found. Please go to the Bioinformatics Information tab before proceeding.")
def run_components():
panel_info, panel_id=check_panel_info()
check_specimen_info()
check_experiment_info()
bioinfo_id=check_microhaplotype_info()
check_demultiplexed_info()
check_sequencing_info()
check_bioinformatics_info()
merge_data(panel_info, panel_id, bioinfo_id)

# MERGE DATA
st.subheader("Merge Components to Final PMO")
if st.button("Merge Data"):
formatted_pmo = {
"experiment_infos": st.session_state["experiment_info"],
"sequencing_infos": st.session_state["seq_info"],
"specimen_infos": st.session_state["specimen_info"],
"taramp_bioinformatics_infos": st.session_state["bioinfo_infos"],
**st.session_state["mhap_data"],
**panel_info,
**st.session_state["demultiplexed_data"],
}
output_path = os.path.join(SAVE_DIR, f"{panel_id}_{bioinfo_id}.json")
with open(output_path, "w") as f:
json.dump(formatted_pmo, f, indent=4)
st.success(f"Your PMO has been saved! It can be found here: {output_path}")
# Initialize and run the app
if __name__ == "__main__":
current_directory = os.getcwd() # Get the current working directory
SAVE_DIR = os.path.join(current_directory, "finished_PMO_files")
os.makedirs(SAVE_DIR, exist_ok=True)
render_header()
st.subheader("Create Final PMO", divider="gray")
st.subheader("Components")
run_components()