 task split_gvcf_files {
	File gvcf
	String project
	String docker
	String cluster_config
	String disk_size
	
	command <<<

		cat ${gvcf} | grep '#CHROM' | sed s'/\t/\n/g' > name

		ncol=`cat name | wc -l`

		sed -i '1,9d' name

		cat ${gvcf} | grep '#' > header
		cat ${gvcf} | grep -v '#' > body
		cat body | grep -w '^chr1\|^chr2\|^chr3\|^chr4\|^chr5\|^chr6\|^chr7\|^chr8\|^chr9\|^chr10\|^chr11\|^chr12\|^chr13\|^chr14\|^chr15\|^chr16\|^chr17\|^chr18\|^chr19\|^chr20\|^chr21\|^chr22\|^chrX' > body.filtered
		cat header body.filtered > ${project}.filtered.g.vcf

		for i in $(seq 10 $ncol);  do  cat ${project}.filtered.g.vcf | cut -f1-9,$i > $i.splited.vcf; done

		ls *splited.vcf | sort -n | paste - name > rename

		cat rename | while read a b
		do
			mv $a $b.splited.vcf
			sample=$(echo $b | cut -f6 -d_)
			rep=$(echo $b | cut -f7 -d_)
			echo $sample >> quartet_sample
			echo $rep >> quartet_rep
		done

		python /opt/how_many_samples.py -sample quartet_sample -rep quartet_rep


	>>>

	runtime {
		docker:docker
		cluster: cluster_config
		systemDisk: "cloud_ssd 40"
		dataDisk: "cloud_ssd " + disk_size + " /cromwell_root/"
	}
	output {
		Array[File] splited_vcf = glob("*.splited.vcf")
		File sister_tag = "sister_tag"
		File quartet_tag = "quartet_tag"
	}
}