#!/bin/bash 
l_min=12;
l_max=64;
for (( l=$l_min; l<=$l_max; l++ ))
do
    echo "l : $l";
    # (A) Generate datasets
    rm -f main.weight.multihit.l${l}.txt main.weight.coverage.l${l}.txt 
    for w in 2 3 4 5 6 7 8 9
    do
        echo "w : $w";
        s=$(($w+4));
        # (A) multihit
        # single seed 
        ./iedera -spaced -n 1 -v 0 -l ${l} -w ${w},${w} -s ${w},${s} -y 1 2>&1 | grep -v "WARNING" >> main.weight.multihit.l${l}.txt
        # double seed
        ./iedera -spaced -n 2 -v 0 -l ${l} -w ${w},${w} -s ${w},${s} -y 1 2>&1 | grep -v "WARNING" >> main.weight.multihit.l${l}.txt
        # (B) coverage
        # single seed 
        ./iedera -spaced -n 1 -v 0 -l ${l} -w ${w},${w} -s ${w},${s} -g 1 2>&1 | grep -v "WARNING" >> main.weight.coverage.l${l}.txt
        # double seed
        ./iedera -spaced -n 2 -v 0 -l ${l} -w ${w},${w} -s ${w},${s} -g 1 2>&1 | grep -v "WARNING" >> main.weight.coverage.l${l}.txt
    done
    # (B) Merge them
    cat main.weight.coverage.l${l}.txt | cut -f 2- > m${l}_.txt
    paste main.weight.multihit.l${l}.txt m${l}_.txt | grep "\"" > main.weight.full.l${l}.txt
    rm -f m${l}_.txt
    # (C) call the optimizer for pictures only (not movie)
    rm -f main.weight.multihit.l${l}.txt main.weight.coverage.l${l}.txt
    ./_optim_multilength_.pl main.weight.full.l${l}.txt ${l} > main.weight.l${l}.txt
done
