from snakemake.utils import min_version
min_version("3.2")

input_channels = '/project/gcg/Data/1KG/multisample_bins.npz'

rule all:
  input:
    expand("results_wf2/{outercv_test_sample}/{outercv_test_sample}.sv-channels.vcf",
      outercv_test_sample=['HG00420','HG03992','HG01881'])

rule locso_per_chrom:
  input:
    svchan=input_channels,
    vcf='/project/gcg/Data/1KG/Manta/{outercv_test_sample}_manta.vcf'
  params:
    outercv_test_sample="{outercv_test_sample}",
    innercv_test_sample='HG01053',
    val_chrom='chr22',
    epochs=50,
    ncalls=50,
    batch_size=32
  output:
    outdir=directory("results_wf2/{outercv_test_sample}"),
    vcf="results_wf2/{outercv_test_sample}/{outercv_test_sample}.sv-channels.vcf",
    log="results_wf2/{outercv_test_sample}/{outercv_test_sample}.optimize.log"
  conda:
    "refactor"
  shell:
    """
    set -xe
    python nested_2fold_locso_cv.py \
        -i "{input.svchan}" \
        -o "{output.outdir}" \
        --manta_vcf_in "{input.vcf}" \
        --manta_vcf_out "{output.vcf}" \
        --outercv_test_sample {params.outercv_test_sample} \
        --innercv_test_sample {params.innercv_test_sample} \
        --val_chrom {params.val_chrom} \
        -e {params.epochs} \
        -n {params.ncalls} \
        --batch_size {params.batch_size} \
        --logfile {output.log}
    """
