Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

134 lines
4.8KB

  1. task cnvkit{
  2. String sample_id
  3. File ref_dir
  4. String? fasta
  5. File ref_flat
  6. File? bed_file
  7. String? Ploidy
  8. File tumor_bam
  9. File tumor_bam_index
  10. File? normal_bam
  11. File? normal_bam_index
  12. File? VCF
  13. String docker
  14. String cluster_config
  15. String disk_size
  16. String sample=basename(tumor_bam,".bam")
  17. command <<<
  18. set -o pipefail
  19. set -e
  20. nt=$(nproc)
  21. echo ${sample}
  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. /usr/local/bin/cnvkit.py target ${bed_file} --annotate ${ref_flat} --split --short-names -o my_baits.bed
  31. /usr/local/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. /usr/local/bin/cnvkit.py access ${ref_dir} -o access.bed
  41. # Prepare the target bed
  42. /usr/local/bin/cnvkit.py target ${bed_file} --annotate ${ref_flat} --split --short-names -o my_baits.bed
  43. /usr/local/bin/cnvkit.py autobin ${tumor_bam} -t my_baits.bed -g access.bed
  44. /usr/local/bin/cnvkit.py coverage ${tumor_bam} my_baits.target.bed -o ${sample}.T.targetcoverage.cnn
  45. /usr/local/bin/cnvkit.py coverage ${tumor_bam} my_baits.antitarget.bed -o ${sample}.T.antitargetcoverage.cnn
  46. /usr/local/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. /usr/local/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. /usr/local/bin/cnvkit.py access ${ref_dir} -o access.bed
  63. # Prepare the target bed
  64. #/usr/local/bin/cnvkit.py --annotate ${ref_flat} --split --short-names -o my_baits.bed
  65. /usr/local/bin/cnvkit.py autobin ${tumor_bam} --method wgs -g access.bed
  66. /usr/local/bin/cnvkit.py coverage ${tumor_bam} ${sample}.target.bed -o ${sample}.T.targetcoverage.cnn
  67. /usr/local/bin/cnvkit.py coverage ${tumor_bam} ${sample}.antitarget.bed -o ${sample}.T.antitargetcoverage.cnn
  68. /usr/local/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. /usr/local/bin/cnvkit.py batch ${tumor_bam} \
  73. -r ${sample}.reference.cnn/reference.cnn \
  74. --output-dir ${sample}.cns \
  75. -p $nt
  76. ls ./
  77. if [ ${VCF} ]; then
  78. /usr/local/bin/cnvkit.py call ${sample}.cns/${sample}.cns --center-at $center \
  79. -o ${sample}.call.cns
  80. else
  81. /usr/local/bin/cnvkit.py call ${sample}.cns/${sample}.cns --center-at $center --vcf ${VCF}\
  82. -o ${sample}.call.cns
  83. # Plot the results
  84. /usr/local/bin/cnvkit.py scatter ${sample}.cns/${sample}.cnr -s ${sample}.call.cns -o ${sample}.scatter.pdf
  85. /usr/local/bin/cnvkit.py diagram ${sample}.cns/${sample}.cnr -s ${sample}.call.cns -o ${sample}.diagram.pdf
  86. /usr/local/bin/cnvkit.py heatmap ${sample}.cns/${sample}.cnr ${sample}.call.cns -o ${sample}.heatmap.pdf
  87. #gain and loss
  88. /usr/local/bin/cnvkit.py export vcf ${sample}.call.cns -y -i "${sample}" -o ${sample}.call.cns.vcf
  89. tar cvf ${sample}.tar ${sample}*
  90. >>>
  91. runtime{
  92. docker:docker
  93. cluster:cluster_config
  94. systemDisk:"cloud_ssd 40"
  95. dataDisk:"cloud_ssd " + disk_size + " /cromwell_root/"
  96. timeout:259200
  97. }
  98. output{
  99. File out_file = "${sample}.tar"
  100. File cnv_bed = "${sample}.call.cns.vcf"
  101. }
  102. }