code: def parse_align_file(file_in):
      
      loc_id = 1
      bedfile_clusters = ""
      bamfile = pybedtools.BedTool(file_in)
      bed = pybedtools.BedTool.bam_to_bed(bamfile)
      for c, start, end, name, q, strand in bed:
          loc_id += 1
          bedfile_clusters += "%s\t%s\t%s\t%s\t%s\t%s\n" % \
                              (c, start, end, name, loc_id, strand)
      return bedfile_clusters
docs: Parse sam files with aligned sequences