<jupyter_start><jupyter_text>Correr experimentos<jupyter_code>import math, subprocess
import numpy as np
import os
from IPython.display import display, clear_output
def correr_experimento(algoritmo, secuencia1, secuencia2):
    # Crear proceso para ejecutar el codigo.
    process = subprocess.Popen(["../cli", "-a", algoritmo, "-s", secuencia1, "-t", secuencia2], stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines = True)
    
    exit_code = process.wait()

    # Verificar que el proceso no fallo.
    assert exit_code == 0, F"Hubo un error en la experimentacion para el algoritmo: {algoritmo} con la secuencia {secuencia1} y {secuencia2}."
    # Leer salida de STDERR con los tiempos de ejecucion de cada metodo.
    outputs = process.stderr.readline().split(); 
    
    tiempo = outputs[0]
    celdas = outputs[1]
    score = outputs[2]
    longitud1 = outputs[3]
    longitud2 = outputs[4]
    
    process.stdin.close();
    process.stdout.close();
    process.stderr.close();

    return tiempo, celdas, score, longitud1, longitud2
experimentos = [];<jupyter_output><empty_output><jupyter_text>Experimento NW<jupyter_code>genomes = [f"../sequences/genomes/{name}" for name in os.listdir("../sequences/genomes/")]

for genome1 in genomes:
    for genome2 in genomes:
        if genome1 == genome2:
            continue
        for lenguaje in ["C","ASM"]:
            for tecnologia in ["LIN","SSE","AVX","AVX512"]:
                if not (lenguaje == "ASM" and tecnologia == "LIN"):
                    algoritmo = f"NW_{lenguaje}_{tecnologia}"
                    experimentos.append(["NW_genomes", algoritmo, genome1, genome2])

randoms = [f"../sequences/random/{name}" for name in os.listdir("../sequences/random/")]

for random1 in randoms:
    random1_len = random1.split('_')[1]
    for random2 in randoms:
        random2_len = random2.split('_')[1]
        if random1_len != random2_len or random1 == random2:
            continue
        for lenguaje in ["C","ASM"]:
            for tecnologia in ["LIN","SSE","AVX","AVX512"]:
                if not (lenguaje == "ASM" and tecnologia == "LIN"):
                    algoritmo = f"NW_{lenguaje}_{tecnologia}"
                    experimentos.append(["NW_random", algoritmo, random1, random2])<jupyter_output><empty_output><jupyter_text>Experimento SW<jupyter_code>ref_seq_dirs = [name for name in os.listdir("../sequences/reads/")]

ref_seq_and_read_pairs = []

for ref_dir in ref_seq_dirs:
    ref_seq = f"../sequences/genomes/{ref_dir}.fasta"
    for name in os.listdir(f"../sequences/reads/{ref_dir}"):
        ref_seq_read = f"../sequences/reads/{ref_dir}/{name}" 
        ref_seq_and_read_pairs.append((ref_seq, ref_seq_read))

for seq_pairs in ref_seq_and_read_pairs:
    for lenguaje in ["C","ASM"]:
        for tecnologia in ["LIN","SSE","AVX","AVX512"]:
            if not (lenguaje == "ASM" and tecnologia == "LIN"):
                algoritmo = f"SW_{lenguaje}_{tecnologia}"
                experimentos.append(["SW_reads", algoritmo, seq_pairs[0], seq_pairs[1]])
            

randoms = [f"../sequences/random/{name}" for name in os.listdir("../sequences/random/")]

for random1 in randoms:
    random1_len = random1.split('_')[1]
    for random2 in randoms:
        random2_len = random2.split('_')[1]
        if random1_len != random2_len or random1 == random2:
            continue
        for lenguaje in ["C","ASM"]:
            for tecnologia in ["LIN","SSE","AVX","AVX512"]:
                if not (lenguaje == "ASM" and tecnologia == "LIN"):
                    algoritmo = f"SW_{lenguaje}_{tecnologia}"
                    experimentos.append(["SW_random", algoritmo, random1, random2])
columnas = [
    "experimento",
    "algoritmo",
    "secuencia1",
    "secuencia2",
    "longitud1",
    "longitud2",
    "tiempo",
    "celdas",
    "score"
];

filas = [];
numero = 1
T = 1 # Numero de veces que se ejecuta cada experimento
for experimento in experimentos:
    
    clear_output(wait=True)
    display('Experimento: ' + str(numero) + "/" + str(len(experimentos)))
    numero += 1
    
    exp = experimento[0]
    algoritmo = experimento[1]
    secuencia1 = experimento[2]
    secuencia2 = experimento[3]
    
#     tiempos = []
      
    for i in range(0, T):
        tiempo, celdas, score, longitud1, longitud2 = correr_experimento(algoritmo, secuencia1, secuencia2)
#         tiempos.append(tiempo);
        
#     tiempo_promedio = np.median(tiempos);
    
        filas.append([
            exp,
            algoritmo,
            secuencia1,
            secuencia2,
            longitud1,
            longitud2,
            tiempo,
            celdas,
            score]
        );

df_resultado = pd.DataFrame(filas, columns=columnas);
df_resultado.to_csv("results/resultado.csv", index=False, header=True);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13453650533223954, 'fraction_numerical': 0.01763740771123872, 'mean_word_length': 2.8042121684867394, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '295192', 'license': 'MIT', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1690, 'n_words': 351, 'path': 'Exp/.ipynb_checkpoints/CorrerExperimentos-checkpoint.ipynb', 'repo_name': 'kugelblitz1235/TPOrga_Final', 'size': '4876'}