You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.2KB

  1. task cnvkit{
  2. String sample_id
  3. File ref_dir
  4. String? fasta
  5. File ref_flat
  6. File? bed_file
  7. File hrd
  8. File tumor_bam
  9. File tumor_bam_index
  10. File? normal_bam
  11. File? normal_bam_index
  12. String docker
  13. String cluster_config
  14. String disk_size
  15. String sample=basename(tumor_bam,".bam")
  16. command <<<
  17. set -o pipefail
  18. set -e
  19. nt=$(nproc)
  20. echo ${sample}
  21. Ploidy=`awk -F'\t' '{print $7}' ${hrd} | sed -n '2p'`
  22. echo $Ploidy
  23. center=`awk -v vv=$Ploidy 'BEGIN {print log(2/vv)/log(2)}'`
  24. echo $center
  25. #WES
  26. if [ ${bed_file} ]; then
  27. echo "WES"
  28. if [ ${normal_bam} ]; then
  29. echo "WES with normal"
  30. /root/miniconda2/bin/cnvkit.py target ${bed_file} --annotate ${ref_flat} --split --short-names -o my_baits.bed
  31. /root/miniconda2/bin/cnvkit.py batch ${tumor_bam} \
  32. --normal ${normal_bam} \
  33. --targets my_baits.bed \
  34. --fasta ${ref_dir} \
  35. --annotate ${ref_flat} -p $nt \
  36. --drop-low-coverage \
  37. --output-dir ${sample}.reference.cnn
  38. else
  39. echo "WES no normal"
  40. /root/miniconda2/bin/cnvkit.py access ${ref_dir} -o access.bed
  41. # Prepare the target bed
  42. /root/miniconda2/bin/cnvkit.py target ${bed_file} --annotate ${ref_flat} --split --short-names -o my_baits.bed
  43. /root/miniconda2/bin/cnvkit.py autobin ${tumor_bam} -t my_baits.bed -g access.bed
  44. /root/miniconda2/bin/cnvkit.py coverage ${tumor_bam} my_baits.target.bed -o ${sample}.T.targetcoverage.cnn
  45. /root/miniconda2/bin/cnvkit.py coverage ${tumor_bam} my_baits.antitarget.bed -o ${sample}.T.antitargetcoverage.cnn
  46. /root/miniconda2/bin/cnvkit.py reference -o ${sample}.reference.cnn/reference.cnn -f ${ref_dir} -t my_baits.target.bed -a my_baits.antitarget.bed
  47. fi
  48. #WGS
  49. else
  50. echo "WGS"
  51. if [ ${normal_bam} ]; then
  52. echo "WGS with normal"
  53. /root/miniconda2/bin/cnvkit.py batch ${tumor_bam} \
  54. --normal ${normal_bam} \
  55. --method wgs \
  56. --fasta ${ref_dir} \
  57. --annotate ${ref_flat} -p $nt \
  58. --drop-low-coverage \
  59. --output-dir ${sample}.reference.cnn
  60. else
  61. echo "WGS no normal"
  62. /root/miniconda2/bin/cnvkit.py access ${ref_dir} -o access.bed
  63. # Prepare the target bed
  64. #/root/miniconda2/bin/cnvkit.py --annotate ${ref_flat} --split --short-names -o my_baits.bed
  65. /root/miniconda2/bin/cnvkit.py autobin ${tumor_bam} --method wgs -g access.bed
  66. /root/miniconda2/bin/cnvkit.py coverage ${tumor_bam} ${sample}.target.bed -o ${sample}.T.targetcoverage.cnn
  67. /root/miniconda2/bin/cnvkit.py coverage ${tumor_bam} ${sample}.antitarget.bed -o ${sample}.T.antitargetcoverage.cnn
  68. /root/miniconda2/bin/cnvkit.py reference -o ${sample}.reference.cnn/reference.cnn -f ${ref_dir} -t ${sample}.target.bed -a ${sample}.antitarget.bed
  69. fi
  70. fi
  71. ls ./
  72. /root/miniconda2/bin/cnvkit.py batch ${tumor_bam} \
  73. -r ${sample}.reference.cnn/reference.cnn \
  74. --output-dir ${sample}.cns \
  75. -p $nt
  76. ls ./
  77. /root/miniconda2/bin/cnvkit.py call ${sample}.cns/${sample}.cns --center-at $center \
  78. -o ${sample}.call.cns
  79. ls ./
  80. tar cvf ${sample}.tar ${sample}*
  81. >>>
  82. runtime{
  83. docker:docker
  84. cluster:cluster_config
  85. systemDisk:"cloud_ssd 40"
  86. dataDisk:"cloud_ssd " + disk_size + " /cromwell_root/"
  87. timeout:259200
  88. }
  89. output{
  90. File out_file = "${sample}.tar"
  91. #File cnv_bed = "${sample}.ratio_cnv.call.filter.bed"
  92. }
  93. }