Guest User

Untitled

a guest
Mar 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/bin/bash
  2. set -e
  3.  
  4. # requires: bwa, samtools, bcftools
  5. # if using modules:
  6. source /mnt/software/Modules/current/init/bash
  7. module load bwa samtools bcftools
  8.  
  9. if [ $# -lt 2 ]; then
  10. echo "Usage: $0 ref /path/to/laa_job"
  11. echo "Output: Per barcode alignment to reference (*.aln.bam) and variant calls (*.vcf)"
  12. exit 1
  13. fi
  14.  
  15. REF="$1"
  16. FQTGZ="$2/tasks/pbcoretools.tasks.split_laa_fastq-0/consensus_fastq.tar.gz"
  17. FQZ="$2/tasks/pbcoretools.tasks.split_laa_fastq-0/consensus_fastq.zip"
  18.  
  19. # make sure the reference is indexed
  20. samtools faidx "${REF}"
  21. bwa index "${REF}"
  22.  
  23. # unzip fastqs
  24. if [ -e "${FQTGZ}" ]; then
  25. tar zxvf "${FQTGZ}"
  26. elif [ -e "${FQZ}" ]; then
  27. unzip -j "${FQZ}"
  28. else
  29. echo "LAA job not found at $2"
  30. exit 1
  31. fi
  32.  
  33. # align to reference and call variants
  34. for fastq in consensus_fastq.*.fastq
  35. do
  36. bwa mem "${REF}" "${fastq}" | samtools view -Sb - | samtools sort - > "${fastq%.*}.aln.bam"
  37. samtools index ${fastq%.*}.aln.bam
  38. samtools mpileup -uf "${REF}" "${fastq%.*}.aln.bam" | bcftools call -mv --ploidy 1 - > "${fastq%.*}.vcf"
  39. done
  40.  
  41. module remove bwa samtools bcftools
  42. set +e
Add Comment
Please, Sign In to add comment