code: def samples_to_records(samples, default_keys=None):
      
      from bcbio.pipeline import run_info
      RECORD_CONVERT_TO_LIST = set(["config__algorithm__tools_on", "config__algorithm__tools_off",
                                    "reference__genome_context"])
      all_keys = _get_all_cwlkeys(samples, default_keys)
      out = []
      for data in samples:
          for raw_key in sorted(list(all_keys)):
              key = raw_key.split("__")
              if tz.get_in(key, data) is None:
                  data = tz.update_in(data, key, lambda x: None)
              if raw_key not in data["cwl_keys"]:
                  data["cwl_keys"].append(raw_key)
              if raw_key in RECORD_CONVERT_TO_LIST:
                  val = tz.get_in(key, data)
                  if not val: val = []
                  elif not isinstance(val, (list, tuple)): val = [val]
                  data = tz.update_in(data, key, lambda x: val)
              # Booleans are problematic for CWL serialization, convert into string representation
              if isinstance(tz.get_in(key, data), bool):
                  data = tz.update_in(data, key, lambda x: str(tz.get_in(key, data)))
          data["metadata"] = run_info.add_metadata_defaults(data.get("metadata", {}))
          out.append(data)
      return out
docs: Convert samples into output CWL records.