code: def test_interval_coverage():
      vds = hl.vds.read_vds(
          os.path.join(resource("vds"), "1kg_chr22_5_samples.vds")
      )
  
      interval1 = "chr22:10678825-10678835"
      interval2 = "chr22:10678970-10678979"
  
      intervals = hl.Table.parallelize(
          list(
              hl.struct(
                  interval=hl.parse_locus_interval(
                      x, reference_genome="GRCh38"
                  )
              )
              for x in [interval1, interval2]
          ),
          key="interval",
      )
  
      checkpoint_path = new_temp_file()
      r = hl.vds.interval_coverage(
          vds, intervals, gq_thresholds=(1, 21), dp_thresholds=(0, 1, 6)
      ).checkpoint(checkpoint_path)
      assert r.aggregate_rows(
          hl.agg.collect(
              (
                  hl.format(
                      "%s:%d-%d",
                      r.interval.start.contig,
                      r.interval.start.position,
                      r.interval.end.position,
                  ),
                  r.interval_size,
              )
          )
      ) == [(interval1, 10), (interval2, 9)]
  
      observed = r.aggregate_entries(hl.agg.collect(r.entry))
      expected = [
          hl.Struct(
              bases_over_gq_threshold=(10, 0),
              bases_over_dp_threshold=(10, 10, 5),
              sum_dp=55,
              fraction_over_gq_threshold=(1.0, 0.0),
              fraction_over_dp_threshold=(1.0, 1.0, 0.5),
              mean_dp=5.5,
          ),
          hl.Struct(
              bases_over_gq_threshold=(10, 0),
              bases_over_dp_threshold=(10, 10, 0),
              sum_dp=45,
              fraction_over_gq_threshold=(1.0, 0.0),
              fraction_over_dp_threshold=(1.0, 1.0, 0),
              mean_dp=4.5,
          ),
          hl.Struct(
              bases_over_gq_threshold=(0, 0),
              bases_over_dp_threshold=(10, 0, 0),
              sum_dp=0,
              fraction_over_gq_threshold=(0.0, 0.0),
              fraction_over_dp_threshold=(1.0, 0, 0),
              mean_dp=0,
          ),
          hl.Struct(
              bases_over_gq_threshold=(10, 0),
              bases_over_dp_threshold=(10, 10, 0),
              sum_dp=30,
              fraction_over_gq_threshold=(1.0, 0.0),
              fraction_over_dp_threshold=(1.0, 1.0, 0.0),
              mean_dp=3.0,
          ),
          hl.Struct(
              bases_over_gq_threshold=(9, 0),
              bases_over_dp_threshold=(10, 10, 0),
              sum_dp=10,
              fraction_over_gq_threshold=(0.9, 0.0),
              fraction_over_dp_threshold=(1.0, 1.0, 0.0),
              mean_dp=1.0,
          ),
          hl.Struct(
              bases_over_gq_threshold=(9, 9),
              bases_over_dp_threshold=(9, 9, 9),
              sum_dp=153,
              fraction_over_gq_threshold=(1.0, 1.0),
              fraction_over_dp_threshold=(1.0, 1.0, 1.0),
              mean_dp=17.0,
          ),
          hl.Struct(
              bases_over_gq_threshold=(9, 9),
              bases_over_dp_threshold=(9, 9, 9),
              sum_dp=159,
              fraction_over_gq_threshold=(1.0, 1.0),
              fraction_over_dp_threshold=(1.0, 1.0, 1.0),
              mean_dp=159 / 9,
          ),
          hl.Struct(
              bases_over_gq_threshold=(9, 9),
              bases_over_dp_threshold=(9, 9, 9),
              sum_dp=98,
              fraction_over_gq_threshold=(1.0, 1.0),
              fraction_over_dp_threshold=(1.0, 1.0, 1.0),
              mean_dp=98 / 9,
          ),
          hl.Struct(
              bases_over_gq_threshold=(9, 9),
              bases_over_dp_threshold=(9, 9, 9),
              sum_dp=72,
              fraction_over_gq_threshold=(1.0, 1.0),
              fraction_over_dp_threshold=(1.0, 1.0, 1.0),
              mean_dp=8,
          ),
          hl.Struct(
              bases_over_gq_threshold=(9, 0),
              bases_over_dp_threshold=(9, 9, 0),
              sum_dp=20,
              fraction_over_gq_threshold=(1.0, 0.0),
              fraction_over_dp_threshold=(1.0, 1.0, 0.0),
              mean_dp=2 / 9,
          ),
      ]
  
      for i in range(len(expected)):
          obs = observed[i]
          exp = expected[i]
          assert (
              obs.bases_over_gq_threshold == exp.bases_over_gq_threshold
          ), i
          assert obs.sum_dp == exp.sum_dp, i
          assert (
              obs.bases_over_dp_threshold == exp.bases_over_dp_threshold
          ), i
          assert (
              obs.fraction_over_gq_threshold
              == exp.fraction_over_gq_threshold
          ), i
          assert (
              obs.fraction_over_dp_threshold
              == exp.fraction_over_dp_threshold
          ), i
          pytest.approx(obs.mean_dp, exp.mean_dp)
  
imports: import os
  import pytest
  import hail
  from hail.utils import new_temp_file
  from hail.vds.combiner.combine import defined_entry_fields
  from ..helpers import resource, test_timeout, qobtest
label_desc: Use image node_id 10 for calling a global function with example usage: test_interval_coverage() without return types