import "./tasks/fastqc.wdl" as fastqc
import "./tasks/fastqscreen.wdl" as fastqscreen
import "./tasks/qualimap.wdl" as qualimap
import "./tasks/sentieon.wdl" as sentieon
import "./tasks/multiqc.wdl" as multiqc
import "./tasks/mergeSentieon.wdl" as mergeSentieon


workflow {{ project_name }} {

	File inputSamplesFile
	Array[Array[File]] inputSamples = read_tsv(inputSamplesFile)
	File screen_ref_dir
	File fastq_screen_conf
	File ref_dir
	String fasta

	scatter (sample in inputSamples) {
		call fastqc.fastqc as fastqc {
			input:
			read1=sample[0],
			read2=sample[1]
		}

		call fastqscreen.fastq_screen as fastqscreen {
			input:
			read1=sample[0],
			read2=sample[1],
			screen_ref_dir=screen_ref_dir,
			fastq_screen_conf=fastq_screen_conf
		}

		call qualimap.qualimap as qualimap {
			input:
			bam=sample[2],
			bai=sample[3]
		}

		call sentieon.sentieon as sentieon {
			input:
			aln_metrics=sample[7],
			dedup_metrics=sample[8],
			is_metrics=sample[9],
			deduped_coverage=sample[10],
			sample_name=sample[6]
		}

	}
	call multiqc.multiqc as multiqc {
		input:
		read1_zip=fastqc.read1_zip,
		read2_zip=fastqc.read2_zip,
		txt1=fastqscreen.txt1,
		txt2=fastqscreen.txt2,
		zip=qualimap.zip
	}

	call mergeSentieon.mergeSentieon as mergeSentieon {
		input:
		aln_metrics_header=sentieon.aln_metrics_header,
		aln_metrics_data=sentieon.aln_metrics_data,
		dedup_metrics_header=sentieon.dedup_metrics_header,
		dedup_metrics_data=sentieon.dedup_metrics_data,
		is_metrics_header=sentieon.is_metrics_header,
		is_metrics_data=sentieon.is_metrics_data,
		deduped_coverage_header=sentieon.deduped_coverage_header,
		deduped_coverage_data=sentieon.deduped_coverage_data
	}
}

