Repository navigation
Expand file tree
/
Copy pathreporte.py
More file actions
66 lines (51 loc) · 1.99 KB
/
Copy pathreporte.py
File metadata and controls
66 lines (51 loc) · 1.99 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
import json
import os
import statistics
from collections import Counter
from pathlib import Path
from analizar_pdb import orquestar
def mostrar_reporte():
ruta_db = "data/bitacora_investigacion.json"
if not os.path.exists(ruta_db):
print("[ERROR] Aún no hay bitácora. Ejecuta un análisis primero.")
return
with open(ruta_db, "r") as f:
data = json.load(f)
# --- Cálculos Estadísticos ---
total = len(data)
if total == 0:
print("[INFO] La bitácora está vacía.")
return
frecuencias = [reg['frecuencia_hz'] for reg in data]
promedio_f = sum(frecuencias) / total
# Cálculo de desviación estándar (requiere al menos 2 datos)
stdev_f = statistics.stdev(frecuencias) if total > 1 else 0.0
bandas = Counter([reg['banda'] for reg in data])
# -----------------------------
print(f"\n{'='*75}")
print(f"{'REPORTE ANALÍTICO: PHIDYNAMICS':^75}")
print(f"{'='*75}")
print(f"{'ID':<10} | {'Delta':<10} | {'Hz':<10} | {'Banda Espectral'}")
print(f"{'-'*75}")
for reg in data:
print(f"{reg['pdb_id']:<10} | {reg['delta']:<10} | {reg['frecuencia_hz']:<10} | {reg['banda']}")
print(f"{'-'*75}")
print(f"RESUMEN ESTADÍSTICO:")
print(f"Total estructuras analizadas: {total}")
print(f"Frecuencia Promedio: {promedio_f:.2f} Hz")
print(f"Desviación Estándar (Estabilidad): {stdev_f:.4f} Hz")
print(f"Distribución por bandas: {dict(bandas)}")
print(f"{'='*75}\n")
def exportar_reporte_visual(pdb_id="1BNA"):
resultados, fig = orquestar(pdb_id, mostrar=False)
if fig is None:
print("[ERROR] No se pudo generar figura.")
return
salida = Path("outputs")
salida.mkdir(exist_ok=True)
archivo = salida / f"{pdb_id.lower()}_torsion.png"
fig.savefig(archivo, dpi=300, bbox_inches="tight")
print(f"[OK] Imagen exportada a: {archivo}")
if __name__ == "__main__":
mostrar_reporte()
exportar_reporte_visual("1BNA")