import gradio as gr import os import requests BREVO_KEY = os.environ["BREVO_API_KEY"] FROM_EMAIL = "epicamp.response@gmail.com" FROM_NAME = "EPIC-AMP" def send_report(to_email, pdf_b64, label, confidence, sequence): is_amp = 'AMP' in label and 'Non' not in label label_color = '#2e7d32' if is_amp else '#c62828' html_content = f"""

EPIC-AMP Analysis Report

Explainable Antimicrobial Peptide Classification Platform

Dear Researcher,

Your peptide sequence has been successfully analyzed using the EPIC-AMP platform. Please find your detailed PDF report attached.

Metric Result
Classification {label}
Confidence Score {confidence}
Input Sequence {sequence}

The attached PDF includes LIME feature attributions, MIC predictions, and global SHAP feature importance.

For questions reach us at epicamp.sup@gmail.com.

Best regards,
The EPIC-AMP Team
Bioinformatics & Computational Biology Unit (BCBU)


Zewail City of Science and Technology · BCBU · Giza, Egypt
📧 epicamp.sup@gmail.com
This is an automated message — please do not reply directly.

""" resp = requests.post( "https://api.brevo.com/v3/smtp/email", headers={ "api-key": BREVO_KEY, "Content-Type": "application/json" }, json={ "sender": {"email": FROM_EMAIL, "name": FROM_NAME}, "to": [{"email": to_email}], "subject": f"EPIC-AMP Analysis Report — {label}", "htmlContent": html_content, "attachment": [{ "content": pdf_b64, "name": "EPIC-AMP_Report.pdf" }] }, timeout=20 ) return "sent" if resp.status_code == 201 else f"error:{resp.status_code}:{resp.text}" with gr.Blocks() as demo: with gr.Row(): to_email = gr.Text(label="Recipient Email") pdf_b64 = gr.Text(label="PDF Base64") label_in = gr.Text(label="Label") confidence = gr.Text(label="Confidence") sequence = gr.Text(label="Sequence") result = gr.Text(label="Status") btn = gr.Button("Send") btn.click( fn=send_report, inputs=[to_email, pdf_b64, label_in, confidence, sequence], outputs=result, api_name="send" ) demo.launch(ssr_mode=False)