code: def bam_to_fastq_awk(self, bam_file, out_fastq_pre, paired_end):
          
          self.make_sure_path_exists(os.path.dirname(out_fastq_pre))
          fq1 = out_fastq_pre + "_R1.fastq"
          if paired_end:
              fq2 = out_fastq_pre + "_R2.fastq"
              cmd = self.tools.samtools + " view " + bam_file + " | awk '"
              cmd += r'{ if (NR%2==1) print "@"$1"/1\n"$10"\n+\n"$11 > "' + fq1 + '";'
              cmd += r' else print "@"$1"/2\n"$10"\n+\n"$11 > "' + fq2 + '"; }'
              cmd += "'"  # end the awk command
          else:
              fq2 = None
              cmd = self.tools.samtools + " view " + bam_file + " | awk '"
              cmd += r'{ print "@"$1"\n"$10"\n+\n"$11 > "' + fq1 + '"; }'
              cmd += "'"
          return cmd, fq1, fq2
docs: This converts bam file to fastq files, but using awk. As of 2016, this is much faster 
          than the standard way of doing this using Picard, and also much faster than the 
          bedtools implementation as well; however, it does no sanity checks and assumes the reads
          (for paired data) are all paired (no singletons), in the correct order.