用于miRNA-seq二代测序数据分析
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

114 lines
4.9KB

  1. task ReadStats {
  2. String sample_id
  3. File in_log_trimAdatper
  4. File in_log_readFilter
  5. File in_log_align_miRNA
  6. File in_log_align_RNA
  7. File in_log_align_rn7
  8. File in_sam_align_RNA
  9. String cluster_config
  10. String disk_size
  11. command <<<
  12. set -o pipefail
  13. set -e
  14. n_Total_Sequence=$(cat ${in_log_trimAdatper} | grep 'total reads' | head -n 1 | cut -d ':' -f 2 | sed 's/ //g')
  15. n_AdapterNotFound=$(cat ${in_log_trimAdatper} | grep 'reads failed due to too long' | cut -d ':' -f 2 | sed 's/ //g')
  16. n_Total_forCount=$[$n_Total_Sequence-$n_AdapterNotFound]
  17. n_Pass_trimAdatper=$(cat ${in_log_trimAdatper} | grep 'reads passed filter' | tail -n 1 | cut -d ':' -f 2 | sed 's/ //g')
  18. n_Adapter_dimer=$[$n_Total_Sequence-$n_AdapterNotFound-$n_Pass_trimAdatper]
  19. n_Too_short=$(cat ${in_log_readFilter} | grep 'too short' | tail -n 1 | cut -d ':' -f 2 | sed 's/ //g')
  20. n_Low_quality_singleBase=$(cat ${in_log_readFilter} | grep 'low quality' | head -n 1 | cut -d ':' -f 2 | sed 's/ //g')
  21. n_Low_quality_tooManyN=$(cat ${in_log_readFilter} | grep 'too many N' | head -n 1 | cut -d ':' -f 2 | sed 's/ //g')
  22. n_Low_quality=$[$n_Low_quality_singleBase+$n_Low_quality_tooManyN]
  23. n_ForAlign=$(cat ${in_log_readFilter} | grep 'reads passed filter' | head -n 1 | cut -d ':' -f 2 | sed 's/ //g')
  24. n_miRNA_mature=$(cat ${in_log_align_miRNA} | grep 'at least one reported alignment' | head -n 1 | cut -d ':' -f 2 | cut -d '(' -f 1 | sed 's/ //g')
  25. n_miRNA_hairpin=$(cat ${in_log_align_preMiRNA} | grep 'at least one reported alignment' | head -n 1 | cut -d ':' -f 2 | cut -d '(' -f 1 | sed 's/ //g')
  26. n_RNA=$(cat ${in_log_align_RNA} | grep 'at least one reported alignment' | head -n 1 | cut -d ':' -f 2 | cut -d '(' -f 1 | sed 's/ //g')
  27. n_otGenomic=$(cat ${in_log_align_rn7} | grep 'at least one reported alignment' | head -n 1 | cut -d ':' -f 2 | cut -d '(' -f 1 | sed 's/ //g')
  28. n_notGenomic=$(cat ${in_log_align_rn7} | grep 'reads that failed to align' | head -n 1 | cut -d ':' -f 2 | cut -d '(' -f 1 | sed 's/ //g' )
  29. groupedReadCount=${sample_id}.trimAdapt.filter.align2RNA.grouped.readCount
  30. cat ${in_sam_align_RNA} | grep -v '@' | awk '($2!=4)' | cut -f 3 | sed 's/.*;//g' | awk '{a[$1]++}END{for(i in a){printf "%s\t%d\n",i,a[i]}}' > $groupedReadCount
  31. if [ $(cat $groupedReadCount | grep '^mRNA' | wc -l ) -gt 0 ]
  32. then
  33. n_mRNA=$(cat $groupedReadCount | grep '^mRNA' | cut -f 2 )
  34. else
  35. n_mRNA=0
  36. fi
  37. if [ $(cat $groupedReadCount | grep '^long_non-coding_RNA' | wc -l ) -gt 0 ]
  38. then
  39. n_lncRNA=$(cat $groupedReadCount | grep '^long_non-coding_RNA' | cut -f 2 )
  40. else
  41. n_lncRNA=0
  42. fi
  43. if [ $(cat $groupedReadCount | grep '^ribosomal_RNA' | wc -l ) -gt 0 ]
  44. then
  45. n_rRNA=$(cat $groupedReadCount | grep '^ribosomal_RNA' | cut -f 2 )
  46. else
  47. n_rRNA=0
  48. fi
  49. if [ $(cat $groupedReadCount | grep '^Y_RNA' | wc -l ) -gt 0 ]
  50. then
  51. n_YRNA=$(cat $groupedReadCount | grep '^Y_RNA' | cut -f 2 )
  52. else
  53. n_YRNA=0
  54. fi
  55. if [ $(cat $groupedReadCount | grep -E '^misc_RNA|small|guide_RNA|vault_RNA' | wc -l ) -gt 0 ]
  56. then
  57. n_otsmall=$(cat $groupedReadCount | grep -E '^misc_RNA|small|guide_RNA|vault_RNA' | cut -f 2 | awk '{sum+=$1}END{print sum}')
  58. else
  59. n_otsmall=0
  60. fi
  61. n_otTranscript=$[$n_RNA-$n_mRNA-$n_lncRNA-$n_rRNA-$n_YRNA-$n_otsmall]
  62. file_output=${sample_id}.readStats
  63. echo -e "Stage\tReadCount" > $file_output
  64. echo -e "adapter not found\t$n_AdapterNotFound" >> $file_output
  65. echo -e "adapter dimer\t$n_Adapter_dimer" >> $file_output
  66. echo -e "too short\t$n_Too_short" >> $file_output
  67. echo -e "low sequencing quality\t$n_Low_quality" >> $file_output
  68. echo -e "mature miRNA\t$n_miRNA_mature" >> $file_output
  69. echo -e "hairpin miRNA\t$n_miRNA_hairpin" >> $file_output
  70. echo -e "piRNA\t$n_piRNA" >> $file_output
  71. echo -e "tRNA\t$n_tRNA" >> $file_output
  72. echo -e "mRNA\t$n_mRNA" >> $file_output
  73. echo -e "lncRNA\t$n_lncRNA" >> $file_output
  74. echo -e "rRNA\t$n_rRNA" >> $file_output
  75. echo -e "YRNA\t$n_YRNA" >> $file_output
  76. echo -e "other small RNA\t$n_otsmall" >> $file_output
  77. echo -e "other from transcriptome\t$n_otTranscript" >> $file_output
  78. echo -e "other from human genome\t$n_otGenomic" >> $file_output
  79. echo -e "not from human genome\t$n_notGenomic" >> $file_output
  80. >>>
  81. runtime {
  82. cluster: cluster_config
  83. systemDisk: "cloud_ssd 40"
  84. dataDisk: "cloud_ssd " + disk_size + " /cromwell_root/"
  85. }
  86. output {
  87. File out="${sample_id}.readStats"
  88. File out_groupedCount="${sample_id}.trimAdapt.filter.align2RNA.grouped.readCount"
  89. }
  90. }