class_docstr: Test the iteration functionality provided by io.SamReader.
code: def test_downsampling(
      self, method, maybe_range, fraction, expected_n_reads
  ):
      reader = sam.SamReader(
          test_utils.genomics_core_testdata("test.bam"),
          downsample_fraction=fraction,
          random_seed=12345,
      )
      with reader:
          if method == "iterate":
              reads_iter = reader.iterate()
          elif method == "query":
              reads_iter = reader.query(
                  ranges.parse_literal(maybe_range)
              )
          else:
              self.fail("Unexpected method " + str(method))
          self.assertEqual(
              test_utils.iterable_len(reads_iter), expected_n_reads
          )
  
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 10 for calling the SamReaderTests obj's underlying member method code with example usage: obj.test_downsampling(method, maybe_range, fraction, expected_n_reads) without return types