Update app.py
Browse files12344 unmodified lines910111213141516171819207 unmodified lines282930313233343548 unmodified lines8485868788899091929394959697989910010110210310410510610710846 unmodified lines155156157158159import gradio as grdef _safe_name(name: str) -> str:return "".join(c if c.isalnum() or c in "._-" else "_" for c in name)4 unmodified linesvalid = []for f in files:suffix = Path(f.name).suffix.lower()if suffix not in ALLOWED_EXTS:raise gr.Error(f"Unsupported file format: {f.name}. Use .fa, .fasta, .fna, or .fas")valid.append(f)return valid7 unmodified linestry:saved_files = []for f in files:dest = input_dir / _safe_name(Path(f.name).name)shutil.copy(f.name, dest)saved_files.append(dest)result = run_pangenome_pipeline(48 unmodified lines)identity = gr.Slider(minimum=0.7,maximum=1.0,value=0.9,step=0.01,label="Protein clustering identity threshold",)coverage = gr.Slider(minimum=0.5,maximum=1.0,value=0.8,step=0.01,label="Protein clustering coverage threshold",)core_threshold = gr.Slider(minimum=0.8,maximum=1.0,value=1.0,step=0.01,label="Core gene threshold (fraction of genomes)",)46 unmodified lines],)if __name__ == "__main__":demo.launch(server_name="0.0.0.0", server_port=7860)1234567891011121314151617181920212223242526272829304 unmodified lines353637383940414243444546477 unmodified lines555657585960616248 unmodified lines11111211311411511611711811912012112212312412512612712812913013113213313413546 unmodified lines182183184185186187import shutilimport tempfilefrom pathlib import Pathimport gradio as grimport pandas as pdfrom pangenome_core import run_pangenome_pipelineAPP_TITLE = "Pan-Genome Analysis Tool"APP_DESC = """Upload multiple genome FASTA files to identify and classify genes into:- Core genes- Accessory genes- Unique genesOutputs:- Summary statistics- Cluster membership table- Presence/absence matrix- Downloadable FASTA and CSV files"""ALLOWED_EXTS = {".fa", ".fasta", ".fna", ".fas"}def _safe_name(name: str) -> str:return "".join(c if c.isalnum() or c in "._-" else "_" for c in name)4 unmodified linesvalid = []for f in files:file_path = Path(f)suffix = file_path.suffix.lower()if suffix not in ALLOWED_EXTS:raise gr.Error(f"Unsupported file format: {file_path.name}. Use .fa, .fasta, .fna, or .fas")valid.append(file_path)return valid7 unmodified linestry:saved_files = []for f in files:dest = input_dir / _safe_name(f.name)shutil.copy(str(f), str(dest))saved_files.append(dest)result = run_pangenome_pipeline(48 unmodified lines)identity = gr.Slider(minimum=0.70,maximum=1.00,value=0.90,step=0.01,label="Protein clustering identity threshold",)coverage = gr.Slider(minimum=0.50,maximum=1.00,value=0.80,step=0.01,label="Protein clustering coverage threshold",)core_threshold = gr.Slider(minimum=0.80,maximum=1.00,value=1.00,step=0.01,label="Core gene threshold (fraction of genomes)",)46 unmodified lines],)if __name__ == "__main__":demo.launch(server_name="0.0.0.0", server_port=7860)
app.py+42-14