code: def _organize_lanes(info_iter, barcode_ids):
      
      all_lanes = []
      for (fcid, lane, sampleref), info in itertools.groupby(info_iter, lambda x: (x[0], x[1], x[1])):
          info = list(info)
          cur_lane = dict(flowcell_id=fcid, lane=lane, genome_build=info[0][3], analysis="Standard")
          if not _has_barcode(info):
              cur_lane["description"] = info[0][1]
          else: # barcoded sample
              cur_lane["description"] = "Barcoded lane %s" % lane
              multiplex = []
              for (_, _, sample_id, _, bc_seq) in info:
                  bc_type, bc_id = barcode_ids[bc_seq]
                  multiplex.append(dict(barcode_type=bc_type,
                                        barcode_id=bc_id,
                                        sequence=bc_seq,
                                        name=sample_id))
              cur_lane["multiplex"] = multiplex
          all_lanes.append(cur_lane)
      return all_lanes
docs: Organize flat lane information into nested YAML structure.