{“role”: “user”, “content”: prompt},
]temperatura = 0,4, ) devolver opciones respectivas[0].message.content excepto Excepción como e: devolver f”Falló la síntesis de OpenAI: {e}” genes, W = generate_gene_regulatory_network(n_genes=14, edge_prob=0.20) X_expr = simular_gene_expression(W, n_steps=80, noise=0.08) grn_agent = GeneRegulatoryNetworkAgent() grn_result = grn_agent.run(genes, W, X_expr) proteínas, prot_features, prot_families, prot_localization = generate_protein_features(n_proteins=40, feature_dim=10) ppi_rows = generate_ppi_dataset(proteins, prot_features, prot_families, prot_localization) ppi_agent = ProteinInteractionPredictionAgent() ppi_result = ppi_agent.run(ppi_rows) metabolitos, reacciones = generate_metabolic_network() met_agent = MetabolicOptimizationAgent() met_result, met_trace = met_agent.run(reacciones, presupuesto_de oxígeno=3.5, presupuesto_sustrato=4.2) df_signal = simular_célula_señalización(T=220, dt=0.05, ligand_level=1.2) sig_agent = CellSignalingSimulationAgent() sig_result = sig_agent.run(df_signal) all_results = [grn_result, ppi_result, met_result, sig_result]
para r en all_results: Pretty(r.name, json.dumps(r.summary, indent=2)) fig = plt.figure(figsize=(18, 14)) ax1 = plt.subplot(2, 2, 1) im = ax1.imshow(W, cmap=”coolwarm”, aspecto=”auto”) ax1.set_title(“Matriz de peso regulatorio genético”) ax1.set_xticks(range(len(genes))) ax1.set_yticks(range(len(genes))) ax1.set_xticklabels(genes, rotación=90) ax1.set_yticklabels(genes) plt.colorbar(im, ax=ax1, fracción=0.046, pad=0.04) ax2 = plt.subplot(2, 2, 2) para i en rango(min(6, X_expr.shape[1])): ax2.plot(X_expr[:, i]etiqueta = genes[i]) ax2.set_title(“Dinámica de expresión genética de muestra”) ax2.set_xlabel(“Paso de tiempo”) ax2.set_ylabel(“Expresión”) ax2.legend(loc=”arriba a la derecha”, fontsize=8) ax3 = plt.subplot(2, 2, 3) ax3.plot(df_signal[“time”]señal_df[“receptor_active”]etiqueta=”Receptor”) ax3.plot(df_signal[“time”]señal_df[“kinase_active”]etiqueta=”Kinase”) ax3.plot(df_signal[“time”]señal_df[“tf_active”]etiqueta=”Factor de transcripción”) ax3.plot(df_signal[“time”]señal_df[“phosphatase”]label=”Fosfatasa”) ax3.set_title(“Simulación de señalización celular”) ax3.set_xlabel(“Tiempo”) ax3.set_ylabel(“Actividad”) ax3.legend() ax4 = plt.subplot(2, 2, 4) ax4.plot(met_trace) ax4.set_title(“Seguimiento del objetivo de búsqueda metabólica”) ax4.set_xlabel(“Iteración”) ax4.set_ylabel(“Puntuación objetiva”) plt.tight_layout() plt.show() G_grn = nx.DiGraph() para g en genes: G_grn.add_node(g) para i en rango(len(genes)): para j en rango(len(genes)): si abs(W[i, j]) > 0.4: G_grn.add_edge(genes[i]genes[j]peso=W[i, j]) plt.figure(figsize=(10, 8)) pos = nx.spring_layout(G_grn, seed=42) edge_colors = [“green” if G_grn[u][v][“weight”] > 0 else “rojo” para u, v en G_grn.edges()]nx.draw_networkx(G_grn, pos, with_labels=True, node_size=900, font_size=9, flechas=True, edge_color=edge_colors) plt.title(“Gráfico de red reguladora de genes (verde=activación, rojo=represión)”) plt.axis(“off”) plt.show() top_ppi = ppi_result.summary[“top_predicted_interactions”][:12]
G_ppi = nx.Graph() para la fila en top_ppi: a, b, p = fila[“protein_a”]fila[“protein_b”]fila[“pred_prob”]
G_ppi.add_edge(a, b, peso=p) plt.figure(figsize=(10, 8)) pos = nx.spring_layout(G_ppi, seed=7) anchos = [2 + 4 * G_ppi[u][v][“weight”] para u, v en G_ppi.edges()]nx.draw_networkx(G_ppi, pos, with_labels=True, node_size=1000, font_size=9, width=widths) plt.title(“Subred de interacción de proteínas más prevista”) plt.axis(“off”) plt.show() grn_table = pd.DataFrame(grn_result.summary[“most_dynamic_genes”]) ppi_table = pd.DataFrame(ppi_result.summary[“top_predicted_interactions”]) met_table = pd.DataFrame(met_result.summary[“dominant_reactions”]) sig_table = pd.DataFrame([sig_result.summary]) Pretty(“Genes más dinámicos”, grn_table.to_string(index=False)) Pretty(“Principales PPI pronosticados”, ppi_table.to_string(index=False)) Pretty(“Reacciones metabólicas dominantes”, met_table.to_string(index=False)) pi_agent = PrincipalInvestigatorAgent(cliente=cliente, modelo=OPENAI_MODEL) final_report = pi_agent.synthesize(all_results) Pretty(“INFORME DE BIOLOGÍA DE SISTEMAS OPENAI”, final_report) artefacto = { “grn”: grn_result.summary, “ppi”: ppi_result.summary, “metabolic”: met_result.summary, “signaling”: sig_result.summary, “llm_report”: final_report, } con open(“bio_agents_tutorial_results.json”, “w”) as f: json.dump(artifact, f, indent=2) print(“\nResultados guardados en: bio_agents_tutorial_results.json”)