code: def bam_to_fastq_bedtools(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"
          fq2 = None
          cmd = self.tools.bedtools + " bamtofastq -i " + bam_file + " -fq " + fq1 + ".fastq"
          if paired_end:
              fq2 = out_fastq_pre + "_R2.fastq"
              cmd += " -fq2 " + fq2
  
          return cmd, fq1, fq2
docs: Converts bam to fastq; A version using bedtools