import "./tasks/benchmark.wdl" as benchmark
import "./tasks/mendelian.wdl" as mendelian
import "./tasks/merge_mendelian.wdl" as merge_mendelian
import "./tasks/merge_family.wdl" as merge_family
import "./tasks/quartet_mendelian.wdl" as quartet_mendelian

workflow {{ project_name }} {

	File inputSamplesFile
	Array[Array[File]] inputSamples = read_tsv(inputSamplesFile)

	String BENCHMARKdocker
	String MENDELIANdocker
	String DIYdocker

	String fasta
	File ref_dir
	File benchmark_region

	File benchmarking_dir

	String project

	String disk_size
	String BIGcluster_config
	String SMALLcluster_config


	scatter (sample in inputSamples){

		call benchmark.benchmark as LCL5_benchmark {
			input:
			vcf=sample[0],
			benchmarking_dir=benchmarking_dir,
			filtered_bed=benchmark_region,
			ref_dir=ref_dir,
			fasta=fasta,
			docker=BENCHMARKdocker,
			cluster_config=BIGcluster_config,
			disk_size=disk_size
		}

		call benchmark.benchmark as LCL6_benchmark {
			input:
			vcf=sample[1],
			benchmarking_dir=benchmarking_dir,
			filtered_bed=benchmark_region,
			ref_dir=ref_dir,
			fasta=fasta,
			docker=BENCHMARKdocker,
			cluster_config=BIGcluster_config,
			disk_size=disk_size
		}

		call benchmark.benchmark as LCL7_benchmark {
			input:
			vcf=sample[2],
			benchmarking_dir=benchmarking_dir,
			filtered_bed=benchmark_region,
			ref_dir=ref_dir,
			fasta=fasta,
			docker=BENCHMARKdocker,
			cluster_config=BIGcluster_config,
			disk_size=disk_size
		}

		call benchmark.benchmark as LCL8_benchmark {
			input:
			vcf=sample[3],
			benchmarking_dir=benchmarking_dir,
			filtered_bed=benchmark_region,
			ref_dir=ref_dir,
			fasta=fasta,
			docker=BENCHMARKdocker,
			cluster_config=BIGcluster_config,
			disk_size=disk_size
		}

		call merge_family.merge_family as merge_family {
			input:
			LCL5_vcf_gz=LCL5_benchmark.rtg_vcf,
			LCL5_vcf_idx=LCL5_benchmark.rtg_vcf_index,
			LCL6_vcf_gz=LCL6_benchmark.rtg_vcf,
			LCL6_vcf_idx=LCL6_benchmark.rtg_vcf_index,
			LCL7_vcf_gz=LCL7_benchmark.rtg_vcf,
			LCL7_vcf_idx=LCL7_benchmark.rtg_vcf_index,
			LCL8_vcf_gz=LCL8_benchmark.rtg_vcf,
			LCL8_vcf_idx=LCL8_benchmark.rtg_vcf,
			project=project,
			rep=sample[4],
			docker=BENCHMARKdocker,
			cluster_config=BIGcluster_config,
			disk_size=disk_size,
		}

		call mendelian.mendelian as mendelian {
			input:
			family_vcf=merge_family.merged_vcf,
			ref_dir=ref_dir,
			fasta=fasta,
			docker=MENDELIANdocker,
			cluster_config=BIGcluster_config,
			disk_size=disk_size		
		}

		call merge_mendelian.merge_mendelian as merge_mendelian {
			input:
			D5_trio_vcf=mendelian.D5_trio_vcf,
			D6_trio_vcf=mendelian.D6_trio_vcf,
			family_vcf=merge_family.merged_vcf,
			docker=DIYdocker,
			cluster_config=SMALLcluster_config,
			disk_size=disk_size
		}

	}

	call quartet_mendelian.quartet_mendelian as quartet_mendelian {
		input:
		summary=merge_mendelian.project_mendelian_summary,
		LCL5_hap=LCL5_benchmark.summary,
		LCL6_hap=LCL6_benchmark.summary,
		LCL7_hap=LCL7_benchmark.summary,
		LCL8_hap=LCL8_benchmark.summary,
		docker=DIYdocker,
		project=project,
		cluster_config=SMALLcluster_config,
		disk_size=disk_size
	}

}


