code: def bam_conversions(self, bam_file, depth=True):
          
          cmd = self.tools.samtools + " view -h " + bam_file + " > " + bam_file.replace(".bam", ".sam") + "\n"
          cmd += self.tools.samtools + " sort " + bam_file + " -o " + bam_file.replace(".bam", "_sorted.bam") + "\n"
          cmd += self.tools.samtools + " index " + bam_file.replace(".bam", "_sorted.bam") + "\n"
          if depth:
              cmd += self.tools.samtools + " depth " + bam_file.replace(".bam", "_sorted.bam") + " > " + bam_file.replace(".bam", "_sorted.depth") + "\n"
          return cmd
docs: Sort and index bam files for later use.
  
          :param bool depth: also calculate coverage over each position