code: def test_reference_genome_liftover():
      grch37 = hl.get_reference("GRCh37")
      grch38 = hl.get_reference("GRCh38")
  
      assert not grch37.has_liftover("GRCh38")
      assert not grch38.has_liftover("GRCh37")
      grch37.add_liftover(
          resource("grch37_to_grch38_chr20.over.chain.gz"), "GRCh38"
      )
      grch38.add_liftover(
          resource("grch38_to_grch37_chr20.over.chain.gz"), "GRCh37"
      )
      assert grch37.has_liftover("GRCh38")
      assert grch38.has_liftover("GRCh37")
      assert grch37._liftovers == {
          "GRCh38": resource("grch37_to_grch38_chr20.over.chain.gz")
      }
      assert grch38._liftovers == {
          "GRCh37": resource("grch38_to_grch37_chr20.over.chain.gz")
      }
  
      ds = hl.import_vcf(resource("sample.vcf"))
      t = ds.annotate_rows(
          liftover=hl.liftover(
              hl.liftover(ds.locus, "GRCh38"), "GRCh37"
          )
      ).rows()
      assert t.all(t.locus == t.liftover)
  
      null_locus = hl.missing(hl.tlocus("GRCh38"))
  
      rows = [
          {"l37": hl.locus("20", 1, "GRCh37"), "l38": null_locus},
          {"l37": hl.locus("20", 60000, "GRCh37"), "l38": null_locus},
          {
              "l37": hl.locus("20", 60001, "GRCh37"),
              "l38": hl.locus("chr20", 79360, "GRCh38"),
          },
          {
              "l37": hl.locus("20", 278686, "GRCh37"),
              "l38": hl.locus("chr20", 298045, "GRCh38"),
          },
          {
              "l37": hl.locus("20", 278687, "GRCh37"),
              "l38": hl.locus("chr20", 298046, "GRCh38"),
          },
          {"l37": hl.locus("20", 278688, "GRCh37"), "l38": null_locus},
          {"l37": hl.locus("20", 278689, "GRCh37"), "l38": null_locus},
          {"l37": hl.locus("20", 278690, "GRCh37"), "l38": null_locus},
          {
              "l37": hl.locus("20", 278691, "GRCh37"),
              "l38": hl.locus("chr20", 298047, "GRCh38"),
          },
          {
              "l37": hl.locus("20", 37007586, "GRCh37"),
              "l38": hl.locus("chr12", 32563117, "GRCh38"),
          },
          {
              "l37": hl.locus("20", 62965520, "GRCh37"),
              "l38": hl.locus("chr20", 64334167, "GRCh38"),
          },
          {
              "l37": hl.locus("20", 62965521, "GRCh37"),
              "l38": null_locus,
          },
      ]
      schema = hl.tstruct(l37=hl.tlocus(grch37), l38=hl.tlocus(grch38))
      t = hl.Table.parallelize(rows, schema)
      assert t.all(
          hl.if_else(
              hl.is_defined(t.l38),
              hl.liftover(t.l37, "GRCh38") == t.l38,
              hl.is_missing(hl.liftover(t.l37, "GRCh38")),
          )
      )
  
      t = t.filter(hl.is_defined(t.l38))
      assert t.count() == 6
  
      t = t.key_by("l38")
      t.count()
      assert list(t.key) == ["l38"]
  
      null_locus_interval = hl.missing(
          hl.tinterval(hl.tlocus("GRCh38"))
      )
      rows = [
          {
              "i37": hl.locus_interval(
                  "20", 1, 60000, True, False, "GRCh37"
              ),
              "i38": null_locus_interval,
          },
          {
              "i37": hl.locus_interval(
                  "20", 60001, 82456, True, True, "GRCh37"
              ),
              "i38": hl.locus_interval(
                  "chr20", 79360, 101815, True, True, "GRCh38"
              ),
          },
      ]
      schema = hl.tstruct(
          i37=hl.tinterval(hl.tlocus(grch37)),
          i38=hl.tinterval(hl.tlocus(grch38)),
      )
      t = hl.Table.parallelize(rows, schema)
      assert t.all(hl.liftover(t.i37, "GRCh38") == t.i38)
  
      grch37.remove_liftover("GRCh38")
      grch38.remove_liftover("GRCh37")
  
file_path: hail/hail/python/test/hail/genetics/test_reference_genome.py
imports: import pytest
  from random import randint
  import hail
  from hail.genetics import *
  from ..helpers import *
  from hail.utils import FatalError
label_desc: Use image node_id 3 for calling a global function with example usage: test_reference_genome_liftover() without return types