code: def _write_cluster(metacluster, cluster, loci, idx, path):
      
      out_file = op.join(path, 'log', str(idx) + '.bed')
      with utils.safe_run(out_file):
          with open(out_file, 'w') as out_handle:
              for idc in metacluster:
                  for idl in cluster[idc].loci2seq:
                      pos = loci[idl].list()
                      print("\t".join(pos[:4] + [str(len(cluster[idc].loci2seq[idl]))] + [pos[-1]]), file=out_handle, end="")
docs: For complex meta-clusters, write all the loci for further debug