class_docstr: Tests for sam.SamWriter.
code: def test_roundtrip_cram_writer(self, filename, has_embedded_ref):
      output_path = test_utils.test_tmpfile(filename)
      writer_ref_path = test_utils.genomics_core_testdata("test.fasta")
      reader_ref_path = ""
      if not has_embedded_ref:
          reader_ref_path = writer_ref_path
      original_reader = sam.SamReader(
          test_utils.genomics_core_testdata(filename),
          ref_path=reader_ref_path,
      )
      original_records = list(original_reader.iterate())
      with sam.SamWriter(
          output_path,
          header=original_reader.header,
          ref_path=writer_ref_path,
          embed_ref=has_embedded_ref,
      ) as writer:
          for record in original_records:
              writer.write(record)
      with sam.SamReader(
          output_path, ref_path=reader_ref_path
      ) as new_reader:
          self.assertEqual(original_records, list(new_reader.iterate()))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  from absl.testing import absltest
  from absl.testing import parameterized
  import six
  from etils import epath
  from third_party.nucleus.io import sam
  from third_party.nucleus.io import tfrecord
  from third_party.nucleus.protos import reads_pb2
  from third_party.nucleus.protos import reference_pb2
  from third_party.nucleus.testing import test_utils
  from third_party.nucleus.util import ranges
label_desc: Use image node_id 4 for calling the ReadWriterTests obj's underlying member method code with example usage: obj.test_roundtrip_cram_writer(filename, has_embedded_ref) without return types